#include <bits/stdc++.h>
#ifdef ioi
//#include "rainbow.h"
#else
#include "rainbow.h"
#endif // ioi
#define sz(s) (ll)(s.size())
#define all(x) (x.begin(), x.end())
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mp make_pair
#define ort1 exit(0);
#define nl endl
#define rep(i, l, r) for(int i = (l); i <= (r); ++i)
#define per(i, l, r) for(int i = (l); i >= (r); --i)
#define TL clock() / (double)CLOCKS_PER_SEC
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1.0);
const double eps = 1e-9;
const int mod = 1e9 + 7;
const ll INF = 1e12 + 1;
const int N = 1e3 + 9;
int n, r, c, m, q;
int x, y;
int a[N][N];
bool used[N][N];
string s;
void p(int x, int y){
rep(i, 0, m - 1){
if(s[i] == 'N') x--;
if(s[i] == 'E') y++;
if(s[i] == 'W') y--;
if(s[i] == 'S') x++;
a[x][y] = 1;
}
}
void init(int R, int C, int sr, int sc, int M, char *S) {
rep(i, 0, M - 1){
s.pb(S[i]);
}
m = M;
p(sr, sc);
}
inline void dfs(int x, int y, int ar, int ac, int br, int bc){
used[x][y] = 1;
if(a[x + 1][y] == 0 && x + 1 <= br && used[x + 1][y] == 0) dfs(x + 1, y, ar, ac, br, bc);
if(a[x - 1][y] == 0 && x - 1 >= ar && used[x - 1][y] == 0) dfs(x - 1, y, ar, ac, br, bc);
if(a[x][y + 1] == 0 && y + 1 <= bc && used[x][y + 1] == 0) dfs(x, y + 1, ar, ac, br, bc);
if(a[x][y - 1] == 0 && y - 1 >= ac && used[x][y - 1] == 0) dfs(x, y - 1, ar, ac, br, bc);
}
int colour(int ar, int ac, int br, int bc){
int cnt = 0;
memset(used, 0, sizeof(used));
rep(i, ar, br){
rep(j, ac, bc){
if(used[i][j] == 0 && a[i][j] == 0){
cnt++;
dfs(i, j, ar, ac, br, bc);
}
}
}
return cnt;
return 0;
}
namespace read{
static int R, C, M, Q;
static int sr, sc;
static char S[100000 + 5];
void input(){
scanf("%d %d %d %d", &R, &C, &M, &Q);
scanf("%d %d", &sr, &sc);
if (M > 0) {
scanf(" %s ", S);
}
init(R, C, sr, sc, M, S);
int query;
for (query = 0; query < Q; query++) {
int ar, ac, br, bc;
scanf("%d %d %d %d", &ar, &ac, &br, &bc);
printf("%d\n", colour(ar, ac, br, bc));
}
}
}
#ifdef ioi
int main(){
read :: input();
ort1
}
#endif
Compilation message
rainbow.cpp: In function 'void read::input()':
rainbow.cpp:88:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d %d", &R, &C, &M, &Q);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rainbow.cpp:89:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d", &sr, &sc);
~~~~~^~~~~~~~~~~~~~~~~~~
rainbow.cpp:91:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf(" %s ", S);
~~~~~^~~~~~~~~~~
rainbow.cpp:99:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d %d %d", &ar, &ac, &br, &bc);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
1408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
1408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1408 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
1408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
1408 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |