QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#130134#5653. Library gamebai_hongWA 1ms3676kbC++201.3kb2023-07-23 17:05:222023-07-23 17:05:40

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-23 17:05:40]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3676kb
  • [2023-07-23 17:05:22]
  • 提交

answer

#include<bits/stdc++.h>
const int QWQ=5005;
using namespace std;
inline int read(){
	char ch = getchar();int x = 0, f = 1;
	while(ch<'0'||ch>'9'){if(ch == '-') f = -1;ch = getchar();}
	while('0'<=ch && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}
inline void write(int x){
	if(x <0)putchar('-'),x =-x;
	if(x >9)write(x /10);
	putchar(x %10+'0');
}
int n,m,a[QWQ],vis[QWQ];
bool cmp(int x,int y){ return x>y; }
bool cheak(){
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++)
		if (a[i]>m/i) return a[i];
	return 0;
}
signed main(){
	n=read(),m=read();
	for (int i=1;i<=n;i++) a[i]=read();
	int can=cheak();
	if (can){
		puts("Bernardo");
		fflush(stdout);
		int x,l,r;
		for (int i=n;i>=1;i--){
			x=read(),l=read();
			r=l+x-1; bool fl=0;
			for (int j=l;j<=r;j++)
				if(j%can==0){ fl=1; printf("%d\n",j); break; }
			if (!fl) printf("%d\n",l);
			fflush(stdout);
		}
	} else{
		puts("Alessia");
		printf("%d %d\n",a[1],1);
		fflush(stdout);
		vis[m+1]=1; int x;
		for (int i=2;i<=n;i++){
			x=read(),vis[x]=1;
			int tmp=114514,tp;
			for (int j=1,last=0;j<=m+1;j++)
				if (vis[j]){
					if (j-last-1>=a[i]&&j-last-1<tmp)
						tmp=j-last-1,tp=last+1;
					last=j;
				}
			printf("%d %d\n",a[i],tp);
			fflush(stdout);
		} x=read();
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3676kb

input:

5 14
3 7 2 3 10
7
14
2
4
6

output:

Alessia
10 1
7 8
3 1
3 3
2 5

result:

ok Contestant won the game

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3656kb

input:

4 10
4 1 6 4
6 1
4 2
4 3
1 4

output:

Bernardo
1
2
3
4

result:

wrong answer Judge won the game