#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
int n, m;
bool is[51][51] = {};
string mas;
void gen(int e, int s) {
for(auto x : mas) {
is[e][s] = 1;
if(x == 'N') e--;
if(x == 'S') e++;
if(x == 'W') s--;
if(x == 'E') s++;
is[e][s] = 1;
}
}
void init(int R, int C, int sr, int sc, int M, char *S) {
n = R; m = C;
for(int i = 0; i < M; i++) mas.push_back(S[i]);
gen(sr, sc);
}
int colour(int ar, int ac, int br, int bc) {
int ret = 0;
bool vis[51][51] = {};
vector<pair<int, int> > pos = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
for(int i = ar; i <= br; i++) {
for(int j = ac; j <= bc; j++) {
if(vis[i][j]) continue ;
if(is[i][j]) continue;
// cout << "esu (" << i << ", " << j << ")\n";
int e = i; int s = j;
int pe, ps;
queue<pair<int, int> > q;
q.push({e, s});
while(q.size()) {
e = q.front().first;
s = q.front().second;
q.pop();
for(auto x : pos) {
pe = x.first + e; ps = x.second + s;
if(pe < ar || pe > br || ps < ac || ps > bc) continue;
if(vis[pe][ps]) continue;
if(is[pe][ps]) continue;
vis[pe][ps] = 1;
q.push({pe, ps});
}
}
ret++;
}
}
// cout << "ret " << ret << endl;
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
352 KB |
Output is correct |
3 |
Correct |
16 ms |
336 KB |
Output is correct |
4 |
Correct |
16 ms |
340 KB |
Output is correct |
5 |
Correct |
6 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
308 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
352 KB |
Output is correct |
3 |
Correct |
16 ms |
336 KB |
Output is correct |
4 |
Correct |
16 ms |
340 KB |
Output is correct |
5 |
Correct |
6 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
308 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
7 ms |
352 KB |
Output is correct |
3 |
Correct |
16 ms |
336 KB |
Output is correct |
4 |
Correct |
16 ms |
340 KB |
Output is correct |
5 |
Correct |
6 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
308 KB |
Output is correct |
7 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |