QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#774756#5140. Frozen Scoreboardszy10010WA 5ms34968kbC++234.1kb2024-11-23 13:48:402024-11-23 13:48:40

Judging History

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

  • [2024-11-23 13:48:40]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:34968kb
  • [2024-11-23 13:48:40]
  • 提交

answer

#include <map>
#include <set>
#include <queue>
#include <deque>
#include <cmath>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define fi first
#define se second
#define u1 (u<<1)
#define u2 (u<<1|1)
#define pb push_back
#define pp pop_back()
#define int long long
#define laile cout<<"laile"<<endl
#define lowbit(x) ((x)&(-x))
#define double long double
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld %lld",&x,&y)
#define sd(x) scanf("%Lf",&x)
#define sdd(x,y) scanf("%Lf %Lf",&x,&y)
#define _for(i,n) for(int i=0;i<(n);++i)
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
#define _pre(i,a,b) for(int i=(a);i>=(b);--i)
#define all(x) (x).begin(), (x).end()
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef unsigned long long ULL;
typedef pair<int,int>PII;
typedef pair<double,double>PDD;
const int N=1e6+10,INF=4e18;
int n,p,m;
string s[N];
int ac,nowpen;
struct aa
{
	bool bl;
	int submit;
	int must;
	int finalsubmit;
	int pen;
	int id;
};
vector<aa>v;
void deal1(string &s)
{
	bool bl=false;
	int x=0,y=0;
	_for(i,s.size())
	{
		if(isdigit(s[i]))
		{
			if(!bl)x=x*10+s[i]-'0';
			else y=y*10+s[i]-'0';
		}
		if(s[i]=='/')bl=true;
	}
	nowpen-=(x-1)*20;
	nowpen-=y;
	ac--;
}
void deal2(string &s,int id)
{
	bool bl=false;
	int x=0,y=0;
	_for(i,s.size())
	{
		if(isdigit(s[i]))
		{
			if(!bl)x=x*10+s[i]-'0';
			else y=y*10+s[i]-'0';
		}
		if(s[i]==' '&&x)bl=true;
	}
	v.pb({false,x,y-x,0,0,id});
}
bool pan[20];//判断是否?变+
void solve()
{
	cin>>ac>>nowpen;
	getline(cin,s[0]);
	v.clear();
	_rep(i,1,m)
	{
		pan[i]=false;
		getline(cin,s[i]);
		if(s[i][0]=='.'||s[i][0]=='-')continue;
		if(s[i][0]=='+')deal1(s[i]);
		if(s[i][0]=='?')deal2(s[i],i);
	}
	if(nowpen<0)
	{
		cout<<"No\n";
		return ;
	}
	if(ac==0)
	{
		if(nowpen==0)
		{
			cout<<"Yes\n";
			_rep(i,1,m)
			{
				if(s[i][0]!='?')cout<<s[i]<<"\n";
				else 
				{
					cout<<"- ";
					for(auto k:v)
					{
						if(k.id==i)
						{
							cout<<k.must+k.submit<<'\n';
							break;
						}
					}
				}
			}
		}
		else cout<<"No\n";
		return;
	}
//	cout<<"nowpen="<<nowpen<<endl;
	for(int i=0;i<1<<(int)v.size();i++)
	{
		int pen=nowpen;
		bool panduan=false;
		int l=0,r=0,sumsubmit=0,cnt1=0;
		int minneed;//最少需要多提交次数
		for(int j=0;j<(int)v.size();j++)
		{
			if(i>>j&1)
			{
				l+=240;
				r+=299;
				pen-=v[j].must*20;
				sumsubmit+=v[j].submit-1;
				//可能产生罚时的提交
				cnt1++;
				v[j].bl=true;
				pan[j]=true;
			}
			else v[j].bl=false;
		}
		/*
		bool bl;
		int submit;
		int must;
		int finalsubmit;
		int pen;
		int id;
		*/
		if(cnt1!=ac)continue;
//		cout<<"sumsubmit="<<cnt1<<" "<<sumsubmit<<" "<<pen<<" "<<l<<" "<<r<<endl;
//		cout<<"l,r="<<l<<"    "<<r<<endl;
		if(pen<l)continue;
		else if(pen>=l&&pen<=r)
			minneed=0;
		else 
		{
			minneed=((pen-r)+19)/20;
			pen-=minneed*20;
		}
//		cout<<"minneed pen="<<minneed<<" "<<pen<<endl;
//		cout<<"minneed subsubmit"<<minneed<<" "<<sumsubmit<<endl;
		if(minneed>sumsubmit)continue;
//		cout<<"ac="<<ac<<endl;
		int chu=pen/ac,yu=pen%ac,cnt=0;
		for(int j=0;j<(int)v.size();j++)
		{
			if(i>>j&1)
			{
				if(++cnt<=yu)v[j].pen=chu+1;
				else v[j].pen=chu;
				if(minneed>v[j].submit-1)
					v[j].finalsubmit=v[j].must+v[j].submit,minneed-=v[j].submit-1;
				else 
					v[j].finalsubmit=v[j].must+minneed+1,minneed=0;
				pan[v[j].id]=true;
			}
		}
		cout<<"Yes\n";
//		cout<<"m="<<m<<endl;
		for(int j=1;j<=m;j++)
		{
//			cout<<"j="<<j<<endl;
			if(!pan[j])
			{
				if(s[j][0]!='?')cout<<s[j]<<'\n';
				else 
				{
					cout<<"- ";
					for(auto k:v)
					{
						if(k.id==j)
						{
							cout<<k.must+k.submit<<'\n';
							break;
						}
					}
				}
			}
			else
			{
				for(auto k:v)
				{
					if(k.id==j)
					{
						cout<<"+ "<<k.finalsubmit<<"/"<<k.pen<<'\n';
						break;
					}
				}
			}
		}
		return ;
	}
	cout<<"No\n";
	return ;
}
signed main()
{
	IOS;
	int T=1;
    cin>>T>>m;
	while(T--)
		solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok ok (1 test case)

Test #2:

score: 0
Accepted
time: 5ms
memory: 34952kb

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
+ 87/280
- 100

result:

ok ok (6 test cases)

Test #3:

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

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
+ 9/133
+ 2/260
- 5
+ 3/259
- 5
+ 1/259
- 3
- 5
+ 1/165
- 6
- 5
Yes
- 2
- 9
.
- 1
- 7
- 6
+ 4/179
- 2
+ 4/271
.
- 2
- 3
.
Yes
.
- 2
.
- 2
- 1
- 2
- 2
.
.
.
.
+ 3/100
.
Yes
+ 1/195
.
.
.
.
.
.
.
.
- 1
.
.
.
Yes
.
.
.
.
.
.
.
.
.
.
.
.
.
Yes
+ 0/0
+ 0/0
+ 1/173
- 11
- 9
- 3
- 6
+ 4/294
- 8
- 12
- ...

result:

wrong answer 1-th verdict are different from the input. (test case 1)