QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#837866#9079. Hamming Distance_mjjAC ✓3ms3736kbC++201.3kb2024-12-30 15:24:182024-12-30 15:24:20

Judging History

This is the latest submission verdict.

  • [2024-12-30 15:24:20]
  • Judged
  • Verdict: AC
  • Time: 3ms
  • Memory: 3736kb
  • [2024-12-30 15:24:18]
  • Submitted

answer

#include <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin() , v.end()
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#define int long long

using namespace std;

typedef long long LL;
typedef pair<int , int> PII;

const int N = 3e5 + 5;
const int mod = 998244353;
const int INF = 0x3f3f3f3f;

int suf[N];
string s , t;

int cal(char c , int pos){
    int a = 0;
    if(c == s[pos])a --;
    if(c == t[pos])a ++;
    return a;
}

void solve(int x){
    cout << "Case " << x << ": ";
    cin >> s >> t;
    int n = s.size();
    for(int i = n - 1 ; i >= 0 ; i --){
        if(s[i] != t[i])suf[i] = 1;
    }
    for(int i = n - 2 ; i >= 0 ; i --)suf[i] += suf[i + 1];
    suf[n] = 0;
    vector<char> q;
    int ss = 0;
    for(int i = 0 ; i < n ; i ++){
        for(int j = 0 ; j < 26 ; j ++){
            if(suf[i + 1] >= abs(ss + cal('a' + j , i))){
                q.push_back('a' + j);
                ss += cal('a' + j , i);
                break;
            }
        }
    }
    for(auto c : q)cout << c;
    cout << endl;
    for(int i = 0 ; i <= n ; i ++)suf[i] = 0;
}

signed main(){
    ios;
    int T = 1;
    cin >> T;
    int tot = T;
    while(T --){
        solve(tot - T);
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3588kb

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: 3640kb

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: 3736kb

input:

1
aab
bba

output:

Case 1: abc

result:

ok 3 tokens

Test #4:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

1
aaaea
ccbdc

output:

Case 1: aabac

result:

ok 3 tokens

Test #5:

score: 0
Accepted
time: 3ms
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