Submission #928754

#TimeUsernameProblemLanguageResultExecution timeMemory
928754Faisal_SaqibNecklace (Subtask 1-3) (BOI19_necklace1)C++17
0 / 85
589 ms109636 KiB
#include <algorithm> #include <iostream> #include <map> #include <queue> using namespace std; int main() { string a,b; cin>>a>>b; map<deque<char>,int> fpp; int n=a.size(); for(int i=0;i<n;i++) { deque<char> tp; for(int j=i;j<n;j++) { tp.push_back(a[j]); deque<char> lp=tp; deque<char> lp1=tp; reverse(begin(lp1),end(lp1)); for(int l=0;l<(j-i+1);l++) { fpp[lp]=1; fpp[lp1]=1; char f=lp.front(); lp.pop_front(); lp.push_back(f); f=lp1.front(); lp1.pop_front(); lp1.push_back(f); } } } int m=b.size(); int mx=0; int ip=-1; int jp=-1; for(int i=0;i<m;i++) { deque<char> tp; for(int j=i;j<m;j++) { tp.push_back(b[j]); if(fpp.find(tp)!=fpp.end()) { if((int)(tp.size())>mx) { mx=(int)(tp.size()); ip=fpp[tp]; jp=i; } } } } cout<<mx<<endl; cout<<ip<<' '<<jp<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...