Submission #227372

# Submission time Handle Problem Language Result Execution time Memory
227372 2020-04-27T07:58:50 Z cgiosy None (KOI17_shell) C++17
46 / 100
2000 ms 17948 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("arch=haswell")

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 6 ms 768 KB Output is correct
2 Correct 6 ms 768 KB Output is correct
3 Correct 6 ms 768 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 6 ms 768 KB Output is correct
6 Correct 6 ms 848 KB Output is correct
7 Correct 6 ms 768 KB Output is correct
8 Correct 7 ms 768 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 142 ms 9208 KB Output is correct
2 Correct 147 ms 10716 KB Output is correct
3 Correct 213 ms 9268 KB Output is correct
4 Correct 146 ms 9296 KB Output is correct
5 Correct 236 ms 9220 KB Output is correct
6 Correct 176 ms 9240 KB Output is correct
7 Correct 139 ms 9284 KB Output is correct
8 Correct 153 ms 9268 KB Output is correct
9 Correct 164 ms 9212 KB Output is correct
10 Correct 196 ms 9336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 768 KB Output is correct
2 Correct 6 ms 768 KB Output is correct
3 Correct 6 ms 768 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 6 ms 768 KB Output is correct
6 Correct 6 ms 848 KB Output is correct
7 Correct 6 ms 768 KB Output is correct
8 Correct 7 ms 768 KB Output is correct
9 Correct 6 ms 768 KB Output is correct
10 Correct 142 ms 9208 KB Output is correct
11 Correct 147 ms 10716 KB Output is correct
12 Correct 213 ms 9268 KB Output is correct
13 Correct 146 ms 9296 KB Output is correct
14 Correct 236 ms 9220 KB Output is correct
15 Correct 176 ms 9240 KB Output is correct
16 Correct 139 ms 9284 KB Output is correct
17 Correct 153 ms 9268 KB Output is correct
18 Correct 164 ms 9212 KB Output is correct
19 Correct 196 ms 9336 KB Output is correct
20 Correct 277 ms 13140 KB Output is correct
21 Correct 222 ms 14712 KB Output is correct
22 Correct 232 ms 15224 KB Output is correct
23 Execution timed out 2008 ms 17948 KB Time limit exceeded
24 Halted 0 ms 0 KB -