QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#826849#9079. Hamming DistanceabovecloudAC ✓3ms3824kbC++231.5kb2024-12-22 16:36:482024-12-22 16:36:48

Judging History

This is the latest submission verdict.

  • [2024-12-22 16:36:48]
  • Judged
  • Verdict: AC
  • Time: 3ms
  • Memory: 3824kb
  • [2024-12-22 16:36:48]
  • Submitted

answer

/*** WORK : 省赛\桂林ccpc\B.cpp ***/
/*** TIME : 2024/12/22 15:44 ***/
#include <bits/stdc++.h>
using namespace std;
#define int long long

#define all(v) v.begin(), v.end()
#define eb emplace_back
#define se second
#define fi first
#define endl '\n'

using vi = vector<int>;using vvi = vector<vi>;using vvvi = vector<vvi>;
using pii = pair<int,int>;using vpii = vector<pii>;using vvpii = vector<vpii>;
using mii = map<int,int>;using mpi = map<pii,int>;using si = set<int>;
istream& operator>>(istream& in,vi& a){for(int &x:a)in>>x;return in;}
ostream& operator<<(ostream& out,const vi& a){for(int x:a)out<<x<<" ";return out;}
const int INF = LLONG_MAX/4;const int MOD = (int)1e9 + 7;
const int MAXN = 2e5 + 5;

int cnt = 0;
void solve()
{
    string a,b;cin >> a >> b;
    int n = a.size();
    vi dp(n,0);
    for(int i=n-2;i>=0;i--){
        dp[i] = dp[i+1] + (a[i+1]!=b[i+1]);
    }
    int now = 0;
    cnt++;
    cout << "Case " << cnt << ": "; 

    for(int i=0;i<n;i++){
        for(char c = 'a';c <= 'z';c++){
            int t = 0;
            if(c == a[i])t++;
            if(c == b[i])t--;
            if(abs(now+t) <= dp[i]){
                cout <<c;
                now+=t;
                break;
            }
        }
    }
    cout << endl;
}

int32_t main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(12);
    int T = 1;
    cin >> T;
    while (T--)
        solve();
}

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

詳細信息

Test #1:

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

input:

2
abc
acd
abandon
newyork

output:

Case 1: aaa
Case 2: aaaaark

result:

ok 6 tokens

Test #2:

score: 0
Accepted
time: 1ms
memory: 3532kb

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

input:

1
aab
bba

output:

Case 1: abc

result:

ok 3 tokens

Test #4:

score: 0
Accepted
time: 1ms
memory: 3592kb

input:

1
aaaea
ccbdc

output:

Case 1: aabac

result:

ok 3 tokens

Test #5:

score: 0
Accepted
time: 3ms
memory: 3668kb

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