Submission #738316

# Submission time Handle Problem Language Result Execution time Memory
738316 2023-05-08T12:51:10 Z myrcella Land of the Rainbow Gold (APIO17_rainbow) C++17
12 / 100
85 ms 4924 KB
//by szh
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
 
#include "rainbow.h"
 
const int maxn = 5e6+10;
 
const int dx[4] = {0,-1,1,0}, dy[4] = {1,0,0,-1};
int grid[3][maxn];
int r,c;
 
vector <pii> range[3];
 
void init(int R, int C, int sr, int sc, int M, char *S) {
	r = R, c = C;
	grid[sr][sc] = 1;
	rep(i,0,M) {
		if (S[i]=='S') sr++;
		else if (S[i]=='E') sc++;
		else if (S[i]=='W') sc--;
		else sr--;
		grid[sr][sc] = 1;
	}
  	int start;
	rep(k,1,3) {
      	start = 1;
		rep(i,1,C+1) {
			if (grid[k][i]==1) {
				if (start < i) range[k].pb({start,i-1});
				start = i+1;
			}
		}
		if (start<=C) range[k].pb({start,C});
	}
  	start = 1;
	rep(i,1,C+1) {
		if (grid[2][i]==1 and grid[1][i]==1) {
			if (start < i) range[0].pb({start,i-1});
			start = i+1;
		}
	}
	if (start<=C) range[0].pb({start,C});
}
 
int colour(int ar, int ac, int br, int bc) {
	if (ar==1 and br==1) {
		int tmp = upper_bound(ALL(range[1]),MP(bc,mod))-range[1].begin();
		tmp -= lower_bound(ALL(range[1]),MP(ac,-1))-range[1].begin();
		int id = lower_bound(ALL(range[1]),MP(ac,-1))-range[1].begin();
		if (!range[1].empty() and id!=0 and range[1][id-1].se>=ac) tmp++;
		return tmp;
	}
	if (ar==2 and br==2) {
		int tmp = upper_bound(ALL(range[2]),MP(bc,mod))-range[2].begin();
		tmp -= lower_bound(ALL(range[2]),MP(ac,-1))-range[2].begin();
		int id = lower_bound(ALL(range[2]),MP(ac,-1))-range[2].begin();
		if (!range[2].empty() and id!=0 and range[2][id-1].se>=ac) tmp++;
		return tmp;
	}
    else {
		int tmp = upper_bound(ALL(range[0]),MP(bc,mod))-range[0].begin();
		tmp -= lower_bound(ALL(range[0]),MP(ac,-1))-range[0].begin();
		int id = lower_bound(ALL(range[0]),MP(ac,-1))-range[0].begin();
		if (!range[0].empty() and id!=0 and range[0][id-1].se>=ac) tmp++;
		return tmp;
	}
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 54 ms 3828 KB Output is correct
4 Correct 68 ms 4676 KB Output is correct
5 Correct 67 ms 4924 KB Output is correct
6 Correct 63 ms 4608 KB Output is correct
7 Correct 65 ms 4904 KB Output is correct
8 Correct 49 ms 4004 KB Output is correct
9 Correct 64 ms 4776 KB Output is correct
10 Correct 85 ms 4868 KB Output is correct
11 Correct 63 ms 4672 KB Output is correct
12 Correct 52 ms 4296 KB Output is correct
13 Correct 51 ms 4732 KB Output is correct
14 Correct 58 ms 4796 KB Output is correct
15 Correct 56 ms 4548 KB Output is correct
16 Correct 56 ms 4232 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 2 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -