#include "rainbow.h"
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N1 = 50;
vector<pii> stage;
int N, M;
bool chk[MAX_N1+1][MAX_N1+1];
int type;
bool vst[MAX_N1+1][MAX_N1+1];
pii s, e;
void pro1(){
type = 1;
for(int i=0; i<stage.size(); i++){
chk[stage[i].first][stage[i].second] = true;
}
}
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
void dfs(int x, int y){
if(x<s.first || x>e.first || y<s.second || y>e.second) return;
if(chk[x][y] || vst[x][y]) return;
vst[x][y] = true;
for(int i=0; i<4; i++){
dfs(x+dx[i], y+dy[i]);
}
}
void pro2(){
type = 2;
}
void pro3(){
type = 3;
}
void init(int R, int C, int sr, int sc, int l, char *S) {
N = R; M = C;
stage.pb({sr, sc});
for(int i=0; i<l; i++){
if(S[i]=='N'){
sr--;
}else if(S[i]=='E'){
sc++;
}else if(S[i]=='W'){
sc--;
}else{
sr++;
}
stage.pb({sr, sc});
}
pro1();
return;
if(R==2){
pro2();
}else if(R<=50 && C<=50){
pro1();
}else{
pro3();
}
}
int colour(int ar, int ac, int br, int bc) {
if(type==1){
int ans = 0;
s = {ar, ac}; e = {br, bc};
for(int i=1; i<=N; i++){
for(int j=1; j<=M; j++){
vst[i][j] = false;
}
}
for(int i=ar; i<=br; i++){
for(int j=ac; j<=bc; j++){
if(!vst[i][j] && !chk[i][j]){
dfs(i, j);
ans++;
}
}
}
return ans;
}
return 0;
}
Compilation message
rainbow.cpp: In function 'void pro1()':
rainbow.cpp:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<stage.size(); i++){
~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
11 ms |
376 KB |
Output is correct |
3 |
Correct |
22 ms |
376 KB |
Output is correct |
4 |
Correct |
21 ms |
380 KB |
Output is correct |
5 |
Correct |
11 ms |
376 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
252 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
128 KB |
Output is correct |
11 |
Correct |
19 ms |
376 KB |
Output is correct |
12 |
Correct |
17 ms |
376 KB |
Output is correct |
13 |
Correct |
13 ms |
376 KB |
Output is correct |
14 |
Correct |
10 ms |
248 KB |
Output is correct |
15 |
Correct |
0 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Runtime error |
5 ms |
2028 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Runtime error |
7 ms |
2536 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
11 ms |
376 KB |
Output is correct |
3 |
Correct |
22 ms |
376 KB |
Output is correct |
4 |
Correct |
21 ms |
380 KB |
Output is correct |
5 |
Correct |
11 ms |
376 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
252 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
128 KB |
Output is correct |
11 |
Correct |
19 ms |
376 KB |
Output is correct |
12 |
Correct |
17 ms |
376 KB |
Output is correct |
13 |
Correct |
13 ms |
376 KB |
Output is correct |
14 |
Correct |
10 ms |
248 KB |
Output is correct |
15 |
Correct |
0 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Runtime error |
7 ms |
2664 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
11 ms |
376 KB |
Output is correct |
3 |
Correct |
22 ms |
376 KB |
Output is correct |
4 |
Correct |
21 ms |
380 KB |
Output is correct |
5 |
Correct |
11 ms |
376 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
252 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
128 KB |
Output is correct |
11 |
Correct |
19 ms |
376 KB |
Output is correct |
12 |
Correct |
17 ms |
376 KB |
Output is correct |
13 |
Correct |
13 ms |
376 KB |
Output is correct |
14 |
Correct |
10 ms |
248 KB |
Output is correct |
15 |
Correct |
0 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Runtime error |
7 ms |
2664 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
19 |
Halted |
0 ms |
0 KB |
- |