#include "rainbow.h"
#include <iostream>
using namespace std;
#include <vector>
#define vi vector<int>
#define ll long long
#include <algorithm>
#include <set>
#include <string>
#include <bitset>
#include <cmath>
#include <math.h>
#define pll pair<ll,ll>
#define vll vector<ll>
#define pi pair<int,int>
#include <map>
#include <queue>
#define x first
#define y second
#define pd pair<double,double>
map<pi, bool> m;
void init(int R, int C, int sr, int sc, int M, char* S) {
m[{sr,sc}] = 1;
for (int i = 0; i < M; i++) {
if (S[i] == 'E')sr++;
if (S[i] == 'W')sr--;
if (S[i] == 'N')sc--;
if (S[i] == 'S')sc++;
m[{sr, sc}] = 1;
}
}
map<pi, bool> vis;
void dfs(int a, int b) {
vis[{a, b}] = 1;
if (m[{a + 1, b}] && !vis[{a+1,b}])dfs(a+1,b);
if (m[{a - 1, b}] && !vis[{a-1, b}])dfs(a -1, b);
if (m[{a, b-1}] && !vis[{a, b-1}])dfs(a , b-1);
if (m[{a , b+1}] && !vis[{a, b+1}])dfs(a , b+1);
}
int colour(int ar, int ac, int br, int bc) {
map<pi, bool> mt = m;
swap(ar, ac); swap(br, bc);
ar--, ac--, br++, bc++;
for (int i = ar; i <= br; i++) {
m[{i, ac}] = 1;
m[{i, bc}] = 1;
}
for (int i = ac; i <= bc; i++) {
m[{ar, i}] = 1;
m[{br, i}] = 1;
}
int v=0, e=0, t=0,r=0;
for (pair<pi, bool> p : m) {
int a = p.x.x, b = p.x.y;
if (a < ar || a > br || b < ac || b > bc)m[p.x]=0;
}
for (pair<pi,bool> p : m) {
if (p.second == 0)continue;
int a = p.x.x, b = p.x.y;
if (a < ar || a > br || b < ac || b > bc)continue;
v++;
bool g = m[{a + 1, b}], h = m[{a, b + 1}], i = m[{a - 1, b}], j = m[{a, b - 1}];
bool k = m[{a + 1, b - 1}], l = m[{a + 1, b + 1}];
e += k;
e += g;
e += l;
e += j;
t += (g + i) * (h + j);
r += g * h * l;
}
m = mt;
int pl = -1;
for (pair<pi, bool> p : m)if (!vis[p.x] && p.y) {
dfs(p.x.x, p.x.y); pl++;
}
return 1+e-v-t+r-pl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
73 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Incorrect |
519 ms |
80292 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
73 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
73 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |