제출 #791788

#제출 시각아이디문제언어결과실행 시간메모리
791788Dan4LifeLand of the Rainbow Gold (APIO17_rainbow)C++17
0 / 100
1 ms596 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() #define all(a) begin(a), end(a) const int mxN = (int)2e5+10; vector<int> blocked[3]; int pr[3][mxN], a[2][mxN]; void init(int R, int C, int x, int y, int M, char *s) { x--, y--; a[x][y]=1; for(int i = 0; i < M; i++){ if(s[i]=='N') x--; if(s[i]=='S') x++; if(s[i]=='W') y--; if(s[i]=='E') y++; a[x][y] = 1; } for(int i = 0; i < 2; i++){ for(int j = 0; j < C; j++){ if(a[i][j]) blocked[i].pb(j); if(!i and (a[0][j]&a[1][j])) blocked[2].pb(j); } } for(int i = 0; i < 3; i++) for(int j = 1; j < sz(blocked[i]); j++) pr[i][j] = pr[i][j-1]+(blocked[i][j]!=(blocked[i][j-1]+1)); } int colour(int r1, int c1, int r2, int c2) { r1--,c1--,r2--,c2--; int ind = (r1==r2?r1:2); int pos1 = lower_bound(all(blocked[ind]),c1)-begin(blocked[ind]); int pos2 = upper_bound(all(blocked[ind]),c2)-begin(blocked[ind])-1; if(pos1==sz(blocked[ind]) or blocked[ind][pos1]>c2) return 1; int tot = (c1<blocked[ind][pos1])+(c1<blocked[ind][pos1]); return tot+pr[ind][pos2]-pr[ind][pos1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...