# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
403569 | tqbfjotld | 조개 줍기 (KOI17_shell) | C++14 | 2041 ms | 169520 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int vals[1505][1505];
int val2[1505][1505];
int num[1505][1505];
set<pair<int,int> > vis;
int curans = 0;
int n;
void decr(int x, int y){
int t=vis.size();
vis.insert({x,y});
if (vis.size()==t) return;
val2[x][y]--;
curans--;
if (x!=n){
if (vals[x+1][y]+max(val2[x][y],y!=1?val2[x+1][y-1]:0)<val2[x+1][y]){
decr(x+1,y);
}
}
if (y!=n){
if (vals[x][y+1]+max(val2[x][y],x!=1?val2[x-1][y+1]:0)<val2[x][y+1]){
decr(x,y+1);
}
}
}
main(){
scanf("%lld",&n);
if (n<=100){
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
scanf("%lld",&vals[x][y]);
}
}
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
if (x==0){
if (y==0) val2[x][y] = vals[x][y];
else val2[x][y] = vals[x][y]+val2[x][y-1];
}
else if (y==0){
val2[x][y] = vals[x][y]+val2[x-1][y];
}
else{
val2[x][y] = vals[x][y]+max(val2[x-1][y],val2[x][y-1]);
}
}
}
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
curans += val2[x][y];
}
}
printf("%lld\n",curans);
for (int x = 0; x<n; x++){
char c;
int a,b;
scanf(" %c%lld%lld",&c,&a,&b);
if (c=='U'){
vals[a-1][b-1]++;
}
else{
vals[a-1][b-1]--;
}
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
if (x==0){
if (y==0) val2[x][y] = vals[x][y];
else val2[x][y] = vals[x][y]+val2[x][y-1];
}
else if (y==0){
val2[x][y] = vals[x][y]+val2[x-1][y];
}
else{
val2[x][y] = vals[x][y]+max(val2[x-1][y],val2[x][y-1]);
}
}
}
int curans = 0;
for (int x = 0; x<n; x++){
for (int y = 0; y<n; y++){
curans += val2[x][y];
}
}
printf("%lld\n",curans);
}
return 0;
}
for (int x = 1; x<=n; x++){
for (int y = 1; y<=n; y++){
scanf("%lld",&vals[x][y]);
}
}
for (int x = 1; x<=n; x++){
for (int y = 1; y<=n; y++){
if (x==1){
if (y==1) val2[x][y] = vals[x][y];
else val2[x][y] = vals[x][y]+val2[x][y-1];
}
else if (y==1){
val2[x][y] = vals[x][y]+val2[x-1][y];
}
else{
val2[x][y] = vals[x][y]+max(val2[x-1][y],val2[x][y-1]);
}
curans += val2[x][y];
}
}
printf("%lld\n",curans);
for(int x = 0; x<n; x++){
char c;
int a,b;
scanf(" %c%lld%lld",&c,&a,&b);
vals[a][b]--;
vis.clear();
decr(a,b);
printf("%lld\n",curans);
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |