This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
cerr << cnt << endl;
break;
}
else if(x == -1 && y == -1) {
cerr << currCol << " " << cntMarked << endl;
for(int32_t i = 9; i <= currCol + 1; i++) {
for(int32_t j = 9; j <= 11; j++) {
cerr << isMarked[j][i];
}
cerr << endl;
}
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++;
}
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |