QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#803069 | #9079. Hamming Distance | pengpeng_fudan# | AC ✓ | 1ms | 3660kb | C++23 | 894b | 2024-12-07 15:49:27 | 2024-12-07 15:49:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve(int T){
string a,b;
cin>>a>>b;
int sz=a.size();
string ans(sz,'a');
vector<int> ed(sz+1);
for(int i=sz-1;i>=0;i--){
if(a[i]!=b[i]) ed[i]=ed[i+1]+1;
else ed[i]=ed[i+1];
}
pair<int,int> sum={0,0};
for(int i=0;i<sz;i++){
for(int j=0;j<26;j++){
pair<int,int> psum=sum;
char c=(char)(j+'a');
if(a[i]==c) psum.first++;
if(b[i]==c) psum.second++;
if(abs(psum.first-psum.second)<=ed[i+1]){
ans[i]=c;
sum=psum;
break;
}
}
}
cout<<"Case "<<T<<": "<<ans<<'\n';
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0);
int _ = 1;
cin >> _;
int tot=0;
while (_--) solve(++tot);
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
2 abc acd abandon newyork
output:
Case 1: aaa Case 2: aaaaark
result:
ok 6 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
3 abcbacjasiodjadosasadasdada abcbacjasiodjadosasadasdada aba abb bbbbbbaaaaa aaaaaabbbbb
output:
Case 1: aaaaaaaaaaaaaaaaaaaaaaaaaaa Case 2: aac Case 3: aaaaabaaaac
result:
ok 9 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
1 aab bba
output:
Case 1: abc
result:
ok 3 tokens
Test #4:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
1 aaaea ccbdc
output:
Case 1: aabac
result:
ok 3 tokens
Test #5:
score: 0
Accepted
time: 1ms
memory: 3660kb
input:
100 y m tbqyaxbi pqdqdayk vdgccwsfo wjgrckffn hhka bwqz zcleuatejof txpvaqmidwg wbbl fcuj rfgjo wfluk ivimfoedco lstisjtzfv bhllf puyfh swuyfbufmz swuyfbufmz wvocvzngafbvnkfkbrcut ldoxqnikmdtodzzzzmchs lsfjwmjhszqiqhmwcrsaftrzvebgwhydynoiotqhqkrqhgxxuf crvapaebmmxljfiiuoiiomnxhwwxgpulltbdwflgxgpezgc...
output:
Case 1: a Case 2: aaaaaaaa Case 3: aaaaaaaaa Case 4: aaab Case 5: aaaaaaaaaaa Case 6: aaaa Case 7: aaaaa Case 8: aaaaaaaaaa Case 9: aaaaa Case 10: aaaaaaaaaa Case 11: aaaaaaaaaaaaaaaaaaaas Case 12: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaua Case 13: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaxj ...
result:
ok 300 tokens
Extra Test:
score: 0
Extra Test Passed