QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#601058 | #7406. Longest Lyndon Prefix | rotcar07 | WA | 0ms | 3596kb | C++20 | 492b | 2024-09-29 20:44:08 | 2024-09-29 20:44:10 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=1e5+5;
int w[maxn];
int main(){
int t;cin>>t;
while(t--){
int n;cin>>n;
string s;cin>>s;
s=' '+s;
w[n]=1;
for(int i=n-1;i>=1;i--){
if(s[i]<s[i+1]) w[i]=w[i+1]+1;
else if(s[i]>s[i+1]) w[i]=1;
else if(w[i+1]==1) w[i]=1;
else w[i]=w[i+1]+1;
}
for(int i=1;i<=n;i++) cout<<w[i]<<' ';cout<<'\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3596kb
input:
3 3 aaa 3 aab 3 cba
output:
1 1 1 3 2 1 1 1 1
result:
ok 9 numbers
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3572kb
input:
10000 10 ababbbbaaa 6 aabbaa 3 abb 9 bababbbbb 9 abbaaaaaa 8 ababbaab 7 abbbbbb 7 aaabaaa 2 ba 10 abaababbab 2 ab 1 a 1 a 5 ababa 6 aaabba 2 ba 4 abba 5 bbbba 9 aabbbbbaa 10 baaabaaaba 10 babbbbbbaa 9 babaaabba 1 b 6 abbbaa 7 aaaaaab 10 baaaaabaaa 9 bbbbabbba 3 bbb 8 abaababa 7 bbbbaba 5 ababb 1 b 7...
output:
2 1 2 1 1 1 1 1 1 1 3 2 1 1 1 1 2 1 1 1 2 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 3 2 1 2 1 1 1 1 1 1 4 3 2 1 1 1 1 1 1 2 1 3 2 1 2 1 1 2 1 2 1 1 1 2 1 2 1 1 4 3 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 3 2 1 1 1 1 1 1 1 1 4 3 2 1 4 3 2 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 4 3 2 1 1 1 1 2 1 1...
result:
wrong answer 1st numbers differ - expected: '7', found: '2'