Submission #948925

# Submission time Handle Problem Language Result Execution time Memory
948925 2024-03-18T16:36:58 Z vjudge1 Land of the Rainbow Gold (APIO17_rainbow) C++17
0 / 100
43 ms 3420 KB
#include <bits/stdc++.h>
#include "rainbow.h"
#define rep(a,b,c) for(int a=b; a<c; a++)
#define repa(a,b) for(auto a: b)
#define pii pair<int, int>
#define fi first
#define se second

using namespace std;

bool river[3][200005]{};
int pref[3][200005]{};

void init(int R, int C, int sr, int sc, int M, char *S){
	if(R>2) exit(0);
	river[sr][sc]=true;
	rep(i,0,M){
		if(S[i]=='N') sr--;
		else if(S[i]=='S') sr++;
		else if(S[i]=='W') sc--;
		else sc++;
		river[sr][sc]=true;
	}
	rep(i,1,C+1){
		pref[0][i]+=pref[0][i-1];
		pref[1][i]+=pref[1][i-1];
		pref[2][i]+=pref[2][i-1];
		if(river[1][i-1] && (!river[1][i])) pref[0][i]++;
		if(river[2][i-1] && (!river[2][i])) pref[1][i]++;
		if((river[1][i-1] && river[2][i-1]) && (!river[1][i] || !river[2][i])) pref[2][i]++;
	}
}

int colour(int ar, int ac, int br, int bc){
	int x, c;
	if(br>ar) x=2;
	else x=ar-1;
	c=pref[x][bc]-pref[x][ac-1];
	c+=((!river[ar][ac] || !river[br][ac]) && (!river[ar][ac-1] && !river[br][ac-1]));
	return c;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 43 ms 3420 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 460 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -