QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#429376 | #8566. Can We Still Qualify For Semifinals? | ucup-team2526# | TL | 9ms | 3864kb | C++20 | 1.6kb | 2024-06-02 13:50:36 | 2024-06-02 13:50:37 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
#define dbg(x...) \
do { \
cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
cout << endl;
}
template<class T, class... Ts>
void err(T arg, Ts ... args) {
cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
void solve(){
int k;cin >> k;
string s;cin >> s;
if (k <= 20) {
cout << "YES" << '\n';
return ;
}
vector<int>g(11,0);
deque<int>q;
for (int i = 1;i <= 10;i++) q.push_back(i);
for (int i = 1;i <= k;i++) {
int now = (i - 1) % 5 + 1;
now--;
//dbg(now);
if (s[i - 1] == '0') {
g[q[10 - now - 1]]++;
}
else {
g[q[now]]++;
}
if (i % 5 == 0) {
q.pop_front();
q.push_front(q.back());
q.pop_back();
q.push_front(1);
}
}
int sy = 45 - k;
int cnt = k;
for (int i = 0;i < (1ll << sy);i++) {
cnt = k;
vector<int>v(11,0);
for (int j = sy - 1;j >= 0;j--) {
cnt++;
int now = (cnt - 1) % 5 + 1;
now--;
if ((i >> j) & 1) {
v[q[now]]++;
}
else v[q[10 - now - 1]]++;
if (cnt == 5) {
q.pop_front();
q.push_front(q.back());
q.pop_back();
q.push_front(1);
}
}
vector<pair<int,int>>b(11);
int res = g[1] + v[1];
for (int j = 1;j <= 10;j++) {
b[j].first = g[j] + v[j];
b[j].second = j;
}
sort(b.begin() + 1,b.begin() + 11);
if (res >= b[7].first) {
cout << "YES" << '\n';
return ;
}
}
cout << "NO" << '\n';
return ;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
int t=1;cin>>t;
while(t--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3864kb
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: 3816kb
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: 0
Accepted
time: 9ms
memory: 3604kb
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 NO NO NO NO
result:
ok 10 token(s): yes count is 0, no count is 10
Test #4:
score: -100
Time Limit Exceeded
input:
10 23 01100000010101000111010 38 01111001100011000101011110101001101001 27 010000000001001001110001001 26 01101001110011101101000110 8 00001000 22 0110100110001110110001 9 000100010 24 000000100101101010100100 6 011000 29 01101010100101000000000000100