QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#764850 | #6617. Encoded Strings I | wzq | WA | 0ms | 3840kb | C++14 | 1.8kb | 2024-11-20 10:56:01 | 2024-11-20 10:56:08 |
Judging History
answer
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define int long long
typedef long long ll;
const int N = 1e5+10;
const int mod = 998244353;
void solve()
{
int n;
cin>>n;
string s;
cin>>s;
map<char,int>mp;
map<char,char>mmp;
int en = n;
for(int i = 0;i<n;i++)
{
if(mp[s[i]]==0)
{
mp[s[i]]=1;
}
else if(mp[s[i]]==1)
{
if(s[i]!=s[i-1])
{
en = i;
break;
}
}
}
int cnt = 0;
for(int i = en-1;i>=0;i--)
{
if(i==en-1)
{
mmp[s[i]] = 'a'+cnt;
cnt++;
continue;
}
if(s[i]!=s[i+1])
{
mmp[s[i]] = 'a'+cnt;
cnt++;
}
}
bool ok = 0;
string tmp = s.substr(0,en);
int op = en;
for(int i = en;i<n;i++)
{
if(ok&&s[i]!=tmp[0])break;
if(s[i]==tmp[0])
{
int j = i;
int cnt = 0;
while(j<n&&cnt<en&&s[j]==tmp[cnt])
{
j++;
cnt++;
}
if(cnt>=en)
{
ok = 1;
op+=en;
i = j-1;
}
else{
break;
}
}
}
for(int i = 0;i<op;i++)
{
cout<<mmp[s[i]];
}
return;
}
signed main(){
int _ = 1;
ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
//cin>>_;
while(_--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
input:
4 aacc
output:
bbaa
result:
ok single line: 'bbaa'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
3 aca
output:
ba
result:
ok single line: 'ba'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
1 t
output:
a
result:
ok single line: 'a'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3560kb
input:
12 bcabcabcbcbb
output:
cbacba
result:
ok single line: 'cbacba'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
1000 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb...
output:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...
result:
ok single line: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa...aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3840kb
input:
1000 ggkkkggggggkgggkgkgkkkkkggkkkgggkgkgggkkgkkgkgkgkgkgggkgkkkkgkgkkgkggkgggkgggkgkkgggggkkgkgkkkkgkkkkkkgkkggkkkkggkkkgkgggkggkkgkkgkgggkkggggkkggggkggkkggkgkgkgkkkgkkgkgkkgkkgkgkggkgggkgkkkgkkkgkkggkkggkkgkgkgkkkkkgkkggkgggkkkkgggkggkgggkkkgkkkkggggkkggkkkkgkkggkkkkkkgkgggkkkkkgggggggkgggkkkggkg...
output:
bbaaa
result:
wrong answer 1st lines differ - expected: 'bbaaabbbbbbabbbababaaaaabbaaab...bbbbabbabababaabbbbbababaababaa', found: 'bbaaa'