QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#302686 | #6624. String Problem | ucup-team1004 | WA | 1ms | 7984kb | C++14 | 917b | 2024-01-11 07:05:58 | 2024-01-11 07:05:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define all(a) (a).begin(),(a).end()
#ifdef DEBUG
template<class T>
ostream& operator << (ostream &out,vector<T> a){
out<<'[';
for(T x:a)out<<x<<',';
return out<<']';
}
template<class T>
vector<T> ary(T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<class T>
void debug(T x){
cerr<<x<<endl;
}
template<class T,class...S>
void debug(T x,S...y){
cerr<<x<<' ',debug(y...);
}
#else
#define debug(...) void()
#endif
const int N=1e6+10;
int n,a[N],ans[N];
char str[N];
int main(){
scanf("%s",str+1),n=strlen(str+1);
for(int i=1;i<=n;i++)a[i]='z'-str[i]+1;
for(int i=1;i<=n;){
int j=i,k=i+1;
for(;k<=n&&a[j]<=a[k];k++){
if(a[j]<a[k])j=i;
else j++;
ans[k]=i;
}
for(int len=k-j;i<=j;i+=len);
ans[k]=i;
}
ans[1]=1;
for(int i=1;i<=n;i++)printf("%d %d\n",ans[i],i);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5800kb
input:
potato
output:
1 1 1 2 3 3 3 4 3 5 5 6
result:
ok 12 tokens
Test #2:
score: 0
Accepted
time: 1ms
memory: 7984kb
input:
pbpbppb
output:
1 1 1 2 1 3 1 4 1 5 5 6 5 7
result:
ok 14 tokens
Test #3:
score: 0
Accepted
time: 1ms
memory: 5956kb
input:
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd...
output:
1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 40 1 41 1 42 1 43 1 44 1 45 1 46 1 47 1 48 1 49 1 50 1 51 1 52 1 53 1 54 1 55 1 56 1 57 1 58 1 59 1 60 1 61 1 62...
result:
ok 1990 tokens
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 7940kb
input:
gtgggtgttgggggtgtgggtgttggtttggggtggtgtgggttggtggggtgggttgttggttgggtttggggtgttgggggtgggttttggttgttggtggggttgttggtggtggggtgggttttgggttggtgggtgggtggttgtgttggttttttttgttgggtttgggtgttgttgtggtgggttttggttggggtgttggttggtgtggtgtgggttttggttttttgtttgtggtggtgttttgtttttggtggggtgtttgttgttttggggttggggtgggggttgtgg...
output:
1 1 2 2 2 3 2 4 2 5 2 6 6 7 6 8 8 9 8 10 8 11 8 12 8 13 8 14 8 15 8 16 8 17 8 18 8 19 8 20 8 21 8 22 8 23 23 24 23 25 23 26 23 27 27 28 27 29 27 30 27 31 27 32 27 33 27 34 27 35 27 36 27 37 27 38 27 39 27 40 27 41 27 42 27 43 27 44 27 45 27 46 27 47 27 48 27 49 27 50 27 51 27 52 27 53 27 54 27 55 27...
result:
wrong answer 13th words differ - expected: '2', found: '6'