QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#380403#8566. Can We Still Qualify For Semifinals?ucup-team1766#WA 1ms3600kbC++231.4kb2024-04-07 03:01:162024-04-07 03:01:17

Judging History

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

  • [2024-04-07 03:01:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-04-07 03:01:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int k, a, b, c;
string s;
int lim;

bool can() {
	vector<int> wins(10);
	vector<int> teams(10); iota(teams.begin(),teams.end(),0);
	for (int _ = 0; _ < 9; _++) {
		for (int i = 0; i < 5; i++) {
			int x = teams[i];
			int y = teams[9-i];

			if (_*5+i < k) {
				if (s[_*5+i] == '1') wins[x]++;
				else wins[y]++;
			} else {
				if (not x or not y) wins[0]++;
				else if (x == a or x == b or x == c) wins[x]++;
				else if (y == a or y == b or y == c) wins[y]++;
				else if (wins[x] < wins[y]) {
					wins[x]++;
					if (wins[x] > lim) return 0;
				} else {
					wins[y]++;
					if (wins[y] > lim) return 0;
				}
			}
		}
		rotate(teams.begin()+1,teams.begin()+2,teams.end());
	}
	return 1;
}

void run() {
	cin >> k;
	cin >> s;

	lim = 0;
	{
		vector<int> teams(10); iota(teams.begin(),teams.end(),0);
		for (int _ = 0; _ < 9; _++) {
			for (int i = 0; i < 5; i++) {
				int x = teams[i];
				int y = teams[9-i];

				if (_*5+i < k) {
					if (s[_*5+i] == '1') {
						if (!x) lim++;
					} else {
						if (!y) lim++;
					}
				} else {
					if (not x or not y) lim++;
				}
			}
			rotate(teams.begin()+1,teams.begin()+2,teams.end());
		}
	}

	for (a = 1; a < 10; a++) {
	for (b = 1; b < 10; b++) {
	for (c = 1; c < 10; c++) {
		if (can()) {
			cout << "YES\n";
			return;
		}
	}
	}
	}
	cout << "NO\n";
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int t; cin >> t; while (t--) run();
}

詳細信息

Test #1:

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

input:

3
3
111
25
1000010101111111111010100
35
01111011110111101111011110111101111

output:

YES
YES
NO

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

10
16
0110000001010100
17
01111000110110101
15
001100010101111
16
0010101010011100
19
0000000100010110100
16
0011101010011100
18
011110010001100000
18
000110101001100011
20
01100010000100100100
15
001000111001101

output:

YES
YES
YES
YES
YES
YES
YES
YES
YES
YES

result:

ok 10 token(s): yes count is 10, no count is 0

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 3592kb

input:

10
37
0110000001010100011101001011100110001
39
000100111101101001100101101000000000100
35
00111000100111100101011010111100100
33
010000010001110010110001101110001
30
000100010100000010010110101010
31
0000101000011010101001010000000
44
00001000000111101011010110000101100011000100
42
01111011110001001...

output:

NO
NO
NO
NO
NO
NO
YES
YES
NO
NO

result:

wrong answer expected NO, found YES [7th token]