#include <bits/stdc++.h>
#include "treasure.h"
using namespace std;
int S[101][101]; // S[a][b] a행 b열까지합
void findTreasure(int N){
static int S[101][101]; // S[a][b] a행 b열까지합
int L,R,U,D,tmp,res;
int a;
if(a%2) a= N/2+1;
else a=(N+1)/2;
int b=(N+1)/2;
L=1,R=N,U=1,D=N;
int x = countTreasure(1,L,N,R);
tmp = x;
for(U=2,D=N;U<=a;U++){
res = countTreasure(U,L,D,R);
if(L==1){
S[U-1][R] = tmp - res;
}
else S[U-1][L-1] = S[U-1][N] - (tmp - res);
tmp = res;
}
tmp = x;
for(U=1,D=N-1;D>=b;D--){
res = countTreasure(U,L,D,R);
if(L==1) S[D+1][R] = tmp - res;
else S[D+1][L-1] = S[D+1][N] - (tmp - res);
tmp = res;
}
int t=0;
for(int i=1; i<=D; i++) t+=S[i][R];
if(L==1) S[D+1][R] = tmp - t;
else S[D+1][L-1] = S[D+1][N] - (tmp - t);
for(L=2,R=N;L<=a;L++){
int x = countTreasure(1,L,N,R);
tmp = x;
for(U=2,D=N;U<=a;U++){
res = countTreasure(U,L,D,R);
if(L==1) S[U-1][R] = tmp - res;
else S[U-1][L-1] = S[U-1][N] - (tmp - res);
tmp = res;
}
tmp = x;
for(U=1,D=N-1;D>=b;D--){
res = countTreasure(U,L,D,R);
if(L==1) S[D+1][R] = tmp - res;
else S[D+1][L-1] = S[D+1][N] - (tmp - res);
tmp = res;
}
int t=0;
for(int i=1; i<=D; i++) t+=S[i][R]-S[i][L-1];
if(L==1) S[D+1][R] = tmp - t;
else S[D+1][L-1] = S[D+1][N] - (tmp - t);
}
for(L=1,R=N-1;R>=b;R--){
int x = countTreasure(1,L,N,R);
tmp = x;
for(U=2,D=N;U<=a;U++){
res = countTreasure(U,L,D,R);
if(L==1) S[U-1][R] = tmp - res;
else S[U-1][L-1] = S[U-1][N] - (tmp - res);
tmp = res;
}
tmp = x;
for(U=1,D=N-1;D>=b;D--){
res = countTreasure(U,L,D,R);
if(L==1){
S[D+1][R] = tmp - res;
}
else S[D+1][L-1] = S[D+1][N] - (tmp - res);
tmp = res;
}
int t=0;
for(int i=1; i<=D; i++) t+=S[i][R];
if(L==1) S[D+1][R] = tmp - t;
else S[D+1][L-1] = S[D+1][N] - (tmp - t);
}
for(int x=1; x<=N; x++)
for(int y=1; y<=N; y++){
if(S[y][x]!=S[y][x-1]){
Report(y,x);
}
}
}
Compilation message
treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:10:11: warning: 'a' is used uninitialized in this function [-Wuninitialized]
if(a%2) a= N/2+1;
^
# |
Verdict |
Execution time |
Memory |
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 |
292 KB |
Output is correct - N = 15, K = 22289, score = 10 |
4 |
Correct |
2 ms |
376 KB |
Output is correct - N = 16, K = 28928, score = 10 |
5 |
Correct |
2 ms |
376 KB |
Output is correct - N = 55, K = 4005289, score = 10 |
6 |
Correct |
2 ms |
376 KB |
Output is correct - N = 66, K = 8305803, score = 10 |
7 |
Correct |
2 ms |
376 KB |
Output is correct - N = 77, K = 15383161, score = 10 |
8 |
Correct |
2 ms |
376 KB |
Output is correct - N = 88, K = 26244416, score = 10 |
9 |
Correct |
2 ms |
376 KB |
Output is correct - N = 99, K = 42032201, score = 10 |
10 |
Correct |
2 ms |
376 KB |
Output is correct - N = 100, K = 43760000, score = 10 |