QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#184502#5140. Frozen Scoreboardx_jwWA 2ms3600kbC++144.7kb2023-09-20 20:10:522023-09-20 20:10:52

Judging History

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

  • [2023-09-20 20:10:52]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3600kb
  • [2023-09-20 20:10:52]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;
int m;
void solve(){
    int sumT,sumF,flag=0;
    cin>>sumT>>sumF;
    vector<pair<int,int>> add,ans(m+1);
    vector<pair<int,int>> ques;char op[20];int pass[20];
    for(int i=1;i<=m;i++){
        cin>>op[i];
        if(op[i]=='+'){
            string s;cin>>s;
            string a,b;int f=0;
            for(auto v:s){
                if(v=='/'){
                    f=1;
                    continue;
                }
                if(!f){
                    a+=v;
                }
                else b+=v;
            }
            add.push_back({stoi(a),stoi(b)});
        }
        else if(op[i]=='?'){
            int a,b;
            cin>>a>>b;a=b-a;
            ques.push_back({a,b});
        }
        else if(op[i]=='-') {
            cin>>pass[i];
        }
    }
//----------读入----------------------------------

    for(auto v:add){
        sumT--;
        sumF-=v.second+(v.first-1)*20;
    }
    if(sumT==0&&sumF==0){int ca=0,cq=0;cout<<"Yes\n";
        for(int j=1;j<=m;j++){
            if(op[j]=='+'){
                cout<<op[j]<<" ";
                cout<<add[ca].first<<"/"<<add[ca].second<<"\n";ca++;
            }
            else if(op[j]=='-'){
                cout<<"- "<<pass[j]<<"\n";
            }
            else if(op[j]=='?'){
                if(ans[cq].first==-1){
                    cout<<"- "<<ans[cq].second<<"\n";cq++;
                }
                else{
                    cout<<"+ ";
                    cout<<ans[cq].first<<"/"<<ans[cq].second<<"\n";cq++;
                }
            }
            else cout<<op[j]<<"\n";
        }return;
    }
    if(sumT<0||sumF<0){
        cout<<"No\n";return;
    }
    //cout<<sumT<<" "<<sumF<<"==\n";
    int n=ques.size();//ans的编号是和ques一样的
    for(int i=0;i<1<<n;i++){
        int cnt=0;//该枚举过的题数
        int tmp=sumF;//剩余分数
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                cnt++;
            }
        }
        if(cnt!=sumT)continue;//封榜后过的题目数与枚举不同
        int f=1;
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                if(ques[j].first==ques[j].second){f=0;break;}
                tmp-=ques[j].first*20+240;
                ans[j].first=ques[j].first+1;
                ans[j].second=240;//必须要有的罚时
            }
            else{
                ans[j].first=-1;//ans第一维是-1 表示这道题封榜之后也没过
                ans[j].second=ques[j].second;
            }
        }
        if(!f) continue;//遇到了封榜之后没交的题
        if(tmp<0) continue;//模拟该情况罚时不合法
        
        for(int j=0;j<n;j++){
            if(tmp<20) break;
            if((i>>j)&1){
                int tot=ques[j].second-ques[j].first-1;
                int tt=tmp/20;
                if(tt>tot){
                    //tt还需要wa多少发
                    //tot这道题能wa几次
                    tmp-=tot*20;
                    ans[j].first+=tot;
                }
                else{
                    tmp-=tt*20;
                    ans[j].first+=tt;//到这里tmp小于20
                }
            }
        }
        //接下来细调tmp 两种情况
        for(int j=0;j<n;j++){
            if(!tmp) break;
            if((i>>j)&1){
                if(tmp>=59){
                    tmp-=59;
                    ans[j].second=299;
                }
                else{
                    ans[j].second+=tmp;
                    tmp=0;
                }
            }
        }
        if(!tmp){
            //合法
            flag=1;cout<<"Yes\n";
            int ca=0,cq=0;
            for(int j=1;j<=m;j++){
                if(op[j]=='+'){
                    cout<<op[j]<<" ";
                    cout<<add[ca].first<<"/"<<add[ca].second<<"\n";ca++;
                }
                else if(op[j]=='-'){
                    cout<<"- "<<pass[j]<<"\n";
                }
                else if(op[j]=='?'){
                    if(ans[cq].first==-1){
                        cout<<"- "<<ans[cq].second<<"\n";cq++;
                    }
                    else{
                        cout<<"+ ";
                        cout<<ans[cq].first<<"/"<<ans[cq].second<<"\n";cq++;
                    }
                }
                else cout<<op[j]<<"\n";
            }
            break;
        }
    }
    if(!flag) cout<<"No\n";
}

int main(){
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
#endif 
    int _=1;
    cin>>_>>m;
    while(_--){
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

input:

1 13
7 951
+ 1/6
? 3 4
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.

output:

Yes
+ 1/6
+ 3/243
+ 4/183
- 2
+ 3/217
.
.
.
+ 2/29
+ 1/91
.
+ 1/22
.

result:

ok ok (1 test case)

Test #2:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

6 2
1 100
.
? 3 4
2 100
+ 1/1
+ 1/2
0 0
- 5
- 6
2 480
? 100 100
? 100 100
2 480
? 99 100
? 100 100
1 2000
? 100 100
? 100 100

output:

No
No
Yes
- 5
- 6
Yes
+ 1/240
+ 1/240
No
Yes
+ 89/240
- 100

result:

ok ok (6 test cases)

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3592kb

input:

1000 13
6 1519
+ 3/183
- 1
+ 9/133
? 2 3
- 5
? 1 3
- 5
? 1 1
? 1 3
- 5
+ 1/165
- 6
? 2 5
2 570
- 2
- 9
.
- 1
- 7
- 6
+ 4/179
- 2
? 2 5
.
- 2
? 1 3
.
1 140
.
- 2
.
- 2
- 1
- 2
- 2
.
.
.
.
+ 3/100
.
1 195
+ 1/195
.
.
.
.
.
.
.
.
? 1 1
.
.
.
0 0
.
.
.
.
.
.
.
.
.
.
.
.
.
3 776
? 8 22
? 1 8
- 6
+ 1/173
...

output:

Yes
+ 3/183
- 1
+ 9/133
+ 3/278
- 5
+ 3/240
- 5
+ 1/240
- 3
- 5
+ 1/165
- 6
- 5
Yes
- 2
- 9
.
- 1
- 7
- 6
+ 4/179
- 2
+ 5/251
.
- 2
- 3
.
Yes
.
- 2
.
- 2
- 1
- 2
- 2
.
.
.
.
+ 3/100
.
Yes
+ 1/195
.
.
.
.
.
.
.
.
+ 0/0
.
.
.
Yes
.
.
.
.
.
.
.
.
.
.
.
.
.
Yes
- 22
- 8
- 6
+ 1/173
- 11
- 9
- 3
- 6
+ 6/...

result:

wrong answer submission should be between 1 and 100 (test case 4)