QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226053 | #7618. Pattern Search | ucup-team1001# | WA | 0ms | 3868kb | C++20 | 1.7kb | 2023-10-25 15:09:00 | 2023-10-25 15:09:01 |
Judging History
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: 3564kb
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: 3868kb
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'