답안 #403693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
403693 2021-05-13T11:21:02 Z joelau 조개 줍기 (KOI17_shell) C++14
12 / 100
13 ms 632 KB
#include <bits/stdc++.h>
using namespace std;

int N, A[100][100], dp[100][100];

int main() {
    scanf("%d", &N);
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) scanf("%d", &A[i][j]);
    long long ans = 0;
    for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
        dp[i][j] = 0;
        if (i != 0) dp[i][j] = max(dp[i][j],dp[i-1][j]);
        if (j != 0) dp[i][j] = max(dp[i][j],dp[i][j-1]);
        dp[i][j] += A[i][j];
        ans += dp[i][j];
    }
    printf("%lld\n", ans);
    for (int a = 0; a < N; ++a) {
        char c; int x,y; scanf(" %c %d %d", &c, &x, &y), x--, y--;
        if (c == 'U') A[x][y]++;
        else A[x][y]--;
        long long ans = 0;
        for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) {
            dp[i][j] = 0;
            if (i != 0) dp[i][j] = max(dp[i][j],dp[i-1][j]);
            if (j != 0) dp[i][j] = max(dp[i][j],dp[i][j-1]);
            dp[i][j] += A[i][j];
            ans += dp[i][j];
        }
        printf("%lld\n", ans);
    }

    return 0;
}

Compilation message

shell.cpp: In function 'int main()':
shell.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |     scanf("%d", &N);
      |     ~~~~~^~~~~~~~~~
shell.cpp:8:66: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) scanf("%d", &A[i][j]);
      |                                                             ~~~~~^~~~~~~~~~~~~~~~
shell.cpp:19:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         char c; int x,y; scanf(" %c %d %d", &c, &x, &y), x--, y--;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 7 ms 332 KB Output is correct
5 Correct 7 ms 316 KB Output is correct
6 Correct 6 ms 332 KB Output is correct
7 Correct 6 ms 312 KB Output is correct
8 Correct 6 ms 332 KB Output is correct
9 Correct 7 ms 392 KB Output is correct
10 Correct 7 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 13 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 332 KB Output is correct
2 Correct 6 ms 332 KB Output is correct
3 Correct 6 ms 332 KB Output is correct
4 Correct 7 ms 332 KB Output is correct
5 Correct 7 ms 316 KB Output is correct
6 Correct 6 ms 332 KB Output is correct
7 Correct 6 ms 312 KB Output is correct
8 Correct 6 ms 332 KB Output is correct
9 Correct 7 ms 392 KB Output is correct
10 Incorrect 13 ms 632 KB Output isn't correct
11 Halted 0 ms 0 KB -