QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#388127#8566. Can We Still Qualify For Semifinals?BUET_POTATOES#WA 0ms3812kbC++202.2kb2024-04-13 12:39:462024-04-13 12:39:46

Judging History

你现在查看的是最新测评结果

  • [2024-04-13 12:39:46]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3812kb
  • [2024-04-13 12:39:46]
  • 提交

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<int>ordar(n);
    int cur = 0;
    for(auto [fau1,fau2, idx] : shob){
        ordar[idx] = ++cur;
    }

    for(int i=k; i<matches.size(); i++){
        if(matches[i].first!=0){
            auto [u,v] = matches[i];
            if(ordar[u]<ordar[v]) wins[u]++;
            else wins[v]++;
        }
    }
    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);
    }
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

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
Wrong Answer
time: 0ms
memory: 3688kb

input:

10
16
0110000001010100
17
01111000110110101
15
001100010101111
16
0010101010011100
19
0000000100010110100
16
0011101010011100
18
011110010001100000
18
000110101001100011
20
01100010000100100100
15
001000111001101

output:

NO
YES
YES
YES
YES
YES
YES
NO
NO
YES

result:

wrong answer expected YES, found NO [1st token]