QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#367592#2364. Endgamekevinyang#WA 1ms3636kbC++171.7kb2024-03-26 09:13:472024-03-26 09:13:47

Judging History

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

  • [2024-03-26 09:13:47]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3636kb
  • [2024-03-26 09:13:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
mt19937_64 rng(std::chrono::system_clock::now().time_since_epoch().count());

bool solve(int a, int b, int c, int d, vector<int>&x, vector<int>&y){
	int n = x.size();
	// can (a,b) move two moves to capture (c,d)
	map<pair<int,int>,int>hm;

	for(int i = 0; i<n; i++){
		hm[{a+x[i],b+y[i]}] = 1;
	}
	if(hm.count({c,d}))return true;
	for(int i = 0; i<n; i++){
		if(hm.count({c-x[i],d-y[i]})){
			return true;
		}
	}
	return false;
}
signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int>x(n);
	vector<int>y(n);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	for(int i = 0; i<n; i++){
		cin >> x[i] >> y[i];
	}
	if(solve(a,b,c,d,x,y)){
		cout << "Alice wins\n";
		return 0;
	}
	if(n<=1000){
		vector<vector<bool>>vis(n+1,vector<bool>(n+1));
		for(int i = 0; i<n; i++){
			for(int j = 0; j<n; j++){
				int nx = c+x[i]+x[j];
				int ny = d+y[i]+y[j];
				if(nx>=1 && nx<=n && ny>=1 && ny<=n){
					vis[nx][ny] = 1;
				}
			}
			int nx = c+x[i];
			int ny = d+y[i];
			if(nx>=1 && nx<=n && ny>=1 && ny<=n){
				vis[nx][ny] = 1;
			}
		}
		for(int i = 1; i<=n; i++){
			for(int j = 1; j<=n; j++){
				if(i==c && j==d)continue;
				if(!vis[i][j]){
					cout << "tie " << i << ' ' << j << '\n';
					return 0;
				}
			}
		}
		cout << "Bob wins\n";
		return 0;
	}
	for(int iters = 0; iters<50; iters++){
		int ax = c; int ay = d;
		while(ax == c && ay == d){
			ax = rng()%n+1;
			ay = rng()%n+1;
		}
		if(solve(c,d,ax,ay,x,y)){
			continue;
		}
		cout << "tie " << ax << ' ' << ay << endl;
		return 0;
	}
	cout << "Bob wins\n";
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
2 3
1 3
1 0
0 -1
1 -1

output:

Bob wins

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

3
3 3
1 1
1 0
1 1
0 1

output:

Bob wins

result:

ok 

Test #3:

score: 0
Accepted
time: 0ms
memory: 3548kb

input:

3
2 2
3 1
-1 0
-1 1
0 1

output:

Bob wins

result:

ok 

Test #4:

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

input:

5
2 1
1 2
-2 2
1 -1
1 1
2 2
3 3

output:

Alice wins

result:

wrong answer Author claims 'alice', but judge claims 'tie'