Language: C++

#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;

struct point
{
        int x, y, dir, dist;
        bool operator<(const point &p) const { return x!=p.x? x < p.x: y < p.y;}
        bool operator==(const point &p) const { return x == p.x and y == p.y;}
};

const int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0};
int n, t, sx, sy, f[64][64][4];
int d[128], p[128], done[64][64][4][16];
vector<point> cand, ans;

void simulate(int dist, int edir)
{
        queue<point> q;
        for(auto &e: cand) if(!e.dist) q.push(e);
        for(auto &e: cand) if(e.dist) q.push(e);
        cand.clear();
        memset(done,0,sizeof(done));
        while(!q.empty()) {
                point v = q.front(); q.pop();
                if(done[v.x][v.y][v.dir][v.dist]) continue;
                done[v.x][v.y][v.dir][v.dist] = 1;
                if(v.dist == dist and v.dir == edir) cand.push_back((point){v.x,v.y,edir,0});
                for (int i = 0; i < 4; i++) {
                        if((v.dir+2)%4 == i or !f[v.x][v.y][i]) continue;
                        int nx = v.x+dx[i], ny = v.y+dy[i];
                        if(v.dist == dist) {
                                if(i == edir) cand.push_back((point){nx,ny,edir,1});
                                else continue;
                        }
                        q.push((point){nx,ny,i,v.dist+1});
                }
        }
}

void solve()
{
        cand.push_back((point){sx,sy,0,0});
        cand.push_back((point){sx,sy,2,0});
        for (int i = 0; i < t; i++) simulate(d[i], p[i]);
        for(auto &e: cand) {
                if(e.dist) ans.push_back((point){e.x-dx[e.dir],e.y-dy[e.dir],e.dir,0});
                else ans.push_back(e);
        }
        sort(begin(ans),end(ans));
        ans.erase(unique(begin(ans),end(ans)),end(ans));
        for(auto &e: ans) cout << e.x << " " << e.y << endl;
}

void input()
{
        cin >> n >> sx >> sy >> t;
        int x1, y1, x2, y2;
        for (int i = 0; i < n; i++) {
                cin >> x1 >> y1 >> x2 >> y2;
                if(x1 == x2) for (int y = min(y1,y2); y < max(y1,y2); y++) f[x1][y][0] = f[x1][y+1][2] = 1;
                else for (int x = min(x1,x2); x < max(x1,x2); x++) f[x][y1][1] = f[x+1][y1][3] = 1;
        }
        const string dir = "NESW";
        char c;
        for (int i = 0; i < t; i++) {
                cin >> d[i] >> c;
                p[i] = dir.find(c);
        }
}

int main()
{
        cin.tie(0);
        cin.sync_with_stdio(0);
        input();
        solve();
        return 0;
}

Compiler output:
a.cc:18:1: error: 'vector' does not name a type
   18 | vector<point> cand, ans;
      | ^~~~~~
a.cc: In function 'void simulate(int, int)':
a.cc:22:9: error: 'queue' was not declared in this scope
   22 |         queue<point> q;
      |         ^~~~~
a.cc:6:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>'
    5 | #include <cstdio>
  +++ |+#include <queue>
    6 | using namespace std;
a.cc:22:20: error: expected primary-expression before '>' token
   22 |         queue<point> q;
      |                    ^
a.cc:22:22: error: 'q' was not declared in this scope
   22 |         queue<point> q;
      |                      ^
a.cc:23:22: error: 'cand' was not declared in this scope; did you mean 'rand'?
   23 |         for(auto &e: cand) if(!e.dist) q.push(e);
      |                      ^~~~
      |                      rand
a.cc:24:22: error: 'cand' was not declared in this scope; did you mean 'rand'?
   24 |         for(auto &e: cand) if(e.dist) q.push(e);
      |                      ^~~~
      |                      rand
a.cc:25:9: error: 'cand' was not declared in this scope; did you mean 'rand'?
   25 |         cand.clear();
      |         ^~~~
      |         rand
a.cc: In function 'void solve()':
a.cc:46:9: error: 'cand' was not declared in this scope; did you mean 'rand'?
   46 |         cand.push_back((point){sx,sy,0,0});
      |         ^~~~
      |         rand
a.cc:50:28: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |                 if(e.dist) ans.push_back((point){e.x-dx[e.dir],e.y-dy[e.dir],e.dir,0});
      |                            ^~~
      |                            abs
a.cc:51:22: error: 'ans' was not declared in this scope; did you mean 'abs'?
   51 |                 else ans.push_back(e);
      |                      ^~~
      |                      abs
a.cc:53:20: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |         sort(begin(ans),end(ans));
      |                    ^~~
      |                    abs