QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226051#7618. Pattern SearchhazeWA 0ms3464kbC++201.7kb2023-10-25 15:08:222023-10-25 15:08:23

Judging History

你现在查看的是最新测评结果

  • [2023-10-25 15:08:23]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3464kb
  • [2023-10-25 15:08:22]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


using ll = long long;
#define int ll
#define endl "\n"


#define pii pair<int,int>
#define ary(i) array<ll,(i)>
#define all(x) x.begin(),x.end()
const int maxn = 2e5 + 7;
const int inf = numeric_limits<int>::max();
const int inf2 = 0x3f3f3f3f3f3f3f3;
const int inff = numeric_limits<int>::min();
const int mod = 1e9 + 7;


void solve() {
    string a, b;
    cin >> a >> b;
    vector<int> an(26, 0);
    vector<int> bn(26, 0);
    vector<int> cn(26, 0);
    for (auto i: a) {
        an[i - 'a']++;
    }
    for (auto i: b) {
        bn[i - 'a']++;
    }
    int maxa= inff;
    for (int i = 0; i < 26; i++) {
        if (bn[i] > an[i]) {
            cout << 0 << endl;
            return;
        }
        maxa = max(maxa,bn[i]);
        cn[i] = bn[i];
    }
    bool flag = true;
    for (int i = 0; i < 26; i++){
        if(bn[i]){
            if(bn[i]!=maxa)flag= false;
        }

    }
    if(flag){
        int maxa= inf;
        for (int i = 0; i < 26; i++){
            if(bn[i]){
                maxa =max({0ll,min(maxa, an[i] - bn[i] + 1)});
            }
        }
        cout<<maxa<<endl;
        return;

    }

    int len = 1;
    while (1){
        for (int i = 0; i < 26; i++) {
            if ((bn[i]/2+bn[i]%2)+cn[i] > an[i]) {
                cout << len << endl;
                return;
            }
            cn[i] += (bn[i]/2+bn[i]%2);
        }
        len++;
    }
//    cout<<len<<endl;


}

#undef int


int main() {
    IOS
    int n;
    cin >> n;
//    n = 1;
    while (n--) {
        solve();
    }

}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3460kb

input:

2
bajkaaall aal
abca cba

output:

2
1

result:

ok 2 number(s): "2 1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3464kb

input:

16
a a
a b
b a
aa a
ab aa
ab b
ab c
aaz az
abcde edcba
aaaaaaaaaaaabbb aaaaaaaaabb
aaaaaazz az
aaaaaaaaaz zzzzz
gggggggggggggggggggge ggggeeee
hyphyphyphyphyphyphyphyphyphyphyphyp eeeeeeeeee
hyphyphyphyphyphyphyphyphyphyphyphype eeteeteeteet
aaaabbbbbbcccccccc aaabbbbbcccccc

output:

1
0
0
2
0
1
0
1
1
1
2
0
0
0
0
1

result:

wrong answer 10th numbers differ - expected: '2', found: '1'