Language: C++

#include <bits/stdc++.h>
using namespace std;

using ll=int64_t;
//#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#ifdef MAROON_LOCAL
#define cerr (cerr<<"-- line "<<__LINE__<<" -- ")
#else
class CerrDummy{}cerrDummy;
template<class T>
CerrDummy& operator<<(CerrDummy&cd,const T&){
	return cd;
}
using charTDummy=char;
using traitsDummy=char_traits<charTDummy>;
CerrDummy& operator<<(CerrDummy&cd,basic_ostream<charTDummy,traitsDummy>&(basic_ostream<charTDummy,traitsDummy>&)){
	return cd;
}
#define cerr cerrDummy
#endif
#define REACH cerr<<"reached"<<endl
#define DMP(x) cerr<<#x<<":"<<x<<endl
#define ZERO(x) memset(x,0,sizeof(x))
#define ONE(x) memset(x,-1,sizeof(x))

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

ll read(){
	ll i;
	scanf("%" SCNd64,&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(ll x,int suc=1){
	printf("%" PRId64,x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341000];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341000];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(b<a)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

const ll infLL=LLONG_MAX/3;

#ifdef int
const int inf=infLL;
#else
const int inf=INT_MAX/2-100;
#endif

struct Pos{
	int x,y;
	bool operator<(const Pos&rhs)const {
		return x!=rhs.x?x<rhs.x:y<rhs.y;
	}
};

map<Pos,int> cmp;
vector<Pos> crd;

const int Nmax=400010;
vi g[Nmax],rg[Nmax];
int d[Nmax],rd[Nmax];
void MakeGraph(Pos s,Pos t,vector<Pos> org,bool vert){
	if(!vert){
		swap(s.x,s.y);
		swap(t.x,t.y);
		for(auto&p:org)
			swap(p.x,p.y);
	}
	REP(k,2){
		map<int,vi> src,dst;
		src[s.x].PB(s.y);
		dst[t.x].PB(t.y);
		for(auto p:org){
			src[p.x+1].PB(p.y);
			src[p.x-1].PB(p.y);
			dst[p.x].PB(p.y-1);
		}
		for(auto&kv:src){
			int x=kv.first;
			for(auto sy:kv.second){
				auto itr=lower_bound(ALL(dst[x]),sy);
				if(itr!=dst[x].end()){
					int ty=*itr;
					if(k){
						sy=-sy;
						ty=-ty;
					}
					int si=cmp[vert?Pos{x,sy}:Pos{sy,x}];
					int ti=cmp[vert?Pos{x,ty}:Pos{ty,x}];
					g[si].PB(ti);
					rg[ti].PB(si);
				}
			}
		}
		for(auto&p:org)
			p.y=-p.y;
		s.y=-s.y;
		t.y=-t.y;
	}
}
void SetDist(int n,vi*graph,int*dist,int src){
	REP(i,n)dist[i]=inf;
	queue<int> q;
	const auto set=[&](int v,int x){
		if(x<dist[v]){
			dist[v]=x;
			q.push(v);
		}
	};
	set(src,0);
	while(!q.empty()){
		int v=q.front();q.pop();
		for(auto to:graph[v])
			set(to,dist[v]+1);
	}
}
struct Line{
	int x,y1,y2,w;
};
vector<Line> GetLines(int n,vector<Pos> org,int*dist,bool vert){
	if(vert){
		for(auto&p:org)
			swap(p.x,p.y);
		for(auto&p:crd)
			swap(p.x,p.y);
	}
	map<int,vi> pos,ice;
	for(auto p:org)
		ice[p.x].PB(p.y);
	for(auto&p:crd)
		pos[p.x].PB(p.y);
	vector<Line> res;
	for(auto kv:pos){
		int x=kv.first;
		vi&ys=ice[x];
		ys.PB(-inf);
		ys.PB(inf);
		sort(ALL(ys));
		vi&zs=kv.second;
		int j=0;
		REP(i,int(ys.size())-1){
			assert(j<int(zs.size()));
			while(zs[j]<=ys[i])j++;
			assert(j<int(zs.size()));
			int mn=inf;
			while(j<int(zs.size())&&zs[j]<ys[i+1]){
				chmin(mn,dist[cmp[vert?Pos{x,zs[j]}:Pos{zs[j],x}]]);
				j++;
			}
			res.PB(
		}
	}
}

signed main(){
	Pos s,t;
	{
		{
			int x=read(),y=read();
			s=Pos{x,y};
		}
		{
			int x=read(),y=read();
			t=Pos{x,y};
		}
		cmp[s]=0;
		cmp[t]=0;
		int n=read();
		vector<Pos> org;
		REP(i,n){
			int x=read(),y=read();
			cmp[Pos{x+1,y}]=0;
			cmp[Pos{x,y+1}]=0;
			cmp[Pos{x-1,y}]=0;
			cmp[Pos{x,y-1}]=0;
			org.PB(Pos{x,y});
		}
		{ 
			int tmp=0;
			for(auto&p:cmp){
				crd.PB(p.first);
				p.second=tmp++;
			}
		}
		MakeGraph(s,t,org,true);
		MakeGraph(s,t,org,false);
	}
	int n=cmp.size();
	for(auto kv:cmp){
		cerr<<kv.first.x<<" "<<kv.first.y<<" "<<kv.second<<endl;
	}
	cerr<<n<<endl;
	REP(i,n){
		cerr<<"idx "<<i<<" "<<crd[i].x<<" "<<crd[i].y<<endl;
		cerr<<"to "<<g[i]<<endl;
	}
	SetDist(n,g,d,cmp[s]);
	SetDist(n,rg,rd,cmp[t]);
	if(d[cmp[t]]<=1){
		print(0);
	}
	vector<Line>
}



Compiler output:
a.cc: In function 'std::vector<Line> GetLines(int, std::vector<Pos>, int*, bool)':
a.cc:235:17: error: expected primary-expression before '}' token
  235 |                 }
      |                 ^
a.cc: In function 'int main()':
a.cc:287:1: error: expected unqualified-id before '}' token
  287 | }
      | ^
a.cc: In function 'std::vector<Line> GetLines(int, std::vector<Pos>, int*, bool)':
a.cc:237:1: warning: control reaches end of non-void function [-Wreturn-type]
  237 | }
      | ^