#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
return '"' + s + '"';
}
string to_string(const char* s) {
return to_string((string) s);
}
string to_string(bool b) {
return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
bool first = true;
string res = "{";
for (int i = 0; i < static_cast<int>(v.size()); i++) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(v[i]);
}
res += "}";
return res;
}
template <size_t N>
string to_string(bitset<N> v) {
string res = "";
for (size_t i = 0; i < N; i++) {
res += static_cast<char>('0' + v[i]);
}
return res;
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
const int N = 100;
char table[N][N];
int n, m;
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R, m = C;
table[sr][sc] = 1;
for (int i = 0; i < M; i++) {
if (S[i] == 'N') {
sr--;
} else if (S[i] == 'S') {
sr++;
} else if (S[i] == 'W') {
sc--;
} else {
sc++;
}
table[sr][sc] = 1;
}
}
bool is_valid(int x, int y, int lx, int rx, int ly, int ry) {
return x >= lx && x <= rx && y >= ly && y <= ry;
}
bool value(int x, int y, int lx, int rx, int ly, int ry) {
return x < lx || x > rx || y < ly || y > ry || table[x][y];
}
int colour(int ar, int ac, int br, int bc) {
int e = 0, v = 0;
int e_border = 0;
for (int i = ar; i <= br; i++) {
for (int j = ac; j <= bc; j++) {
if (table[i][j]) {
v++;
for (int k = 0; k < 4; k++) {
int ni = i + dx[k];
int nj = j + dy[k];
if (is_valid(ni, nj, ar, br, ac, bc) && table[ni][nj]) {
e++;
} else if (value(ni, nj, ar, br, ac, bc)) {
e_border++;
}
}
}
}
}
e /= 2;
v += 2 * (br - ar + 1 + bc - ac + 1) + 4;
e += 2 * (br - ar + 1 + bc - ac + 1) + 4;
e += e_border;
// return e;
int sub = 0;
for (int i = ar - 1; i <= br; i++) {
for (int j = ac - 1; j <= bc; j++) {
sub += value(i, j, ar, br, ac, bc) & value(i + 1, j, ar, br, ac, bc) & value(i + 1, j + 1, ar, br, ac, bc) & value(i, j + 1, ar, br, ac, bc);
}
}
return e - v + 1 - sub;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Runtime error |
2 ms |
724 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Runtime error |
2 ms |
672 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |