QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#379885 | #8566. Can We Still Qualify For Semifinals? | ucup-team3215# | WA | 177ms | 3736kb | C++20 | 1.6kb | 2024-04-06 19:42:03 | 2024-04-06 19:42:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
using pii = array<int, 2>;
using vi = vector<int>;
array<pii, 45> mt;
void solve() {
int n;
string s;
cin >> n >> s;
vi wold(10);
for (int i = 0; i < n; ++i) {
int b = s[i] - '0';
++wold[mt[i][b ^ 1]];
}
for (int i = n; i < 45; ++i) {
auto [x, y] = mt[i];
if (!x)++wold[x];
if (!y)++wold[y];
}
vector<int> p(9);
iota(p.begin(), p.end(), 0);
do {
auto w = wold;
for (int i = n; i < 45; ++i) {
auto [x, y] = mt[i];
if (!x || !y)continue;
if (p[x - 1] < p[y - 1]) {
w[x]++;
w[y]++;
}
}
int val = w[0];
sort(w.rbegin(), w.rend());
if (val >= w[3]) {
cout << "YES\n";
return;
}
} while (next_permutation(p.begin(), p.end()));
cout << "NO\n";
}
int main() {
vi p(10);
iota(all(p), 0);
for (int i = 0; i < 9; ++i) {
for (int j = 0; j < 5; ++j) {
mt[i * 5 + j] = {p[j], p[9 - j]};
}
vi pn(p);
pn[1] = p.back();
for (int j = 2; j < 10; ++j) {
pn[j] = p[j - 1];
}
p = pn;
}
// for (int i = 0; i < 45; ++i) {
// if (i % 5 == 0) {
// cout << endl;
// }
// cout << mt[i][0] + 1 << ' ' << mt[i][1] + 1 << endl;
// }
int t;
cin >> t;
while (t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 17ms
memory: 3736kb
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: 3604kb
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: 177ms
memory: 3512kb
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]