Submission #403693

#TimeUsernameProblemLanguageResultExecution timeMemory
403693joelau조개 줍기 (KOI17_shell)C++14
12 / 100
13 ms632 KiB
#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 (stderr)

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--;
      |                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...