Submission #364194

# Submission time Handle Problem Language Result Execution time Memory
364194 2021-02-08T11:27:23 Z flappybird Land of the Rainbow Gold (APIO17_rainbow) C++14
0 / 100
17 ms 364 KB
#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
typedef long ll;
typedef pair<ll, ll> pp;
#define MAX 101010
#define INF 10000000
#define pb push_back
vector<pp> V;
set<pp> s, vs;
vector<pp> dir;
pp operator+(pp a, pp b) {
	return { a.first + b.first, a.second + b.second };
}
bool exist(pp x) {
	return !(s.find(x) == s.end());
}
void init(int R, int C, int sr, int sc, int M, char *S) {
	ll i;
	ll x, y;
	dir.pb({ 1, 0 });
	dir.pb({ 0, 1 });
	dir.pb({ -1, 0 });
	dir.pb({ 0, -1 });
	x = sr;
	y = sc;
	for (i = 0; i < M; i++) {
		if (S[i] == 'N') s.insert({ --x, y });
		if (S[i] == 'S') s.insert({ ++x, y });
		if (S[i] == 'W') s.insert({ x, --y });
		if (S[i] == 'E') s.insert({ x, ++y });
	}
	set<pp>::iterator it;
	for (it = s.begin(); it != s.end(); it++) V.pb(*it);
}
int colour(int ar, int ac, int br, int bc) {
	s.clear();
	vs.clear();
	ll M = V.size();
	ll i, j;
	ll v, e, r;
	v = e = r = 0;
	ll c;
	for (i = ar; i <= br; i++) s.insert({ i, ac - 1 }), s.insert({ i, bc + 1 });
	for (i = ac; i <= bc; i++) s.insert({ ar - 1, i }), s.insert({ br + 1, i });
	for (i = 0; i < M; i++) {
		if (!((ar <= V[i].first&&V[i].first <= br) && (ac <= V[i].second&&V[i].second <= bc))) continue;
		if (exist(V[i])) continue;
		s.insert(V[i]);
		r++;
		for (j = 0; j < 4; j++) if (!exist(V[i] + dir[j])) e++;
		for (j = 0; j < 4; j++) if (!(exist(V[i] + dir[j]) || exist(V[i] + dir[(j + 1) % 4]) || exist(V[i] + dir[j] + dir[(j + 1) % 4]))) v++;
	}
	v += 2 * (bc - ac + br - ar + 2);
	e += 2 * (bc - ac + br - ar + 2);
	return e - v - r + 1;
}

Compilation message

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:43:5: warning: unused variable 'c' [-Wunused-variable]
   43 |  ll c;
      |     ^
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -