QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#379194#8566. Can We Still Qualify For Semifinals?ucup-team027#WA 1027ms106364kbC++231.7kb2024-04-06 16:32:522024-04-06 16:32:52

Judging History

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

  • [2024-04-06 16:32:52]
  • 评测
  • 测评结果:WA
  • 用时:1027ms
  • 内存:106364kb
  • [2024-04-06 16:32:52]
  • 提交

answer

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template <typename T> using min_heap = priority_queue<T, vector<T>, greater<T>>;

vector<vector<int>> ranks;
vector<pair<int, int>> matches;

void init() {
	// ok rankings
	vector<int> rank(10);
	for (int i = 0; i < 10; i++) {
		rank[i] = i;
	}
	do {
		if (rank[0] < 4) ranks.push_back(rank);
	} while (next_permutation(rank.begin(), rank.end()));

	// matches order
	sort(rank.begin(), rank.end());
	for (int i = 0; i < 9; i++) {
		matches.emplace_back(rank[0], rank[9]);
		matches.emplace_back(rank[1], rank[8]);
		matches.emplace_back(rank[2], rank[7]);
		matches.emplace_back(rank[3], rank[6]);
		matches.emplace_back(rank[4], rank[5]);

		rotate(rank.begin()+1, rank.end()-1, rank.end());
	}
}

void solve() {
	int k; cin >> k;
	string s; cin >> s;

	for (auto rank: ranks) {
		vector<int> score(10);
		for (int i = 0; i < 45; i++) {
			auto [x, y] = matches[i];
			if (i < k) {
				if (s[i] == '1') score[x]++;
				else score[y]++;
			} else {
				if (x == 0 || y == 0) {
					score[0]++;
				} else {
					if (rank[x] < rank[y]) x++;
					else y++;
				}
			}
		}

		// is top 4?
		int top = 0;
		for (int i = 1; i < 10; i++) {
			if (score[i] > score[0]) top++;
		}
		if (top > 3) continue;
		else {
			cout << "YES\n";
			return;
		}
	}
	cout << "NO\n";
}

signed main() {
	ios::sync_with_stdio(0); cin.tie(0);
	init();
	
	int t; cin >> t;
	while (t--) {
		solve();
	}
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 154ms
memory: 106364kb

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: 60ms
memory: 105800kb

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: 1027ms
memory: 106176kb

input:

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

output:

NO
NO
NO
NO
YES
NO
NO
NO
NO
NO

result:

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