#include "rainbow.h"
#include <bits/stdc++.h>
#define N 55
#define f first
#define s second
using namespace std;
typedef pair<int, int> pii;
int n, m, ok[N][N], block[N][N];
int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
int Ni, Mi, Nii, Mii;
int dxy(char c)
{
if(c == 'N') return 0;
if(c == 'S') return 1;
if(c == 'W') return 3;
return 2;
}
void dfs(int x, int y)
{
ok[x][y] = 1;
//cout<<"DFS "<<x<<" "<<y<<"\n";
for(int i = 0; i < 4; i++)
{
int a = x + dx[i], b = y + dy[i];
if(a < Ni or b < Mi or a > Nii or b > Mii or ok[a][b] == 1 or block[a][b]) continue;
ok[a][b] = 1;
dfs(a, b);
}
}
void init(int R, int C, int sr, int sc, int M, char *S)
{
int x = sr, y = sc;
string s;
for(int i = 0; i < M; i++) s.push_back(S[i]);
for(int i = 0; i < s.size(); i++)
{
block[x][y] = 1;
//cout<<x<<" "<<y<<"\n";
int id = dxy(s[i]);
x = x + dx[id], y = y + dy[id];
block[x][y] = 1;
//cout<<"BLOCK "<<x<<" "<<y<<"\n";
}
}
int colour(int ar, int ac, int br, int bc)
{
int cnt = 0;
memset(ok, 0, sizeof ok);
Nii = br, Ni = ar, Mi = ac, Mii = bc;
for(int x = ar; x <= br; x++)
{
for(int y = ac; y <= bc; y++)
{
if(ok[x][y] or block[x][y]) continue;
cnt ++;
ok[x][y] = 1;
dfs(x, y);
}
}
return cnt;
}
Compilation message
rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:52:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < s.size(); i++)
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
416 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
248 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |