#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define OR |
typedef long long ll ;
const ll ooo = 1e14 ;
const ll oo = 2e9 ;
const double PI = acos(-1) ;
const ll M = 1e9 + 7 ;
const int N = 10000010 ;
int r[4] = {1 , -1 , 0 , 0} ,
c[4] = {0 , 0 , 1 , -1} ;
map<char,int> mp;
map<int,bool> vis[200010];
int ln , lm , rn , rm;
string g[200010];
set<pair<int,int>> s;
void init(int R, int C, int sr, int sc, int M, char *S) {
mp['N'] = 1;
mp['S'] = 0;
mp['E'] = 2;
mp['W'] = 3;
for(int i = 1 ; i <= R ; ++i)
for(int j = 0 ; j <= C ; ++j) g[i] += '.';
g[sr][sc] = '#';
for(int i = 0 ; i < M ; ++i){
sr += r[mp[S[i]]];
sc += c[mp[S[i]]];
g[sr][sc] = '#';
}
}
void dfs(int i , int j){
if(i == ln - 1 or j == lm - 1 or i == rn + 1 or j == rm + 1) return;
if(g[i][j] == '#' or vis[i][j])return;
s.erase({i,j});
vis[i][j] = 1;
for(int k = 0 ; k < 4; ++k){
int nx = i + r[k] , ny = j + c[k];
dfs(nx , ny);
}
}
// g++ -Wall -lm -static -DEVAL -o rainbow -O2 rainbow.cpp grader.cpp -std=c++14
int colour(int ar, int ac, int br, int bc) {
int ans = 0 ;
s.clear();
ln = ar;
lm = ac;
rn = br;
rm = bc;
for(int i = ar ; i <= br ; ++i){
vis[i].clear();
for(int j = ac ; j <= bc ; ++j)
if(g[i][j] != '#') s.insert({i , j});
}
while(!s.empty()){
int x = s.begin()->first , y = s.begin()->second;
// cout << x << ' ' << y << ' ' << ":" << endl;
dfs(x , y);
// cout << endl;
ans++;
}
return ans ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
16000 KB |
Output is correct |
2 |
Correct |
84 ms |
16120 KB |
Output is correct |
3 |
Correct |
267 ms |
16256 KB |
Output is correct |
4 |
Correct |
275 ms |
16376 KB |
Output is correct |
5 |
Correct |
78 ms |
16128 KB |
Output is correct |
6 |
Correct |
9 ms |
16000 KB |
Output is correct |
7 |
Correct |
10 ms |
16000 KB |
Output is correct |
8 |
Correct |
9 ms |
16000 KB |
Output is correct |
9 |
Correct |
11 ms |
16000 KB |
Output is correct |
10 |
Correct |
10 ms |
16000 KB |
Output is correct |
11 |
Correct |
219 ms |
16376 KB |
Output is correct |
12 |
Correct |
164 ms |
16248 KB |
Output is correct |
13 |
Correct |
117 ms |
16128 KB |
Output is correct |
14 |
Correct |
58 ms |
16000 KB |
Output is correct |
15 |
Correct |
9 ms |
16000 KB |
Output is correct |
16 |
Correct |
9 ms |
16000 KB |
Output is correct |
17 |
Correct |
9 ms |
16000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
16000 KB |
Output is correct |
2 |
Correct |
9 ms |
16000 KB |
Output is correct |
3 |
Execution timed out |
3077 ms |
54564 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
16000 KB |
Output is correct |
2 |
Execution timed out |
3111 ms |
452868 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
16000 KB |
Output is correct |
2 |
Correct |
84 ms |
16120 KB |
Output is correct |
3 |
Correct |
267 ms |
16256 KB |
Output is correct |
4 |
Correct |
275 ms |
16376 KB |
Output is correct |
5 |
Correct |
78 ms |
16128 KB |
Output is correct |
6 |
Correct |
9 ms |
16000 KB |
Output is correct |
7 |
Correct |
10 ms |
16000 KB |
Output is correct |
8 |
Correct |
9 ms |
16000 KB |
Output is correct |
9 |
Correct |
11 ms |
16000 KB |
Output is correct |
10 |
Correct |
10 ms |
16000 KB |
Output is correct |
11 |
Correct |
219 ms |
16376 KB |
Output is correct |
12 |
Correct |
164 ms |
16248 KB |
Output is correct |
13 |
Correct |
117 ms |
16128 KB |
Output is correct |
14 |
Correct |
58 ms |
16000 KB |
Output is correct |
15 |
Correct |
9 ms |
16000 KB |
Output is correct |
16 |
Correct |
9 ms |
16000 KB |
Output is correct |
17 |
Correct |
9 ms |
16000 KB |
Output is correct |
18 |
Execution timed out |
3074 ms |
56900 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
16000 KB |
Output is correct |
2 |
Correct |
84 ms |
16120 KB |
Output is correct |
3 |
Correct |
267 ms |
16256 KB |
Output is correct |
4 |
Correct |
275 ms |
16376 KB |
Output is correct |
5 |
Correct |
78 ms |
16128 KB |
Output is correct |
6 |
Correct |
9 ms |
16000 KB |
Output is correct |
7 |
Correct |
10 ms |
16000 KB |
Output is correct |
8 |
Correct |
9 ms |
16000 KB |
Output is correct |
9 |
Correct |
11 ms |
16000 KB |
Output is correct |
10 |
Correct |
10 ms |
16000 KB |
Output is correct |
11 |
Correct |
219 ms |
16376 KB |
Output is correct |
12 |
Correct |
164 ms |
16248 KB |
Output is correct |
13 |
Correct |
117 ms |
16128 KB |
Output is correct |
14 |
Correct |
58 ms |
16000 KB |
Output is correct |
15 |
Correct |
9 ms |
16000 KB |
Output is correct |
16 |
Correct |
9 ms |
16000 KB |
Output is correct |
17 |
Correct |
9 ms |
16000 KB |
Output is correct |
18 |
Execution timed out |
3074 ms |
56900 KB |
Time limit exceeded |
19 |
Halted |
0 ms |
0 KB |
- |