Submission #227371

# Submission time Handle Problem Language Result Execution time Memory
227371 2020-04-27T07:57:33 Z cgiosy None (KOI17_shell) C++17
46 / 100
2000 ms 12564 KB
#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]);
	}
	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;
			while(l<r && A[i-1][l]<A[i][l-1]) l++;
		}
		cout<<s<<'\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 6 ms 896 KB Output is correct
4 Correct 7 ms 896 KB Output is correct
5 Correct 6 ms 768 KB Output is correct
6 Correct 6 ms 896 KB Output is correct
7 Correct 6 ms 772 KB Output is correct
8 Correct 6 ms 744 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 6 ms 744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 185 ms 11828 KB Output is correct
2 Correct 184 ms 12444 KB Output is correct
3 Correct 225 ms 9464 KB Output is correct
4 Correct 152 ms 9332 KB Output is correct
5 Correct 209 ms 9268 KB Output is correct
6 Correct 195 ms 9336 KB Output is correct
7 Correct 154 ms 9208 KB Output is correct
8 Correct 171 ms 9304 KB Output is correct
9 Correct 173 ms 9216 KB Output is correct
10 Correct 165 ms 9216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 6 ms 896 KB Output is correct
4 Correct 7 ms 896 KB Output is correct
5 Correct 6 ms 768 KB Output is correct
6 Correct 6 ms 896 KB Output is correct
7 Correct 6 ms 772 KB Output is correct
8 Correct 6 ms 744 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 185 ms 11828 KB Output is correct
11 Correct 184 ms 12444 KB Output is correct
12 Correct 225 ms 9464 KB Output is correct
13 Correct 152 ms 9332 KB Output is correct
14 Correct 209 ms 9268 KB Output is correct
15 Correct 195 ms 9336 KB Output is correct
16 Correct 154 ms 9208 KB Output is correct
17 Correct 171 ms 9304 KB Output is correct
18 Correct 173 ms 9216 KB Output is correct
19 Correct 165 ms 9216 KB Output is correct
20 Correct 258 ms 9660 KB Output is correct
21 Correct 191 ms 12564 KB Output is correct
22 Correct 268 ms 9252 KB Output is correct
23 Execution timed out 2082 ms 9316 KB Time limit exceeded
24 Halted 0 ms 0 KB -