QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#710617#5140. Frozen ScoreboardkalikariWA 3ms3968kbC++174.1kb2024-11-04 20:44:152024-11-04 20:44:15

Judging History

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

  • [2024-11-04 20:44:15]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3968kb
  • [2024-11-04 20:44:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
/*
ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
*/
// #define int long long
#define ld long double
//#define INT __int128
#define eb(x) emplace_back(x)
#define fi first
#define se second
#define sc(x) scanf("%d",&x)
#define SC(x) scanf("%lld",&x)
#define reserve reserve
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<long long, long long> PLL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const ld eps = 1e-12;
const int N = 1e3 + 10, M = 13 + 10;
int n,m,nw;
struct TL{
    char op[2];
    int x,y;
    int pos,fg;
}tl[M],ans[M];
bool vis[M];
int a,b;

int dfs(int u,int liml,int limr,int cn){
    if(u>nw){
        // for(int i=1;i<=nw;i++){
        //     cout<<vis[i]<<" ";
        // }
        // cout<<endl;
        // cout<<"__________=====_   "<<liml<<" "<<limr<<" "<<b<<endl;
        if(liml<=b&&b<=limr&&cn==a)return 1;
        return 0;
    }
    int ret=dfs(u+1,liml,limr,cn);
    if(ret)return 1;

    int nw_liml=liml+(tl[u].y-tl[u].x)*20+240, nw_limr=limr+tl[u].y*20+299;
    // cout<<"++++++++++  "<<" "<<tl[u].y<<" "<<tl[u].x<<" "<<(tl[u].y-tl[u].x)*20+240<<endl;
    vis[u]=1;
    ret=dfs(u+1,nw_liml,nw_limr,cn+1);
    if(ret)return 1;
    vis[u]=0;
    
    return 0;
}

void solve(){
    nw=0;
    memset(vis,0,sizeof vis);

    scanf("%d%d",&a,&b);
    for(int i=1;i<=m;i++){
        tl[i].fg=0;
        scanf("%s",tl[i].op);
        if(tl[i].op[0]=='+'){
            scanf("%d/%d",&tl[i].x,&tl[i].y);
        }
        else if(tl[i].op[0]=='-'){
            scanf("%d",&tl[i].x);
        }
        else if(tl[i].op[0]=='?'){
            scanf("%d%d",&tl[i].x,&tl[i].y);
            tl[i].fg=1;
        }
        tl[i].pos=i;
    }
    sort(tl+1,tl+1+m,[](const TL&a,const TL&b){
        return a.fg>b.fg;
    });

    // cout<<"+__++_____________"<<a<<" "<<b<<endl;

    for(int i=1;i<=m;i++){
        ans[i]=tl[i];
        if(tl[i].op[0]=='?')nw++;
        else{
            int tim=0;
            if(tl[i].op[0]=='+'){
                a--;
                tim+=20*(tl[i].x-1)+tl[i].y;
            }
            b-=tim;
        }
    }

    // cout<<"_________________"<<a<<" "<<b<<" "<<nw<<endl;

    int fg=dfs(1,0,0,0);
    
    if(!fg){
        puts("No");
        return;
    }
    // for(int i=1;i<=m;i++){
    //     cout<<vis[i]<<" ";
    // }
    // cout<<endl;


    int p=b;
    for(int i=1;i<=nw;i++){
        if(vis[i]){
            ans[i].op[0]='+';
            ans[i].x=tl[i].y-tl[i].x+1;
            ans[i].y=240;
            p-=(tl[i].y-tl[i].x)*20+240;
        }
        else{
            ans[i].op[0]='-';
            ans[i].x=tl[i].y;
        }
    }
    // cout<<"_________"<<p<<endl;
    for(int i=1;i<=nw;i++){
        if(vis[i]){
            ans[i].op[0]='+';
            int t=tl[i].x-1;
            // cout<<"+++----------- ---____"<<i<<" "<<t<<" "<<p<<endl;
            while(p>=20&&t){
                ans[i].x++;
                p-=20;
                t--;
            }
            if(p&&ans[i].y<299){
                int t=min(p,299-ans[i].y);
                ans[i].y+=t;
                p-=t;
            }
        }
    }

    // cout<<"_________"<<p<<endl;
    if(p<20){
        ans[nw].y+=p;
        p-=p;
    }
    // if(p!=0){
    //     puts("No");
    //     return;
    // }

    sort(ans+1,ans+1+m,[](const TL&a,const TL&b){
        return a.pos<b.pos;
    });
    puts("Yes");
    for(int i=1;i<=m;i++){
        printf("%c ",ans[i].op[0]);
        if(ans[i].op[0]=='+'){
            printf("%d/%d\n",ans[i].x,ans[i].y);
        }
        else if(ans[i].op[0]=='-'){
            printf("%d\n",ans[i].x);
        }
        else{
            printf("\n");
        }
    }
}

signed main(){
    // ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    int T=1,cas=1;
    cin>>T;
    scanf("%d",&m);
    while(T--){
        solve();
    }
    return 0;
}

详细

Test #1:

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

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: 3780kb

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
- 100
+ 89/240

result:

ok ok (6 test cases)

Test #3:

score: -100
Wrong Answer
time: 3ms
memory: 3968kb

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
- 5
- 3
- 5
+ 1/258
+ 3/240
- 5
+ 1/165
- 6
+ 4/240
Yes
- 2
- 9
. 
- 1
- 7
- 6
+ 4/179
- 2
- 5
. 
- 2
+ 3/291
. 
Yes
. 
- 2
. 
- 2
- 1
- 2
- 2
. 
. 
. 
. 
+ 3/100
. 
Yes
+ 1/195
. 
. 
. 
. 
. 
. 
. 
. 
- 1
. 
. 
. 
Yes
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
. 
Yes
- 22
- 8
-...

result:

wrong answer wrong total time (test case 13)