# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
227366 | cgiosy | 조개 줍기 (KOI17_shell) | C++17 | 125 ms | 9440 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
alignas(64) int A[1520][1520]{};
int main() {
ios::sync_with_stdio(0);cin.tie(0);
int N; long long s=0;
cin>>N;
for(int i=1; i<=N; i++) for(int j=1; j<=N; j++) {
cin>>A[i][j];
s+=A[i][j]+=max(A[i-1][j], A[i][j-1]);
}
for(int i=1; i<=N; i++) A[i][0]=-2e9;
cout<<s<<'\n';
for(int q=0; q<N; q++) {
char t;
int i, l;
cin>>t>>i>>l;
int r=l+1;
if(t=='U') while(l<r) {
while(r<=N && A[i-1][r]<A[i][r-1]+1) r++;
for(int j=l; j<r; j++) A[i][j]++;
s+=r-l;
if(++i>N) break;
while(l<r && A[i-1][l]<=A[i][l-1]) l++;
} else while(l<r) {
while(r<=N && A[i-1][r]<A[i][r-1]-1) r++;
for(int j=l; j<r; j++) A[i][j]--;
s-=r-l;
if(++i>N) break;
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |