#include "rainbow.h"
#include <bits/stdc++.h>
using namespace std;
int n, m;
bool is[501][501] = {};
string mas;
void gen(int e, int s) {
is[e][s] = 1;
for(auto x : mas) {
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[501][501] = {};
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 |
8 ms |
468 KB |
Output is correct |
2 |
Correct |
16 ms |
592 KB |
Output is correct |
3 |
Correct |
26 ms |
576 KB |
Output is correct |
4 |
Correct |
22 ms |
580 KB |
Output is correct |
5 |
Correct |
12 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
0 ms |
432 KB |
Output is correct |
10 |
Correct |
0 ms |
440 KB |
Output is correct |
11 |
Correct |
21 ms |
616 KB |
Output is correct |
12 |
Correct |
19 ms |
616 KB |
Output is correct |
13 |
Correct |
16 ms |
616 KB |
Output is correct |
14 |
Correct |
17 ms |
596 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
16 |
Correct |
0 ms |
468 KB |
Output is correct |
17 |
Correct |
0 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
0 ms |
468 KB |
Output is correct |
3 |
Execution timed out |
3064 ms |
1132 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Runtime error |
2 ms |
1108 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
468 KB |
Output is correct |
2 |
Correct |
16 ms |
592 KB |
Output is correct |
3 |
Correct |
26 ms |
576 KB |
Output is correct |
4 |
Correct |
22 ms |
580 KB |
Output is correct |
5 |
Correct |
12 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
0 ms |
432 KB |
Output is correct |
10 |
Correct |
0 ms |
440 KB |
Output is correct |
11 |
Correct |
21 ms |
616 KB |
Output is correct |
12 |
Correct |
19 ms |
616 KB |
Output is correct |
13 |
Correct |
16 ms |
616 KB |
Output is correct |
14 |
Correct |
17 ms |
596 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
16 |
Correct |
0 ms |
468 KB |
Output is correct |
17 |
Correct |
0 ms |
468 KB |
Output is correct |
18 |
Runtime error |
2 ms |
1236 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
468 KB |
Output is correct |
2 |
Correct |
16 ms |
592 KB |
Output is correct |
3 |
Correct |
26 ms |
576 KB |
Output is correct |
4 |
Correct |
22 ms |
580 KB |
Output is correct |
5 |
Correct |
12 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
468 KB |
Output is correct |
7 |
Correct |
1 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
468 KB |
Output is correct |
9 |
Correct |
0 ms |
432 KB |
Output is correct |
10 |
Correct |
0 ms |
440 KB |
Output is correct |
11 |
Correct |
21 ms |
616 KB |
Output is correct |
12 |
Correct |
19 ms |
616 KB |
Output is correct |
13 |
Correct |
16 ms |
616 KB |
Output is correct |
14 |
Correct |
17 ms |
596 KB |
Output is correct |
15 |
Correct |
0 ms |
468 KB |
Output is correct |
16 |
Correct |
0 ms |
468 KB |
Output is correct |
17 |
Correct |
0 ms |
468 KB |
Output is correct |
18 |
Runtime error |
2 ms |
1236 KB |
Execution killed with signal 11 |
19 |
Halted |
0 ms |
0 KB |
- |