# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63362 | bazsi700 | Treasure (different grader from official contest) (CEOI13_treasure2) | C++14 | 4 ms | 660 KiB |
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>
#include "treasure.h"
using namespace std;
#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL
//16:20
bool table[105][105];
int query(int r1, int c1, int r2, int c2) {
return countTreasure(r1,c1,r2,c2);
/*cout << r1 << " " << c1 << " " << r2 << " " << c2 << "\n" << flush;
int x;
cin >> x;
return x;*/
}
void solve(int r1, int c1, int r2, int c2, int cnt) {
if(cnt == 0) {
return;
}
if(r1 == r2 && c1 == c2) {
table[r1][c1] = true;
return;
}
if(r2-r1 > c2-c1) {
int mid = (r1+r2)/2;
int cn1 = query(r1,c1,mid,c2);
solve(r1,c1,mid,c2,cn1);
solve(mid+1,c1,r2,c2,cnt-cn1);
} else {
int mid = (c1+c2)/2;
int cn1 = query(r1,c1,r2,mid);
solve(r1,c1,r2,mid,cn1);
solve(r1,mid+1,r2,c2,cnt-cn1);
}
}
int cn[105][105];
void findTreasure(int n) {
if(n == 16 || n == 5) {
int x = query(1,1,n,n);
solve(1,1,n,n,x);
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(table[i][j]) {
Report(i,j);
}
}
}
} else {
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
cn[i][j] = query(1,1,i,j);
}
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= n; j++) {
if(cn[i][j]-(cn[i-1][j]+cn[i][j-1]-cn[i-1][j-1])) {
Report(i,j);
}
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |