Submission #147707


Source Code Expand

#include <cstdio>
#include <algorithm>

using namespace std;

int main(void)
{
  int n,q,p;
  int d[55][55] = {};
  int s[55][55] = {};
  scanf("%d",&n);
  for( int i = 0; i < n; i++ ) {
    for( int j = 0; j < n; j++ ) scanf("%d",d[i]+j);
  }
  for( int i = 1; i <= n; i++ ) {
    for( int j = 0; j < n; j++ ) s[i][j+1] += s[i][j]+d[i-1][j];
  }
  for( int i = 0; i < n; i++ ) {
    for( int j = 0; j <= n; j++ ) s[i+1][j] += s[i][j];
  }
  /*
  for( int i = 0; i <= n+1; i++ ) {
    for( int j = 0; j <= n+1; j++ ) printf("%d ",s[i][j]);
    puts("");
  }
  */
  int rp[2555] = {};
  for( int ii = 1; ii <= n*n; ii++ ) {
    int res = 0;
    for( int i = 1; i*i <= ii; i++ ) {
      if( ii%i == 0 ) {
        int a = i;
        int b = ii/i;
        for( int y = 0; y < n; y++ ) {
          for( int x = 0; x < n; x++ ) {
            //printf("(%d,%d) (%d,%d)\n",x,y,min(n,x+b),min(n,y+a));
            res = max({
                res,
                  s[min(n,y+a)][min(n,x+b)]
                  -s[min(n,y+a)][x]
                  -s[y][min(n,x+b)]
                  +s[y][x],
                  s[min(n,y+b)][min(n,x+a)]
                  -s[min(n,y+b)][x]
                  -s[y][min(n,x+a)]
                  +s[y][x],
              });
          }
        }
      }
    }
    //printf("%d:%d\n",ii,res);
    rp[ii] = max(res,rp[ii-1]);
  }
  scanf("%d",&q);
  while( q-- ) {
    scanf("%d",&p);
    printf("%d\n",rp[p]);
  }
  return 0;
}

Submission Info

Submission Time
Task D - おいしいたこ焼きの焼き方
User roxion1377
Language C++11 (GCC 4.8.1)
Score 100
Code Size 1508 Byte
Status AC
Exec Time 219 ms
Memory 804 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:11:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
                 ^
./Main.cpp:13:52: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for( int j = 0; j < n; j++ ) scanf("%d",d[i]+j);
                                                    ^
./Main.cpp:55:17: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q);
                 ^
./Main.cpp:57:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&p);
                   ^

Judge Result

Set Name Subtask1 Subtask2
Score / Max Score 50 / 50 50 / 50
Status
AC × 18
AC × 20
Set Name Test Cases
Subtask1 sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Subtask2 rand0.txt, rand1.txt, rand2.txt, rand3.txt, rand4.txt, rand_max0.txt, rand_max1.txt, rand_max2.txt, rand_max3.txt, rand_max4.txt, s1.txt, s2.txt, sub0.txt, sub1.txt, sub2.txt, sub_rand_max0.txt, sub_rand_max1.txt, sub_rand_max2.txt, sub_rand_max3.txt, sub_rand_min0.txt
Case Name Status Exec Time Memory
rand0.txt AC 124 ms 672 KB
rand1.txt AC 75 ms 800 KB
rand2.txt AC 114 ms 676 KB
rand3.txt AC 37 ms 804 KB
rand4.txt AC 19 ms 796 KB
rand_max0.txt AC 219 ms 676 KB
rand_max1.txt AC 218 ms 668 KB
rand_max2.txt AC 216 ms 800 KB
rand_max3.txt AC 217 ms 804 KB
rand_max4.txt AC 217 ms 800 KB
s1.txt AC 20 ms 800 KB
s2.txt AC 19 ms 800 KB
sub0.txt AC 19 ms 676 KB
sub1.txt AC 20 ms 804 KB
sub2.txt AC 19 ms 800 KB
sub_rand_max0.txt AC 20 ms 800 KB
sub_rand_max1.txt AC 19 ms 800 KB
sub_rand_max2.txt AC 19 ms 752 KB
sub_rand_max3.txt AC 18 ms 676 KB
sub_rand_min0.txt AC 19 ms 804 KB