Submission #403467

# Submission time Handle Problem Language Result Execution time Memory
403467 2021-05-13T08:07:24 Z errorgorn None (KOI17_shell) C++17
46 / 100
2000 ms 18884 KB
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl

#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define lb lower_bound
#define ub upper_bound

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
//change less to less_equal for non distinct pbds, but erase will bug

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
int arr[1505][1505];
int brr[1505][1505];
ll ans=0;

void dfs(int i,int j){
	if (i!=n){
		int temp=max(brr[i][j],brr[i+1][j-1])+arr[i+1][j];
		if (brr[i+1][j]!=temp){
			ans-=brr[i+1][j];
			ans+=temp;
			brr[i+1][j]=temp;
			dfs(i+1,j);
		}
	}
	if (j!=n){
		int temp=max(brr[i][j],brr[i-1][j+1])+arr[i][j+1];
		if (brr[i][j+1]!=temp){
			ans-=brr[i][j+1];
			ans+=temp;
			brr[i][j+1]=temp;
			dfs(i,j+1);
		}
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin.exceptions(ios::badbit | ios::failbit);
	
	cin>>n;
	rep(x,1,n+1) rep(y,1,n+1) cin>>arr[x][y];
	rep(x,1,n+1) rep(y,1,n+1) {
		brr[x][y]=max(brr[x-1][y],brr[x][y-1])+arr[x][y];
		ans+=brr[x][y];
	}
	cout<<ans<<endl;
	
	char c;
	int a,b;
	
	rep(x,0,n){
		cin>>c>>a>>b;
		
		if (c=='U'){
			arr[a][b]++;
			brr[a][b]++;
			ans++;
		}
		else{
			arr[a][b]--;
			brr[a][b]--;
			ans--;
		}
		
		dfs(a,b);
		
		cout<<ans<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1100 KB Output is correct
2 Correct 3 ms 1216 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 14 ms 1252 KB Output is correct
5 Correct 10 ms 1248 KB Output is correct
6 Correct 13 ms 1248 KB Output is correct
7 Correct 3 ms 1228 KB Output is correct
8 Correct 4 ms 1228 KB Output is correct
9 Correct 3 ms 1228 KB Output is correct
10 Correct 2 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 195 ms 17908 KB Output is correct
2 Correct 193 ms 18652 KB Output is correct
3 Correct 756 ms 18752 KB Output is correct
4 Correct 176 ms 18756 KB Output is correct
5 Correct 174 ms 18724 KB Output is correct
6 Correct 190 ms 18756 KB Output is correct
7 Correct 192 ms 18756 KB Output is correct
8 Correct 173 ms 18876 KB Output is correct
9 Correct 170 ms 18772 KB Output is correct
10 Correct 170 ms 18684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1100 KB Output is correct
2 Correct 3 ms 1216 KB Output is correct
3 Correct 5 ms 1236 KB Output is correct
4 Correct 14 ms 1252 KB Output is correct
5 Correct 10 ms 1248 KB Output is correct
6 Correct 13 ms 1248 KB Output is correct
7 Correct 3 ms 1228 KB Output is correct
8 Correct 4 ms 1228 KB Output is correct
9 Correct 3 ms 1228 KB Output is correct
10 Correct 195 ms 17908 KB Output is correct
11 Correct 193 ms 18652 KB Output is correct
12 Correct 756 ms 18752 KB Output is correct
13 Correct 176 ms 18756 KB Output is correct
14 Correct 174 ms 18724 KB Output is correct
15 Correct 190 ms 18756 KB Output is correct
16 Correct 192 ms 18756 KB Output is correct
17 Correct 173 ms 18876 KB Output is correct
18 Correct 170 ms 18772 KB Output is correct
19 Correct 170 ms 18684 KB Output is correct
20 Correct 2 ms 1228 KB Output is correct
21 Correct 228 ms 18612 KB Output is correct
22 Correct 267 ms 18884 KB Output is correct
23 Correct 250 ms 18856 KB Output is correct
24 Execution timed out 2088 ms 18756 KB Time limit exceeded
25 Halted 0 ms 0 KB -