# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1097382 | 2024-10-07T06:36:52 Z | simona1230 | Necklace (Subtask 1-3) (BOI19_necklace1) | C++17 | 23 ms | 2640 KB |
// Online C++ compiler to run C++ program online #include <bits/stdc++.h> using namespace std; string s1,s2; void read() { cin>>s1>>s2; s2+=s2; } int z[200001]; void solve() { int ans=0,bg1=0,bg2=0; int n=s1.size(); for(int i=0;i<s1.size();i++) { for(int j=i;j<s1.size();j++) { string s=""; for(int k=i;k<=j;k++) s+=s1[k]; cout<<s<<" "<<s2<<endl; s+=s2; int l=0,r=0; int maxx=0,idx=0; int m=s.size(); for(int k=1;k<m;k++) { z[k]=0; if(i<r) { z[k]=min(r-k,z[k-l]); } while(k+z[k]<m&&s[z[k]]==s[z[k]+1]) z[k]++; if(k+z[k]>r) { r=k+z[k]; l=k; } if(k>=(j-i+1)&&z[k]+1>maxx&&s[0]==s[k]) { maxx=z[k]+1; idx=k; } } maxx=min(maxx,(j-i+1)); if(maxx>ans) { cout<<"in "<<maxx<<endl; ans=maxx; bg1=i; bg2=idx-(j-i+1); } } } cout<<ans<<endl<<bg1<<" "<<bg2<<endl; } int main() { read(); solve(); reverse(s1.begin(),s1.end()); solve(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 2640 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 2640 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 2640 KB | Expected integer, but "a" found |
2 | Halted | 0 ms | 0 KB | - |