#include "treasure.h"
#include <cstdio>
#include <cassert>
#include <iostream>
using namespace std;
int dp[105][105];
int chk[105][105];
int arr[105][105];
int g(int y1,int x1,int y2,int x2){
return dp[y2][x2] - dp[y1-1][x2] - dp[y2][x1-1] + dp[y1-1][x1-1];
}
/*
void Report(int i,int j){
assert(arr[i][j]);
}
int countTreasure(int y1,int x1,int y2,int x2){
int res = 0;
for(int i=y1;i<=y2;i++){
for(int j=x1;j<=x2;j++){
res += arr[i][j];
}
}
return res;
}
*/
void findTreasure (int N) {
//if(cnt > 0) Report (1, 1);
if(N <= 5){
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
int cnt = countTreasure(i, j, i, j);
chk[i][j] = 1;
}
}
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
if(chk[i][j]) Report(i,j);
}
}
return;
}
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
int cnt = countTreasure(1,1,i,j);
dp[i][j] = cnt;
}
}
/*
cout<<endl;
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
cout<<g(i,j,i,j)<<' ';
}
cout<<endl;
}
*/
for(int i=1;i<=N;i++){
for(int j=1;j<=N;j++){
if(g(i,j,i,j)){
Report(i,j);
}
}
}
}
Compilation message
grader.c: In function 'int main()':
grader.c:63:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
my_assert(strlen(A[i]+1) == N, "each line of the map must contain N zeroes or ones (before loop)");
^
treasure.cpp: In function 'void findTreasure(int)':
treasure.cpp:32:21: warning: unused variable 'cnt' [-Wunused-variable]
int cnt = countTreasure(i, j, i, j);
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
2212 KB |
Invalid Access |
2 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 10, K = 7075, score = 4 |
3 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 15, K = 36450, score = 4 |
4 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 16, K = 47296, score = 4 |
5 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 55, K = 6782050, score = 4 |
6 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 66, K = 14090571, score = 4 |
7 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 77, K = 26140961, score = 4 |
8 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 88, K = 44642224, score = 4 |
9 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 99, K = 71566902, score = 4 |
10 |
Partially correct |
0 ms |
2212 KB |
Output is partially correct - N = 100, K = 74507500, score = 4 |