답안 #197825

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197825 2020-01-23T14:08:39 Z Ruxandra985 Maxcomp (info1cup18_maxcomp) C++14
100 / 100
199 ms 13448 KB
#include <cstdio>
#include <iostream>
using namespace std;
int n , m , a[1010][1010] , d[1010];
int solve (){
    int sol , i , j;
    sol = -2000000000;

    for (j=0;j<=m;j++)
        d[j] = 2000000000;

    for (i=1;i<=n;i++){
        for (j=1;j<=m;j++){

            d[j] = min( min(d[j-1] , d[j]) , a[i][j] - i - j );

            sol = max (sol , a[i][j] - d[j] - i - j - 1);

        }
    }
    return sol;

}
int main()
{
    FILE *fin = stdin;
    FILE *fout = stdout;
    int i , j , sol , st , dr;
    fscanf (fin,"%d%d",&n,&m);
    for (i=1;i<=n;i++){
        for (j=1;j<=m;j++){
            fscanf (fin,"%d",&a[i][j]);
        }
    }
    sol = solve();
    for (i=1;i<=n;i++){
        st = 1;
        dr = m;
        while (st < dr){
            swap(a[i][st] , a[i][dr]);
            st++;
            dr--;
        }
    }
    sol = max (sol , solve());


    for (i=1;i<=m;i++){
        st = 1;
        dr = n;
        while (st < dr){
            swap(a[st][i] , a[dr][i]);
            st++;
            dr--;
        }
    }
    sol = max (sol , solve());

    for (i=1;i<=n;i++){
        st = 1;
        dr = m;
        while (st < dr){
            swap(a[i][st] , a[i][dr]);
            st++;
            dr--;
        }
    }
    sol = max (sol , solve());

    fprintf (fout,"%d",sol);
    return 0;
}

Compilation message

maxcomp.cpp: In function 'int main()':
maxcomp.cpp:29:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%d%d",&n,&m);
     ~~~~~~~^~~~~~~~~~~~~~~~~~
maxcomp.cpp:32:20: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             fscanf (fin,"%d",&a[i][j]);
             ~~~~~~~^~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 1 ms 376 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 3 ms 504 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 3 ms 504 KB Output is correct
18 Correct 197 ms 12780 KB Output is correct
19 Correct 198 ms 12792 KB Output is correct
20 Correct 180 ms 12416 KB Output is correct
21 Correct 199 ms 12776 KB Output is correct
22 Correct 197 ms 12760 KB Output is correct
23 Correct 195 ms 12836 KB Output is correct
24 Correct 159 ms 13448 KB Output is correct