Submission #230942

#TimeUsernameProblemLanguageResultExecution timeMemory
230942jiahngUntitled (GCJ18Q_gogopher)C++14
30 / 30
102 ms1280 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pi; typedef vector <ll> vi; typedef vector <pi> vpi; #define f first #define s second #define FOR(i,s,e) for(ll i=s;i<=ll(e);++i) #define DEC(i,s,e) for(ll i=s;i>=ll(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end() #define lbd(x, y) lower_bound(all(x), y) #define ubd(x, y) upper_bound(all(x), y) #define aFOR(i,x) for (auto i: x) #define mem(x,i) memset(x,i,sizeof x) #define fast ios_base::sync_with_stdio(false),cin.tie(0) int TC; int A,W,H; bool done[1000][1000]; int dx[9] = {0,0,0,-1,1,-1,1,-1,1}; int dy[9] = {0,-1,1,-1,1,0,0,1,-1}; int main(){ fast; cin>>TC; while (TC--){ cin>>A; if (A == 20){ W = 4; H = 5; }else{ W = 40; H = 5; } pi tl = pi(500,500); pi br = pi(500 + W - 1,500 + H - 1); mem(done,0); bool finish = 0; FOR(i,tl.f,br.f){ FOR(j,tl.s,br.s){ while (!done[i][j]){ pi qry; int curmn = 10; FOR(k,0,8){ pi cur = pi(i+dx[k],j+dy[k]); if (cur.f <= tl.f || cur.f >= br.f || cur.s <= tl.s || cur.s >= br.s) continue; int num = 0; FOR(l,0,8){ if (done[cur.f + dx[l]][cur.s + dy[l]]) num++; } if (num < curmn){ curmn = num; qry = cur; } } cout<<qry.f<<' '<<qry.s<<'\n'; cout.flush(); int a,b; cin>>a>>b; if (a == -1 && b == -1) finish = 1; if (a == 0 && b == 0) finish = 1; if (finish) break; done[a][b] = 1; } if (finish) break; } if (finish) break; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...