제출 #65535

#제출 시각아이디문제언어결과실행 시간메모리
65535IvanC보물 찾기 (CEOI13_treasure2)C++17
59 / 100
3 ms788 KiB
#include "treasure.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 110; static int matriz[MAXN][MAXN]; void solve(int lx,int rx,int ly,int ry,int divide_x,int cnt){ if(cnt == 0) return; if((rx - lx + 1)*(ry - ly + 1) == cnt){ for(int i = lx;i<=rx;i++){ for(int j = ly;j <= ry;j++){ matriz[i][j] = 1; } } return; } if(divide_x){ int mx = (lx + rx)/2; int qt = countTreasure(lx,ly,mx,ry); solve(lx,mx,ly,ry,0,qt); solve(mx+1,rx,ly,ry,0,cnt - qt); } else{ int my = (ly + ry)/2; int qt = countTreasure(lx,ly,rx,my); solve(lx,rx,ly,my,1,qt); solve(lx,rx,my+1,ry,1,cnt - qt); } } void findTreasure(int N){ memset(matriz,0,sizeof(matriz)); int cnt = countTreasure(1, 1, N, N); solve(1,N,1,N,1,cnt); for(int i = 1;i<=N;i++){ for(int j = 1;j<=N;j++){ if(matriz[i][j]) Report(i,j); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...