#include<bits/stdc++.h>
#include "treasure.h"
using namespace std;
const int nmax=100+42;
int n;
/*
int countTreasure(int x1,int y1,int x2,int y2)
{
cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<endl;
int ret;
cin>>ret;
return ret;
}
void Report(int i,int j)
{
cout<<"treasure: "<<i<<" "<<j<<endl;
}
*/
map< pair< pair<int,int>, pair<int,int> > ,int> seen;
int ask(int x1,int y1,int x2,int y2)
{
if(x1>x2||y1>y2)return 0;
pair< pair<int,int>, pair<int,int> > state={{x1,y1},{x2,y2}};
if(seen.count(state)==0)seen[state]=countTreasure(x1,y1,x2,y2);
return seen[state];
}
int pref[nmax][nmax];
void findTreasure(int N)
{
n=N;
for(int i=n;i>=1;i--)
for(int j=n;j>=1;j--)
{
if(i>n/2&&j>n/2)pref[i][j]=ask(1,1,i,j);
else if(i>n/2)pref[i][j]=pref[i][n]-ask(1,j+1,i,n);
else if(i<=n/2&&j>n/2)pref[i][j]=pref[n][j]-ask(i+1,1,n,j);
else pref[i][j]=pref[i][n]+pref[n][j]+ask(i+1,j+1,n,n)-pref[n][n];
}
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(pref[i][j]-pref[i-1][j]-pref[i][j-1]+pref[i-1][j-1])Report(i,j);
}
/*
int main()
{
findTreasure(2);
}
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct - N = 5, K = 289, score = 10 |
2 |
Correct |
5 ms |
384 KB |
Output is correct - N = 10, K = 4475, score = 10 |
3 |
Correct |
5 ms |
384 KB |
Output is correct - N = 15, K = 22289, score = 10 |
4 |
Correct |
5 ms |
384 KB |
Output is correct - N = 16, K = 28928, score = 10 |
5 |
Correct |
6 ms |
640 KB |
Output is correct - N = 55, K = 4005289, score = 10 |
6 |
Correct |
6 ms |
640 KB |
Output is correct - N = 66, K = 8305803, score = 10 |
7 |
Correct |
7 ms |
768 KB |
Output is correct - N = 77, K = 15383161, score = 10 |
8 |
Correct |
7 ms |
896 KB |
Output is correct - N = 88, K = 26244416, score = 10 |
9 |
Correct |
9 ms |
1024 KB |
Output is correct - N = 99, K = 42032201, score = 10 |
10 |
Correct |
8 ms |
1024 KB |
Output is correct - N = 100, K = 43760000, score = 10 |