QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#808819 | #9079. Hamming Distance | rotcar07 | AC ✓ | 1ms | 3856kb | C++23 | 559b | 2024-12-11 07:12:06 | 2024-12-11 07:12:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
inline string solve(){
string a,b,res="";cin>>a>>b;
int n=a.length();
int cnt=0,tot=0;
for(int i=0;i<n;i++) tot+=(a[i]!=b[i]);
for(int i=0;i<n;i++){
tot-=a[i]!=b[i];
char c='a';
while(1){
int w=cnt;
if(a[i]==c) w++;
if(b[i]==c) w--;
if(abs(w)<=tot){res+=c,cnt=w;break;}
c++;
}
}
return res;
}
int main(){
std::ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int T;cin>>T;
for(int _=1;_<=T;_++) cout<<"Case "<<_<<": "<<solve()<<'\n';
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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: 3592kb
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: 1ms
memory: 3500kb
input:
1 aab bba
output:
Case 1: abc
result:
ok 3 tokens
Test #4:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
1 aaaea ccbdc
output:
Case 1: aabac
result:
ok 3 tokens
Test #5:
score: 0
Accepted
time: 0ms
memory: 3732kb
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