답안 #44947

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
44947 2018-04-09T19:32:52 Z JustInCase Go, Gopher! (GCJ18Q_gogopher) C++17
30 / 30
101 ms 1336 KB
#include <bits/stdc++.h>
using namespace std;

bool isMarked[1000][1000];

int main() {
	int32_t cntTests;
	cin >> cntTests;

	for(int32_t cs = 1; cs <= cntTests; cs++) {
		int32_t a;
		cin >> a;
		
		memset(isMarked, 0, sizeof(isMarked));
		int32_t currRow = 10, currCol = 10, cntMarked = 0, cnt = 0;

		while(1) {
			cnt++;
			cout << currRow << " " << currCol << endl << flush;

			int32_t x, y;
			cin >> x >> y;

			if(x == 0 && y == 0) {
				break;
			}
			else if(x == -1 && y == -1) {
				return 0;
			}
	
			if(!isMarked[x][y]) {
				isMarked[x][y] = true;
				cntMarked++;
			}
			
			bool isReady = true;
			for(int32_t r = currRow - 1; r <= currRow + 1; r++) {
				for(int32_t c = currCol - 1; c <= currCol; c++) {
					if(!isMarked[r][c]) {
						isReady = false;
						break;
					}
				}
			}

			if(isReady) {
				int32_t rem = 0;
				if(!isMarked[x - 1][y + 1]) {
					rem++;
				}
				if(!isMarked[x][y + 1]) {
					rem++;
				}
				if(!isMarked[x + 1][y + 1]) {
					rem++;
				}

				if(rem < a - cntMarked) {
					currCol++;
				}
			}
		}
	}
}

# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 101 ms 1336 KB Output is correct