#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
#define PB push_back
#define MP make_pair
#define all(a) (a).begin(), (a).end()
#define endl '\n'
#define dbg(x) cerr << '[' << #x << ": " << x << "]\n"
#define dbg2(x, y) cerr << '[' << #x << ": " << x << ", " << #y << ": " << y << "]\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"
const ll INF = (ll)2e18 + 1386;
const ld EPS = 0.000000000000001;
const int MOD = 1e9 + 7;
inline int _add(int a, int b){ int res = a + b; return (res >= MOD ? res - MOD : res); }
inline int _neg(int a, int b){ int res = (abs(a - b) < MOD ? a - b : (a - b) % MOD); return (res < 0 ? res + MOD : res); }
inline int _mlt(ll a, ll b){ return (a * b % MOD); }
inline void fileIO(string i, string o){ freopen(i.c_str(), "r", stdin); freopen(o.c_str(), "w", stdout); }
const int MAXN = 51;
int par[MAXN * MAXN], n, m;
int a[MAXN][MAXN];
inline int c(int x, int y){ return (x - 1) * m + y; }
int getpar(int v){
return par[v] == v ? v : par[v] = getpar(par[v]);
}
void merge(int u, int v){
u = getpar(u), v = getpar(v);
par[u] = v;
}
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R, m = C;
iota(par, par + R * C + 1, 0);
a[sr][sc] = 1;
for (int i = 0; i < M; i++){
char ch = S[i];
if (ch == 'N') a[--sr][sc] = 1;
else if (ch == 'S') a[++sr][sc] = 1;
else if (ch == 'E') a[sr][++sc] = 1;
else a[sr][--sc] = 1;
}
for (int i = 1; i <= R; i++){
for (int j = 1; j <= C; j++){
cout << a[i][j];
}
cout << endl;
}
cout << endl;
}
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
int colour(int ar, int ac, int br, int bc) {
for (int i = ar; i <= br; i++){
for (int j = ac; j <= bc; j++){
if (a[i][j] == 1) continue;
for (int ii = 0; ii < 4; ii++){
int x = i + dx[ii], y = j + dy[ii];
if (x >= ar && x <= br && y >= ac && y <= bc && a[x][y] == 0){
merge(c(i, j), c(x, y));
}
}
}
}
set<int> st;
for (int i = ar; i <= br; i++){
for (int j = ac; j <= bc; j++){
if (a[i][j] == 0) st.insert(getpar(c(i, j)));
}
}
for (int i = ar; i <= br; i++){
for (int j = ac; j <= bc; j++){
par[c(i, j)] = c(i, j);
}
}
return (int)st.size();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |