Submission #366061

#TimeUsernameProblemLanguageResultExecution timeMemory
366061GusMGNecklace (Subtask 4) (BOI19_necklace4)C++17
0 / 15
1558 ms364 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=(a);i<(b);i++) #define per(i,a,b) for(int i=(b)-1;i>=(a);i--) using ll=long long; int main(){ ios_base::sync_with_stdio(0); string s,t; cin>>s>>t; int n=s.size(),m=t.size(),ans=0,l=0,r=0; rep(i,0,n) rep(j,i,n) rep(k,j,n) { string aux=s.substr(j,k-j)+s.substr(i,j-i); int pos=t.find(aux); if(pos!=string::npos && aux.size()>ans) ans=aux.size(),l=i,r=pos; } reverse(s.begin(),s.end()); rep(i,0,n) rep(j,i,n) rep(k,j,n) { string aux=s.substr(j,k-j)+s.substr(i,j-i); int pos=t.find(aux); if(pos!=string::npos && aux.size()>ans) ans=aux.size(),l=n-k,r=pos; } cout<<ans<<"\n"; cout<<l<<" "<<r<<"\n"; }

Compilation message (stderr)

necklace.cpp: In function 'int main()':
necklace.cpp:14:15: warning: comparison of integer expressions of different signedness: 'int' and 'const size_type' {aka 'const long unsigned int'} [-Wsign-compare]
   14 |         if(pos!=string::npos && aux.size()>ans) ans=aux.size(),l=i,r=pos;
      |            ~~~^~~~~~~~~~~~~~
necklace.cpp:14:43: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   14 |         if(pos!=string::npos && aux.size()>ans) ans=aux.size(),l=i,r=pos;
      |                                 ~~~~~~~~~~^~~~
necklace.cpp:20:15: warning: comparison of integer expressions of different signedness: 'int' and 'const size_type' {aka 'const long unsigned int'} [-Wsign-compare]
   20 |         if(pos!=string::npos && aux.size()>ans) ans=aux.size(),l=n-k,r=pos;
      |            ~~~^~~~~~~~~~~~~~
necklace.cpp:20:43: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |         if(pos!=string::npos && aux.size()>ans) ans=aux.size(),l=n-k,r=pos;
      |                                 ~~~~~~~~~~^~~~
necklace.cpp:10:20: warning: unused variable 'm' [-Wunused-variable]
   10 |     int n=s.size(),m=t.size(),ans=0,l=0,r=0;
      |                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...