Submission #264612

#TimeUsernameProblemLanguageResultExecution timeMemory
264612Namnamseo보물 찾기 (CEOI13_treasure2)C++17
69 / 100
1 ms384 KiB
#include "treasure.h" #include <cstring> #include <utility> #include <functional> using namespace std; int rot; bool ans[110][110]; int n; pair<int,int> translate(int x, int y) { if (rot == 0) return {x, y}; if (rot == 1) return {n+1-y, x}; if (rot == 2) return {n+1-x, n+1-y}; return {y, n+1-x}; } int ask(int x, int y) { int fx, fy; tie(fx, fy) = translate(1, 1); tie(x, y) = translate(x, y); if (fx > x) swap(fx, x); if (fy > y) swap(fy, y); return countTreasure(fx, fy, x, y); } void put_ans(int i, int j, int v) { tie(i, j) = translate(i, j); ans[i][j] = v; } int tmp[110][110]; void findTreasure (int N) { n = N; int w = N/2, ww = N-w; int h = N/2, hh = N-h; memset(ans, 0, sizeof(ans)); for(rot=0; rot<4; ++rot) { for(int i=w; i<=N; ++i) for(int j=h; j<=N; ++j) { tmp[i][j] = ask(i, j); } for(int i=w+1; i<=N; ++i) for(int j=h+1; j<=N; ++j) { put_ans(i, j, tmp[i][j] - tmp[i-1][j] - tmp[i][j-1] + tmp[i-1][j-1]); } swap(w, h); swap(h, ww); swap(ww, hh); } for(int i=1; i<=N; ++i) for(int j=1; j<=N; ++j) if(ans[i][j]) Report(i, j); }
#Verdict Execution timeMemoryGrader output
Fetching results...