제출 #1006115

#제출 시각아이디문제언어결과실행 시간메모리
1006115AverageAmogusEnjoyerNecklace (Subtask 1-3) (BOI19_necklace1)C++17
0 / 85
54 ms348 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> bool cmin(T &i, T j) { return i > j ? i=j,true:false; } template<class T> bool cmax(T &i, T j) { return i < j ? i=j,true:false; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { string s,t; cin >> s >> t; int n = (int)s.size(); int ans = 0; int a = 0,b = 0; auto search = [&](bool sw) { for (int i=0;i<n;i++) { for (int j=i;j<n;j++) { for (int k=i;k>=0;k--) { string r = s.substr(i,j-i+1); string f = s.substr(k,i-k); r += f; auto z = t.find(r); if (z != string::npos && cmax(ans,(int)r.size())) { /* cout << "s = " << s << endl; cout << "t = " << t << endl; cout << "r = " << r << endl; cout << "find = " << t.find(r) << endl; */ a = k; b = (sw ? n - (z + (int)r.size() - 1) : z); } } } } }; search(false); reverse(t.begin(),t.end()); search(true); assert(ans); cout << ans << endl << a << " " << b << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...