QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302318#7618. Pattern Searchdefyers#WA 1ms3488kbC++20812b2024-01-10 19:11:342024-01-10 19:11:35

Judging History

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

  • [2024-01-10 19:11:35]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3488kb
  • [2024-01-10 19:11:34]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

using ll = long long;
using pii = pair<int, int>;

int c_s[26], c_t[26];
void solve(int TC) {
	string s, t; cin >> s >> t;
	for(int i = 0; i < 26; i++) c_s[i] = c_t[i] = 0;
	for(auto c : s) c_s[c - 'a']++;
	for(auto c : t) c_t[c - 'a']++;

	int mx = 1 << 30, cnt = 0;
	for(int i = 0; i < 26; i++){
		if(c_t[i]) mx = min(mx, c_s[i] / c_t[i]), cnt++;
	}
	if(cnt == 1){
		int x = -1; for(int i = 0; i < 26; i++) if(c_t[i]) x = i;
		cout << max(0, c_s[x] - c_t[x] + 1) << '\n';
	}else{
		cout << mx << '\n';
	}
}

int32_t main() {
	cin.tie(0)->sync_with_stdio(0);
	cout << fixed << setprecision(10);

	int t = 1;
	cin >> t;
	for (int i = 1; i <= t; i++) {
		solve(i);
	}
}

詳細信息

Test #1:

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

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

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'