#include <bits/stdc++.h>
#define suiii ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define co cout<<
//#pragma GCC optimize("O3,Ofast,unroll-loops")
//#pragma GCC target("avx2,sse3,sse4,avx")
using namespace std;
//stuff
map<string,bool>mp;
map<string,int>mp1;
void rec(string s,ll idx){
if(mp1.count(s)!=0){
co s.size()<<'\n'<<idx<<' '<<mp1[s];
exit(0);
}
if(mp.count(s)) return;
mp[s]=1;
string t=s;
reverse(t.begin(),t.end());
rec(t,idx);
s.push_back(s[0]);
s.erase(s.begin());
rec(s,idx);
}
string s,t;
void solve(){
cin>>s>>t;
if(s.size()>t.size()) swap(s,t);
for(int k=s.size();k>0;k--){
for(int i=0;i<t.size();i++){
if(i+k-1>=t.size()) break;
mp1[t.substr(i,k)]=i;
}
for(int i=0;i<s.size();i++){
if(i+k-1>=s.size()) break;
rec(s.substr(i,k),i);
}
mp1.clear();
mp.clear();
}
}
int main()
{
suiii
int tt=1;
// cin>>tt;
while(tt--){
solve();
}
return 0;
}
Compilation message
necklace.cpp: In function 'void solve()':
necklace.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(int i=0;i<t.size();i++){
| ~^~~~~~~~~
necklace.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if(i+k-1>=t.size()) break;
| ~~~~~^~~~~~~~~~
necklace.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i=0;i<s.size();i++){
| ~^~~~~~~~~
necklace.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | if(i+k-1>=s.size()) break;
| ~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
860 KB |
Output is correct |
2 |
Correct |
6 ms |
776 KB |
Output is correct |
3 |
Correct |
17 ms |
936 KB |
Output is correct |
4 |
Incorrect |
65 ms |
1068 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
860 KB |
Output is correct |
2 |
Correct |
6 ms |
776 KB |
Output is correct |
3 |
Correct |
17 ms |
936 KB |
Output is correct |
4 |
Incorrect |
65 ms |
1068 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
16 ms |
860 KB |
Output is correct |
2 |
Correct |
6 ms |
776 KB |
Output is correct |
3 |
Correct |
17 ms |
936 KB |
Output is correct |
4 |
Incorrect |
65 ms |
1068 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |