#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
ll inf = 1ll << 60;
int r, c, m, q, r0, c0, r1, c1, r2, c2;
map<pair<int, int>, bool> is, is2, vis;
bool valid(int i, int j){
if (i > r2 or i < r1) return false;
if (j > c2 or j < c1) return false;
if (is[{i, j}]) return false;
return true;
}
void dfs(int i, int j){
vis[{i, j}] = true;
if (is2[{i + 1, j}] and !vis[{i + 1, j}]) dfs(i + 1, j);
if (is2[{i - 1, j}] and !vis[{i - 1, j}]) dfs(i - 1, j);
if (is2[{i, j + 1}] and !vis[{i, j + 1}]) dfs(i, j + 1);
if (is2[{i, j - 1}] and !vis[{i, j - 1}]) dfs(i, j - 1);
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> r >> c >> m >> q >> r0 >> c0;
string s;
getline(cin, s);
getline(cin, s);
cin >> r1 >> c1 >> r2 >> c2;
vector<pair<int, int>> a, b;
a.push_back({r0, c0});
int x = r0, y = c0;
for (int i = 0; i < m; i++){
if (s[i] == 'S') x++;
if (s[i] == 'N') x--;
if (s[i] == 'E') y++;
if (s[i] == 'W') y--;
a.push_back({x, y});
is[{x, y}] = true;
}
for (int i = r1; i <= r2; i++){
a.push_back({i, c1 - 1});
a.push_back({i, c2 + 1});
}
for (int i = c1; i <= c2; i++){
a.push_back({r1 - 1, i});
a.push_back({r2 + 1, i});
}
for (auto i : a){
if (valid(i.fi + 1, i.se)) b.push_back({i.fi + 1, i.se});
if (valid(i.fi, i.se + 1)) b.push_back({i.fi, i.se + 1});
if (valid(i.fi - 1, i.se)) b.push_back({i.fi - 1, i.se});
if (valid(i.fi, i.se - 1)) b.push_back({i.fi, i.se - 1});
}
int ans = 0;
for (auto i : b) is2[i] = true;
for (auto i : b){
if (!vis[i]){
dfs(i.fi, i.se);
ans++;
}
}
cout << ans << '\n';
}
Compilation message
/usr/bin/ld: /tmp/ccd6LFPw.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1kdfsw.o:rainbow.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccd6LFPw.o: in function `main':
grader.cpp:(.text.startup+0xed): undefined reference to `init(int, int, int, int, int, char*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x167): undefined reference to `colour(int, int, int, int)'
collect2: error: ld returned 1 exit status