QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#130175#5653. Library gameqWA 0ms3440kbC++231.2kb2023-07-23 17:27:122023-07-23 17:27:12

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:27:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3440kb
  • [2023-07-23 17:27:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct BIT{
	int n,c[5005];
	void init(int x){
		n=x;
	}
	int lowbit(int x){
		return x&(-x);
	}
	void update(int x,int val){
		for(;x<=n;x+=lowbit(x)){
			c[x]+=val;
		}
	}
	int ask(int x){
		int res=0;
		for(;x;x-=lowbit(x)){
			res+=c[x];
		}
		return res;
	}
	int query(int x,int y){
		return ask(y)-ask(x-1);
	}
};
const int N=105,M=5005;
int n,m,a[N],ccc;
bool cmp1(int x,int y){
	return x>y;
}
int check(){
	sort(a+1,a+n+1,cmp1);
	for(int i=1;i<=n;i++){
		if(a[i]>m/i){
			return a[i];
		}
	}
	return 0;
}
bool vis[M];
void A(){
	cout<<"Alessia\n"<<flush;
	BIT t;
	t.init(n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m-a[i]+1;j++){
			if(!t.query(j,j+a[i]-1)){
				cout<<a[i]<<" "<<j<<"\n"<<flush;
				break;
			}
		}
		int b;
		cin>>b;
		t.update(b,1);
	}
}
void B(){
	cout<<"Bernardo\n"<<flush;
	for(int i=1;i<=n;i++){
		int y,a;
		cin>>y>>a;
		int l=a,r=a+y-1,ans=0;
		for(int j=l;j<=r;j++){
			if(j%ccc==0){
				ans=i;
				break;
			}
		}
		cout<<ans<<"\n"<<flush;
	}
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ccc=check();
	!ccc?A():B();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3440kb

input:

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

output:

Alessia
10 1
7 1
3 1
3 3
2 5

result:

wrong answer Judge won the game