Submission #54804

# Submission time Handle Problem Language Result Execution time Memory
54804 2018-07-05T06:37:06 Z top34051 Land of the Rainbow Gold (APIO17_rainbow) C++17
12 / 100
137 ms 42040 KB
//Subtask 2

#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;

#define pii pair<int,int>
#define X first
#define Y second
const int maxn = 2e5 + 5;

int n,m,k;
int a[3][maxn];
map<int,pii> itv[5];

void init(int R, int C, int sr, int sc, int M, char *S) {
	n = R; m = C; k = M;
	int x = sr, y = sc;
	a[x][y] = 1;
	for(int i=0;i<k;i++) {
		if(S[i]=='N') x--;
		if(S[i]=='E') y++;
		if(S[i]=='W') y--;
		if(S[i]=='S') x++;
		a[x][y] = 1;
	}
	int sz;
	sz = 0;
	for(int y=1;y<=m;y++) {
		if(a[1][y]) continue;
		int pos = y;
		while(y+1<=m && !a[1][y+1]) y++;
//		printf("1 [%d, %d]\n",pos,y);
		itv[1][y] = {pos,++sz};
	}
	itv[1][m+1] = {m+1, ++sz};
	sz = 0;
	for(int y=1;y<=m;y++) {
		if(a[2][y]) continue;
		int pos = y;
		while(y+1<=m && !a[2][y+1]) y++;
//		printf("2 [%d, %d]\n",pos,y);
		itv[2][y] = {pos,++sz};
	}
    itv[2][m+1] = {m+1,++sz};
	sz = 0;
	for(int y=1;y<=m;y++) {
		if(a[1][y] && a[2][y]) continue;
		int pos = y;
		while(y+1<=m && ((!a[1][y]&&!a[1][y+1]) || (!a[2][y]&&!a[2][y+1]))) y++;
//		printf("3 [%d, %d]\n",pos,y);
		itv[3][y] = {pos,++sz};
	}
	itv[3][m+1] = {m+1,++sz};
}

int colour(int ar, int ac, int br, int bc) {
    int t;
    if(ar==1 && br==1) t = 1;
    else if(ar==2 && br==2) t = 2;
    else t = 3;
    auto it1 = itv[t].lower_bound(ac);
    auto it2 = itv[t].lower_bound(bc);
    int res = it2->Y.Y - it1->Y.Y + 1;
    if(it2->Y.X > bc) res--;
    return res;
}
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 540 KB Output is correct
2 Correct 2 ms 592 KB Output is correct
3 Correct 69 ms 4420 KB Output is correct
4 Correct 86 ms 8096 KB Output is correct
5 Correct 137 ms 11804 KB Output is correct
6 Correct 107 ms 14692 KB Output is correct
7 Correct 133 ms 19380 KB Output is correct
8 Correct 67 ms 19380 KB Output is correct
9 Correct 88 ms 22732 KB Output is correct
10 Correct 118 ms 26360 KB Output is correct
11 Correct 116 ms 29232 KB Output is correct
12 Correct 61 ms 30692 KB Output is correct
13 Correct 69 ms 34176 KB Output is correct
14 Correct 79 ms 37780 KB Output is correct
15 Correct 79 ms 40632 KB Output is correct
16 Correct 68 ms 42040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 42040 KB Output is correct
2 Runtime error 3 ms 42040 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -