QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#378592 | #8566. Can We Still Qualify For Semifinals? | ucup-team1516# | TL | 1ms | 3572kb | C++17 | 2.0kb | 2024-04-06 13:42:35 | 2024-04-06 13:42:35 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
vector<pair<int, int>> v;
{
vector<int> p(10);
iota(p.begin(), p.end(), 0);
for (int i = 0; i < 9; ++i) {
for (int j = 0; j < 5; ++j) {
v.push_back({p[j], p[9 - j]});
}
vector<int> np = {p[0], p.back()};
for (int j = 1; j < 9; ++j) {
np.push_back(p[j]);
}
swap(p, np);
}
}
int q;
cin >> q;
while (q--) {
int n;
cin >> n;
string s;
cin >> s;
if (n <= 15) {
cout << "YES\n";
continue;
}
vector<int> win(10);
for (int i = 0; i < n; ++i) {
if (s[i] == '1') {
win[v[i].first] += 1;
} else {
win[v[i].second] += 1;
}
}
auto cp = win;
vector<pair<int, int>> u;
for (int i = n; i < v.size(); ++i) {
if (v[i].first == 0) {
win[0] += 1;
} else {
u.push_back(v[i]);
}
}
int m = u.size();
bool ok = false;
for (int i = 0; i < (1 << m); ++i) {
win = cp;
for (int j = 0; j < m; ++j) {
if ((1 << j) & i) win[u[j].first] += 1;
else win[v[j].second] += 1;
}
int cnt = 0;
for (int j = 1; j < 10; ++j) {
cnt += (win[0] < win[j]);
}
if (cnt <= 3) {
ok = true;
break;
}
}
if (ok) cout << "YES\n";
else cout << "NO\n";
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3572kb
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: -100
Time Limit Exceeded
input:
10 16 0110000001010100 17 01111000110110101 15 001100010101111 16 0010101010011100 19 0000000100010110100 16 0011101010011100 18 011110010001100000 18 000110101001100011 20 01100010000100100100 15 001000111001101