QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#388130 | #8566. Can We Still Qualify For Semifinals? | BUET_POTATOES# | WA | 0ms | 3888kb | C++20 | 2.6kb | 2024-04-13 12:47:04 | 2024-04-13 12:47:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
vector<pii>matches;
void testcase(int cs){
int k;
cin>>k;
string s;
cin>>s;
// for(auto [u,v] : matches){
// cout<<u<<" - "<<v<<endl;
// }
int n = 10;
vector<int>wins(10);
vector<int>rem(10, 9);
for(int i=0; i<k; i++){
if(s[i]=='1'){
wins[ matches[i].first ]++;
}
else{
wins[ matches[i].second ]++;
}
rem[ matches[i].first ]--;
rem[ matches[i].second ]--;
}
for(int i=k; i<matches.size(); i++){
if(matches[i].first==0){
wins[0]++;
rem[ matches[i].first ]--;
rem[ matches[i].second ]--;
}
}
vector<tuple<int,int,int>>shob(n-1);
for(int i=1; i<n; i++) shob.emplace_back(wins[i], rem[i], i);
sort(shob.rbegin(), shob.rend(), [&](auto bam, auto dan){
auto [w1, rem1, i] = bam;
auto [w2, rem2, j] = dan;
if(w1==w2) return rem1<rem2;
return w1<w2;
} );
vector<bool>winer(n);
for(int i=0; i<3; i++){
auto [w1, rem1, idx] = shob[i];
winer[idx] = true;
}
for(int i=k; i<matches.size(); i++){
if(matches[i].first!=0){
auto [u,v] = matches[i];
if(winer[u]) wins[u]++;
else if(winer[v]) wins[v]++;
else{
if(wins[u]!=wins[v]){
if(wins[u]<wins[v]) swap(u,v);
wins[v]++;
}
else{
if(rem[u]<rem[v]) swap(u,v);
wins[v]++;
}
}
rem[ matches[i].first ]--;
rem[ matches[i].second ]--;
}
}
int bigar = 0;
for(int i=1; i<n; i++) if(wins[i]>wins[0]) bigar++;
if(bigar>=4) cout<<"NO\n";
else cout<<"YES\n";
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
vector<int>teams;
for(int i=1; i<=10; i++) teams.push_back(i-1);
for(int i=1; i<=9; i++){
for(int j=0, k=teams.size()-1; j<k; j++, k--){
matches.emplace_back(teams[j], teams[k]);
}
deque<int>tmp;
for(int j=1; j<teams.size(); j++) tmp.push_back(teams[j]);
int x = tmp.back();
tmp.pop_back();
tmp.push_front(x);
for(int j=1, i=0; j<teams.size(); j++, i++) teams[j] = tmp[i];
}
int T = 1;
cin >> T;
for(int cs = 1; cs <= T; ++cs){
testcase(cs);
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3888kb
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: 3592kb
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: 0ms
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 NO NO NO NO NO NO
result:
ok 10 token(s): yes count is 0, no count is 10
Test #4:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
10 23 01100000010101000111010 38 01111001100011000101011110101001101001 27 010000000001001001110001001 26 01101001110011101101000110 8 00001000 22 0110100110001110110001 9 000100010 24 000000100101101010100100 6 011000 29 01101010100101000000000000100
output:
YES NO NO NO YES YES YES YES YES NO
result:
ok 10 token(s): yes count is 6, no count is 4
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3560kb
input:
10 30 011000000101010001110100101110 29 01001010010011101110010110010 28 0110000000001000101101001001 23 01101001110011101101000 23 01000001000111001011000 24 011110001000010001010000 23 01001011010101001000011 30 000110011001010010000000000010 24 000110111001110011000011 28 000110001000011011110110...
output:
NO NO NO YES YES NO YES NO YES NO
result:
wrong answer expected YES, found NO [6th token]