QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#317261#7618. Pattern Searchkaruna#WA 0ms3636kbC++201.0kb2024-01-28 18:49:522024-01-28 18:49:52

Judging History

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

  • [2024-01-28 18:49:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-01-28 18:49:52]
  • 提交

answer

#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0); ios_base::sync_with_stdio(0);
	int t;
	cin >> t;

	while (t--) {
		string S, T;
		cin >> S >> T;

		vector<int> cnt(26);
		for (char c : S) cnt[c - 'a']++;

		bool flag = true;
		for (char c : T) {
			if (cnt[c - 'a'] == 0) {
				flag = false;
				break;
			}
			cnt[c - 'a']--;
		}

		if (!flag) {
			cout << 0 << '\n';
		}
		else {
			vector<int> d(26);
			for (char c : T) d[c - 'a']++;

			int mn = 1e9;
			for (int x : d) if (x) mn = min(mn, x);

			int ans = 1;
			for (int k = 1; k <= mn; k++) {
				bool flag = true;
				for (int x : d) if (x) {
					if (x / k < x % k) flag = false;
				}
				if (!flag) continue;

				int s = 1e9;
				for (int i = 0; i < 26; i++) if (d[i]) {
					s = min(s, cnt[i] / (d[i] / k));
				}
				ans = max(ans, s + 1);
			}
			cout << ans << '\n';
		}
	}
}

詳細信息

Test #1:

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

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

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'