#define DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}
// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
public:
template<typename T>
_Debug& operator,(T val) {
cout << val << endl;
return *this;
}
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif
// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back
// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;
// ---------- END OF TEMPLATE ----------
#include "treasure.h"
int arr1[100][100],arr2[100][100],arr3[100][100],arr4[100][100],ans[100][100];
int ask(int l,int r,int u,int d) {
return countTreasure(l+1,u+1,r+1,d+1) & 1;
}
void findTreasure(int N) {
int i,j;
int h = N/2+1;
for (i = h-1; i < N; i++) {
for (j = h-1; j < N; j++) {
arr1[i][j] = ask(0,i,0,j);
if ((i >= h) && (j >= h) && (arr1[i][j]^arr1[i-1][j]^arr1[i][j-1]^arr1[i-1][j-1])) ans[i][j] = 1;
}
}
for (i = h; i >= 0; i--) {
for (j = h-1; j < N; j++) {
if ((i < h) && (i > 0)) arr2[i][j] = ask(i,N-1,0,j);
else if (i == 0) arr2[i][j] = arr1[N-1][j];
else if (i == h) arr2[i][j] = arr1[N-1][j]^arr1[h-1][j];
if ((i < h) && (j >= h) && (arr2[i][j]^arr2[i+1][j]^arr2[i][j-1]^arr2[i+1][j-1])) ans[i][j] = 1;
}
}
for (i = h-1; i < N; i++) {
for (j = h; j >= 0; j--) {
if ((j < h) && (j > 0)) arr3[i][j] = ask(0,i,j,N-1);
else if (j == 0) arr3[i][j] = arr1[i][N-1];
else if (j == h) arr3[i][j] = arr1[i][N-1]^arr1[i][h-1];
if ((i >= h) && (j < h) && (arr3[i][j]^arr3[i-1][j]^arr3[i][j+1]^arr3[i-1][j+1])) ans[i][j] = 1;
}
}
for (i = h; i >= 0; i--) {
for (j = h; j >= 0; j--) {
if ((i > 0) && (i < h) && (j > 0) && (j < h)) arr4[i][j] = ask(i,N-1,j,N-1);
else if (i == 0) arr4[i][j] = arr3[N-1][j];
else if (j == 0) arr4[i][j] = arr2[i][N-1];
else if (i == h) arr4[i][j] = arr3[N-1][j]^arr3[h-1][j];
else if (j == h) arr4[i][j] = arr2[i][N-1]^arr2[i][h-1];
if ((i < h) && (j < h) && (arr4[i][j]^arr4[i+1][j]^arr4[i][j+1]^arr4[i+1][j+1])) ans[i][j] = 1;
}
}
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
if (ans[i][j]) Report(i+1,j+1);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct - N = 5, K = 289, score = 10 |
2 |
Correct |
2 ms |
376 KB |
Output is correct - N = 10, K = 4475, score = 10 |
3 |
Correct |
2 ms |
576 KB |
Output is correct - N = 15, K = 22289, score = 10 |
4 |
Correct |
2 ms |
576 KB |
Output is correct - N = 16, K = 28928, score = 10 |
5 |
Correct |
2 ms |
660 KB |
Output is correct - N = 55, K = 4005289, score = 10 |
6 |
Correct |
2 ms |
672 KB |
Output is correct - N = 66, K = 8305803, score = 10 |
7 |
Correct |
3 ms |
716 KB |
Output is correct - N = 77, K = 15383161, score = 10 |
8 |
Correct |
2 ms |
744 KB |
Output is correct - N = 88, K = 26244416, score = 10 |
9 |
Correct |
2 ms |
872 KB |
Output is correct - N = 99, K = 42032201, score = 10 |
10 |
Correct |
2 ms |
872 KB |
Output is correct - N = 100, K = 43760000, score = 10 |