Language: C++

// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

// kmp をやるための前計算
vector<int> makeTable(const string& s) {
  int n = s.size();
  vector<int> ret(n+1);
  ret[0] = -1;
  int j = -1;
  for (int i = 0; i < n; i++) {
    while (j >= 0 && s[i] != s[j]) j = ret[j];
    ret[i+1] = ++j;
  }
  return ret;
}

// str の中に word とマッチする場所のリストを返す
// ret のそれぞれの要素 el は, 「str[el] からの文字列が word と一致する」ことを示す
vector<int> kmp(const string& str, const string& word) {
  vector<int> table = makeTable(word);
  vector<int> ret;
  int m = 0, i = 0, n = str.size();
  while (m+i < n) {
    if (word[i] == str[m+i]) {
      if (++i == (int)(word.size())) {
        ret.pb(m);
        m = m+i-table[i];
        i = table[i];
      }
    } else {
      m = m+i-table[i];
      if (i > 0) i = table[i];
    }
  }
  return ret;
}


set<int> found;
int n,m;
map<int, int> used;
map<int, int> memo;

int dfs(int i){
  assert(i<=n-1);
  used[i] = 1;
  int ni = (i+m)%n;
  if (used[ni] && memo[ni]==0){
    memo[i] = INF;
    return memo[i];
  }
  else if(used[ni] && memo[ni]>0){
    memo[i] = memo[ni]+1;
    return memo[i];
  }
  else if(used[ni]){
    assert(false);
  }

  if (found.find(ni)!=found.end()){
    memo[i] = dfs(ni)+1;
    return memo[i];
  }
  else{
    memo[i] = 1;
    return memo[i];
  }
}
int solve(){
  string s,t;cin>>s>>t;
  n = sz(s);
  m = sz(t);
  while (sz(s)<sz(t)){
    s += s;
  }

  found = kmp(s, t);
  dump(found);

  assert(false);

  // map<int, int> d;
  //
  // each(e, found){
  //   if (e<=n-1) dfs(e);
  // }
  // dump(used);
  // dump(memo);
  //
  // int ans = 0;
  // each(el, memo){
  //   chmax(ans, el.second);
  // }
  // if (ans>=INF){
  //   cout << -1 << endl;
  // }
  // else{
  //   cout << ans << endl;
  // }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Compiler output:
a.cc: In function 'long long int solve()':
a.cc:125:19: error: no match for 'operator=' (operand types are 'std::set<long long int>' and 'std::vector<long long int>')
  125 |   found = kmp(s, t);
      |                   ^
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_set.h:300:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(const std::set<_Key, _Compare, _Alloc>&) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
  300 |       operator=(const set&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_set.h:300:17: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'const std::set<long long int>&'
  300 |       operator=(const set&) = default;
      |                 ^~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:304:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::set<_Key, _Compare, _Alloc>&&) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
  304 |       operator=(set&&) = default;
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_set.h:304:17: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::set<long long int>&&'
  304 |       operator=(set&&) = default;
      |                 ^~~~~
/usr/include/c++/14/bits/stl_set.h:318:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>& std::set<_Key, _Compare, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>]'
  318 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/14/bits/stl_set.h:318:46: note:   no known conversion for argument 1 from 'std::vector<long long int>' to 'std::initializer_list<long long int>'
  318 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~