# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
49498 | leejseo | 조개 줍기 (KOI17_shell) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int N, A[1501][1501], DP[1501][1501];
void init(){
scanf("%d", &N);
for (int i=0; i<N; i++){
for (int j=0; j<N; j++){
scanf("%d", &A[i][j]);
}
}
}
long long query(bool tf){
if (tf){
char a;
int i, j;
scanf("%c%d%d", &a, &i, &j);
A[i][j] += (a == 'U'? 1 : -1);
}
long long s;
for (int i=0; i<N; i++){
for (int j=0; j<N; j++){
DP[i][j] = A[i][j] + (i == 0? (j == 0? 0 : DP[i][j-1]) : (j == 0? DP[i-1][j] : max(DP[i-1][j], DP[i][j-1])));
s += DP[i][j]
}
}
return s;
}
int main(void){
init();
printf("%lld\n", query(false));
for (int i=0; i<N; i++) printf("%lld\n", query(true));
}