#pragma GCC optimize("O2")
#include <treasure.h>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define countbits __builtin_popcount
#define beg0 __builtin_clz
#define terminal0 __builtin_ctz
#define mod 1e9+7
void setIO(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
}
void setIO(string f){
freopen((f+".in").c_str(),"r",stdin);
freopen((f+".out").c_str(),"w",stdout);
setIO();
}
int n;
vector<pair<int,int>> spots;
void grid(int bx, int by, int ux, int uy){
int cells=countTreasure(bx,by,ux,uy);
if (cells==0) return;
if (bx>=ux && by>=uy){
spots.pb({bx,by});return;
}
if ((bx-ux)%2==0){
grid(bx,by,(ux+bx)/2,(uy+by)/2);//top left subgrid
grid((ux+bx)/2,by,ux,(uy+by)/2);//top right subgrid
grid(bx,(uy+by)/2,(ux+bx)/2,uy);//bottom left subgrid
grid((ux+bx)/2,(uy+by)/2,ux,uy);//bottom right subgrid
}else{
grid(bx,by,(ux+bx)/2,(uy+by)/2);
grid((ux+bx)/2+1,by,ux,(uy+by)/2);
grid(bx,(uy+by)/2+1,(ux+bx)/2,uy);
grid((ux+bx)/2+1,(uy+by)/2+1,ux,uy);
}
}
void findTreasure(int N){
n=N;
int grid[N][N];
for (int i=0;i<N;i++) for (int j=0;j<N;j++) grid[i][j]=1e9;
for (int i=N-1;i>=0;i--){
for (int j=N-1;j>=0;j--){
grid[i][j]=countTreasure(1,1,i+1,j+1);
}
}
for (int i=0;i<N;i++){
for (int j=0;j<N;j++){
int res = grid[i][j];
if (i) res-=grid[i-1][j];
if (j) res-=grid[i][j-1];
if (i&&j) res+=grid[i-1][j-1];
if (res==1) Report(i+1,j+1);
}
}
}
Compilation message
treasure.cpp: In function 'void setIO(std::string)':
treasure.cpp:20:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | freopen((f+".in").c_str(),"r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
treasure.cpp:21:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
21 | freopen((f+".out").c_str(),"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
204 KB |
Output is partially correct - N = 5, K = 425, score = 8 |
2 |
Partially correct |
0 ms |
204 KB |
Output is partially correct - N = 10, K = 7075, score = 4 |
3 |
Partially correct |
1 ms |
204 KB |
Output is partially correct - N = 15, K = 36450, score = 4 |
4 |
Partially correct |
0 ms |
204 KB |
Output is partially correct - N = 16, K = 47296, score = 4 |
5 |
Partially correct |
0 ms |
332 KB |
Output is partially correct - N = 55, K = 6782050, score = 4 |
6 |
Partially correct |
1 ms |
332 KB |
Output is partially correct - N = 66, K = 14090571, score = 4 |
7 |
Partially correct |
1 ms |
332 KB |
Output is partially correct - N = 77, K = 26140961, score = 4 |
8 |
Partially correct |
1 ms |
332 KB |
Output is partially correct - N = 88, K = 44642224, score = 4 |
9 |
Partially correct |
1 ms |
332 KB |
Output is partially correct - N = 99, K = 71566902, score = 4 |
10 |
Partially correct |
1 ms |
332 KB |
Output is partially correct - N = 100, K = 74507500, score = 4 |