#include <bits/stdc++.h>
using namespace std;
#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;
#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 1505
int n;
int a[MAXN][MAXN];
ll s[MAXN][MAXN];
ll dp() {
memset(s, 0, sizeof s);
ll res = 0;
REP (i, 1, n + 1) {
REP (j, 1, n + 1) {
s[i][j] = a[i][j] + max(s[i - 1][j], s[i][j - 1]);
res += s[i][j];
}
}
return res;
}
int main() {
scanf("%d", &n);
REP (i, 1, n + 1) {
REP (j, 1, n + 1) {
scanf("%d", &a[i][j]);
}
}
printf("%lld\n", dp());
REP (i, 0, n) {
char o; int r, c; scanf(" %c%d%d", &o, &r, &c);
if (o == 'U') {
a[r][c]++;
} else {
a[r][c]--;
}
printf("%lld\n", dp());
}
return 0;
}
/*
3
3 2 7
4 2 6
5 3 8
U 1 2
D 3 2
U 1 2
*/
Compilation message
shell.cpp: In function 'int main()':
shell.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
44 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
shell.cpp:47:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
47 | scanf("%d", &a[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~
shell.cpp:52:26: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | char o; int r, c; scanf(" %c%d%d", &o, &r, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
223 ms |
18448 KB |
Output is correct |
2 |
Correct |
227 ms |
18464 KB |
Output is correct |
3 |
Correct |
225 ms |
18464 KB |
Output is correct |
4 |
Correct |
217 ms |
18380 KB |
Output is correct |
5 |
Correct |
243 ms |
18444 KB |
Output is correct |
6 |
Correct |
227 ms |
18444 KB |
Output is correct |
7 |
Correct |
225 ms |
18500 KB |
Output is correct |
8 |
Correct |
234 ms |
18352 KB |
Output is correct |
9 |
Correct |
230 ms |
18444 KB |
Output is correct |
10 |
Correct |
227 ms |
18448 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2077 ms |
26728 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
223 ms |
18448 KB |
Output is correct |
2 |
Correct |
227 ms |
18464 KB |
Output is correct |
3 |
Correct |
225 ms |
18464 KB |
Output is correct |
4 |
Correct |
217 ms |
18380 KB |
Output is correct |
5 |
Correct |
243 ms |
18444 KB |
Output is correct |
6 |
Correct |
227 ms |
18444 KB |
Output is correct |
7 |
Correct |
225 ms |
18500 KB |
Output is correct |
8 |
Correct |
234 ms |
18352 KB |
Output is correct |
9 |
Correct |
230 ms |
18444 KB |
Output is correct |
10 |
Execution timed out |
2077 ms |
26728 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |