QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#658098#5140. Frozen ScoreboardSouthernB#WA 10ms1704kbC++141.9kb2024-10-19 16:09:172024-10-19 16:09:17

Judging History

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

  • [2024-10-19 16:09:17]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:1704kb
  • [2024-10-19 16:09:17]
  • 提交

answer

#include <cstdio>
#include <cctype>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
template<typename T> void cmax(T &a,const T &b){if(a<b)a=b;}
template<typename T> void cmin(T &a,const T &b){if(b<a)a=b;}

const int N=1005;

void read(int &x){
	char c;
	while(!isdigit(c=getchar()));
	x=(c&15);
	while(isdigit(c=getchar()))
		x=x*10+(c&15);
}
void read(char &c){
	while(isspace(c=getchar()));
}

int n,m,a,b;
char op[N];
int x[N],y[N];

int gb(int x,int i){return (x>>i)&1;}

void fmain(){
	read(n),read(m);
	while(n--){
		read(a),read(b);
		for(int i=0;i<m;++i){
			read(op[i]);
			if(op[i]!='.'){
				read(x[i]);
				if(op[i]!='-')
					read(y[i]);
			}
		}
		bool f=false;
		for(int S=0;S<(1<<m);++S){
			if(__builtin_popcount(S)!=a)
				continue;
			bool flg=false;
			for(int i=0;i<m;++i)
				if((gb(S,i) && (op[i]=='-' || op[i]=='.')) || (!gb(S,i) && op[i]=='+')){
					flg=true;
					break;
				}
			if(flg)
				continue;
			int mn=0,mx=0;
			for(int i=0;i<m;++i){
				if(!gb(S,i))
					continue;
				if(op[i]=='+'){
					mn+=(x[i]-1)*20+y[i];
					mx+=(x[i]-1)*20+y[i];
				}else{ // ?
					mn+=(y[i]-x[i])*20+240;
					mx+=(y[i]-1)*20+299;
				}
			}
			if(!(mn<=b && b<=mx))
				continue;
			int p=b-mn;
			puts("Yes");
			for(int i=0;i<m;++i){
				if(op[i]=='.'){
					puts(".");
				}else if(op[i]=='-'){
					printf("- %d\n",x[i]);
				}else if(op[i]=='+'){
					printf("+ %d/%d\n",x[i],y[i]);
				}else if(gb(S,i)){
					if((x[i]-1)*20+59<=p){
						printf("+ %d/299\n",y[i]);
						p-=(x[i]-1)*20+59;
					}else{
						int o=y[i]-x[i];
						while(p>=20 && o<y[i]-1){
							++o;
							p-=20;
						}
						printf("+ %d/%d\n",o+1,240+p);
					}
				}else{
					printf("- %d\n",y[i]);
				}
			}
			f=true;
			break;
		}
		if(!f)
			puts("No");
	}
}

int main(){
	fmain();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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: 10ms
memory: 1704kb

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/278
- 5
+ 1/278
- 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
.
.
.
.
.
.
.
.
- 1
.
.
.
Yes
.
.
.
.
.
.
.
.
.
.
.
.
.
Yes
- 22
- 8
- 6
+ 1/173
- 11
- 9
- 3
- 6
+ 6/25...

result:

wrong answer wrong total time (test case 1)