QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#24152#2615. Surround the CatgalaxiasWA 5ms3572kbC++113.5kb2022-03-26 18:11:112022-04-30 05:08:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 05:08:50]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3572kb
  • [2022-03-26 18:11:11]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;

int dx[] = {0,1,-1,0,1,-1};
int dy[] = {1,0,0,-1,1,-1};


int ddx[] = {1,2,1,-1,-2,-1};
int ddy[] = {-1,1,2,1,-1,-2};

map<pair<int,int>, int> mp;

bool isedge(int x, int y) {
	if(x == 8) {
		for(int i=0;i<=8;i++) {
			if(y == i) return true;
		}
	}
	
	if(y == 8) {
		for(int i=0;i<=8;i++) {
			if(x == i) return true;
		}
	}
	
	for(int i=0;i<=8;i++) {
		if(x == 0-i && y == 8-i) return true;
	}
	
	for(int i=0;i<=8;i++) {
		if(x == 0+i && y == -8+i) return true;
	}
	
	if(x == -8) {
		for(int i=0;i<=8;i++) {
			if(y == -i) return true;
		}
	}
	
	if(y == -8) {
		for(int i=-8;i<=0;i++) {
			if(x == i) return true;
		}
	}
	
	return false;

}

bool dfs1(int x, int y) {
	for(int i=0;i<6;i++) {
		int xx = x+dx[i];
		int yy = y+dy[i];
		if(isedge(xx,yy)) return true;
	}
	return false;
}

bool dfs2(int x, int y) {
	for(int i=0;i<6;i++) {
		int xx = x+dx[i];
		int yy = y+dy[i];
		if(dfs1(xx,yy)) return true;
	}
	return false;
}

pair<int,int> findvis() {
	for(int i=0;i<=8;i++) {
		if(!mp.count(make_pair(8,i))) return make_pair(8,i);
	}
	for(int i=0;i<=8;i++) {
		if(!mp.count(make_pair(i,8))) return make_pair(i,8);
	}
	for(int i=0;i<=8;i++) {
		if(!mp.count(make_pair(0-i,8-i))) return make_pair(0-i,8-i);
	}
	for(int i=0;i<=8;i++) {
		if(!mp.count(make_pair(-8,-i))) return make_pair(-8,-i);
	}
	for(int i=0;i<=8;i++) {
		if(!mp.count(make_pair(-8+i,-8))) return make_pair(-8+i,-8);
	}
	for(int i=0;i<=8;i++) {
		if(!mp.count(make_pair(0+i,-8+i))) return make_pair(0+i,-8+i);
	}
}

pair<int,int> query(int x, int y) {
	cout << x << " " << y << endl;
	cout.flush();
	mp[make_pair(x,y)] = 1;
	int xx,yy;
	cin >> xx >> yy;
	return make_pair(xx,yy);
}

signed main() {
	int qw, wq;
	pair<int,int> cur;
	cin >> wq >> qw;
	query(8,1);
	query(7,8);
	query(-1,8);
	query(-8,-1);
	query(-7,-8);
	cur = query(1,-8);
	for(int i=0;i<42;i++) {
		if(dfs1(cur.first,cur.second)) {
			int ok = 0;
			for(int i=0;i<6;i++) {
				int xx = cur.first+dx[i];
				int yy = cur.second+dy[i];
				if(isedge(xx,yy) && !mp.count(make_pair(xx,yy))) {

					cur = query(xx,yy);
					ok=1;
					break;
				}
			} 
			if(!ok) {
				
			int okk = 0;
			for(int i=0;i<6;i++) {
				int xx = cur.first+ddx[i];
				int yy = cur.second+ddy[i];
				if(isedge(xx,yy) && !mp.count(make_pair(xx,yy))) {

					cur = query(xx,yy);
					okk=1;
					break;
				}
			}
			if(!okk) {
				pair<int,int> tmp = findvis();

				cur = query(tmp.first,tmp.second);
			}

			}
		}else if(dfs2(cur.first,cur.second)) {
			int ok = 0;
			for(int i=0;i<6;i++) {
				int xx = cur.first+ddx[i];
				int yy = cur.second+ddy[i];
				if(xx == 8 && yy == 0) continue;
				if(xx == 8 && yy == 8) continue;
				if(xx == 0 && yy == 8) continue;
				if(xx == -8 && yy == 0) continue;
				if(xx == -8 && yy == -8) continue;
				if(xx == 0 && yy == -8) continue;
				if(isedge(xx,yy) && !mp.count(make_pair(xx,yy))) {

					cur = query(xx,yy);
					ok=1;
					break;
				}
			}
			if(!ok) {
				pair<int,int> tmp = findvis();

				cur = query(tmp.first,tmp.second);
			}
		}else {
				pair<int,int> tmp = findvis();

				cur = query(tmp.first,tmp.second);
		}
	}

	
}
/*
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7

0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
0 0
*/


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 3572kb

input:

0 0
1 0
2 1
3 2
4 3
5 4
6 5
7 6
7 7
6 7
5 7
6 7
5 7
6 7
5 7
6 7
7 7
6 7
7 7
6 7
5 7
6 7
7 7
7 6
7 7
7 6
7 5
7 6
7 7
7 6
7 7
7 6
7 7
6 7
7 7
6 7
5 7
6 7
7 7
6 7
7 7
7 6
7 7
6 7
5 7
6 7
7 7
6 7
5 7

output:

8 1
7 8
-1 8
-8 -1
-7 -8
1 -8
8 6
8 7
8 8
6 8
5 8
8 0
4 8
8 2
8 3
8 4
8 5
0 8
1 8
2 8
3 8
-1 7
-2 6
-3 5
-4 4
-5 3
-6 2
-7 1
-8 0
-8 -2
-8 -3
-8 -4
-8 -5
-8 -6
-8 -7
-8 -8
-6 -8
-5 -8
-4 -8
-3 -8
-2 -8
-1 -8
0 -8
1 -7
2 -6
3 -5
4 -4
5 -3

result:

wrong answer wrong output format  Unexpected end of file - int32 expected