Pagini recente » Cod sursa (job #126270) | Cod sursa (job #2205016) | Cod sursa (job #631600) | Cod sursa (job #186276) | Cod sursa (job #2142082)
#include <bits/stdc++.h>
using namespace std;
ifstream in("zc.in");
ofstream out("zc.out");
int main() {
int n, m; in >> n >> m;
vector< pair< int, int > >capcane(n);
for(auto& it: capcane)in >> it.first >> it.second;
pair< int, int > currentPosition = make_pair(0, 0);
int ans = 0;
for(int i = 1; i <= m; ++i) {
char direction;
int steps;
in >> direction >> steps;
int nx, ny;
if(direction == 'N') {
nx = 0;
ny = 1;
} else {
if(direction == 'E') {
nx = 1;
ny = 0;
} else {
if(direction == 'S') {
nx = 0;
ny = -1;
} else {
nx = -1;
ny = 0;
}
}
}
while(steps) {
currentPosition.first += nx;
currentPosition.second += ny;
//out << currentPosition.first << " " << currentPosition.second << '\n';
for(auto it: capcane) {
int manhattanDist = abs(currentPosition.first - it.first) + abs(currentPosition.second - it.second);
if(manhattanDist <= 2) {
ans++;
//out << currentPosition.first << " " << currentPosition.second << " " << it.first << " " << it.second << " " << manhattanDist << '\n';
}
}
steps--;
}
}
out << ans;
in.close(); out.close();
return 0;
}