Submission #738313

# Submission time Handle Problem Language Result Execution time Memory
738313 2023-05-08T12:43:52 Z myrcella Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
1 ms 596 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 = 55;

const int dx[4] = {0,-1,1,0}, dy[4] = {1,0,0,-1};
int grid[maxn][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 = 0;
	rep(k,1,3) {
		rep(i,0,C) {
			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-1});
	}
	rep(i,0,C) {
		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-1});
}

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 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Runtime error 1 ms 596 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -