QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#819742 | #2840. 绿绿与串串 | Mirasycle | WA | 107ms | 31384kb | C++14 | 1.1kb | 2024-12-18 17:19:13 | 2024-12-18 17:19:18 |
Judging History
answer
#include<bits/stdc++.h>
#define pb emplace_back
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
const int maxn=2e6+10;
void chkmax(int &x,int y){ x=x>y?x:y; }
void chkmin(int &x,int y){ x=x<y?x:y; }
char s[maxn]; int n,m=0; vector<int> ans;
int r[maxn],vis[maxn],len[maxn]; char t[maxn];
void solve(){
cin>>(s+1); n=strlen(s+1); ans.clear();
if(n==1){ cout<<1<<endl; return ; }
t[m=0]='#'; t[++m]='@';
for(int i=1;i<=n;i++) t[++m]=s[i],t[++m]='@'; t[++m]='!';
for(int i=1,R=0,c=0;i<m;i++){
r[i]=i>R?1:min(r[2*c-i],R-i+1);
while(t[i-r[i]]==t[i+r[i]]&&r[i]<m) r[i]++;
if(i+r[i]-1>R) R=i+r[i]-1,c=i;
}
for(int i=1;i<=n;i++){ vis[i]=0; len[i]=r[i<<1]/2; }
vis[n+1]=1;
for(int i=n;i>=2;i--){
if(i+len[i]-1==n) ans.pb(i),vis[i]=1;
else if(i==len[i]&&vis[i+len[i]-1]) ans.pb(i);
}
reverse(ans.begin(),ans.end());
for(auto v:ans) cout<<v<<" "; cout<<endl;
}
int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int T; cin>>T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 11836kb
input:
7 abcdcb qwqwq qaqaqqq carnation c ab aa
output:
4 6 2 3 4 5 6 7 9 1 2 2
result:
ok 7 lines
Test #2:
score: -100
Wrong Answer
time: 107ms
memory: 31384kb
input:
5 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc...
output:
250001 250002 250003 250004 250005 250006 250007 250008 250009 250010 250011 250012 250013 250014 250015 250016 250017 250018 250019 250020 250021 250022 250023 250024 250025 250026 250027 250028 250029 250030 250031 250032 250033 250034 250035 250036 250037 250038 250039 250040 250041 250042 250043...
result:
wrong answer 1st lines differ - expected: '2 3 4 5 6 7 8 9 10 11 12 13 14...96 999997 999998 999999 1000000', found: '250001 250002 250003 250004 25...6 999997 999998 999999 1000000 '