QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#379792 | #8566. Can We Still Qualify For Semifinals? | ucup-team3215# | WA | 1ms | 3820kb | C++20 | 2.5kb | 2024-04-06 19:08:33 | 2024-04-06 19:08:33 |
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 == 0) {
++wold[x];
}
}
for (int a1 = 1; a1 < 10; ++a1) {
for (int a2 = a1 + 1; a2 < 10; ++a2) {
for (int a3 = a2 + 1; a3 < 10; ++a3) {
vi w(wold);
vi bst(10);
bst[a1] = 1;
bst[a2] = 1;
bst[a3] = 1;
for (int i = n; i < 45; ++i) {
auto [x, y] = mt[i];
if (x == 0) {
continue;
}
if (bst[x]) {
if (bst[y]) {
if (w[x] > w[y]) {
swap(x, y);
}
++w[x];
} else {
++w[x];
}
} else {
if (bst[y]) {
++w[y];
} else {
if (w[x] > w[y]) {
swap(x, y);
}
++w[x];
}
}
}
vi srt(w);
sort(all(srt), greater<>());
if (w[0] >= srt[4]) {
cout << "YES\n";
return;
}
}
}
}
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3768kb
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: 3804kb
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: 3820kb
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]