#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
int dx[9] = {0, 0, 0, 1, 1, 1, -1, -1, -1};
int dy[9] = {0, 1, -1, 0, 1, -1, 0, 1, -1};
int main()
{
int t;
cin>>t;
while(t--){
int A;
cin>>A;
int a = 3;
set<pii> usados;
int b = (A % a == 0 ? A/a : (A/a) + 1);
int Xmin = 10, Xmax = 10 + (a) - 1;
int Ymin = 10, Ymax = 10 + (b) - 1;
vector<pii> v;
for(int i = Xmin + 1; i < Xmax; i++)
for(int j = Ymin + 1; j < Ymax; j ++)
v.push_back({i, j});
random_shuffle(v.begin(), v.end());
for(int p = 0; p < v.size(); p++){
int x = v[p].f, y = v[p].s;
int conta = 0 ;
for(int i = 0; i < 9; i++)
{
int a = x + dx[i], b = y + dy[i];
if(usados.count({a, b})) conta ++;
}
if(conta == 9)
{
if(p == v.size() - 1) p = -1;
continue;
}
cout<<x<<" "<<y<<endl;
int a , b;
cin>>a>>b;
if(a == 0 && b == 0) break;
usados.insert({a, b});
if(p == v.size() - 1) p = -1;
}
}
}
Compilation message
gogopher.cpp: In function 'int main()':
gogopher.cpp:41:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int p = 0; p < v.size(); p++){
~~^~~~~~~~~~
gogopher.cpp:56:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(p == v.size() - 1) p = -1;
~~^~~~~~~~~~~~~~~
gogopher.cpp:71:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(p == v.size() - 1) p = -1;
~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
336 KB |
Output is correct |