QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#76429#3816. Home alone: Johnny lost in New YorkAFewSunsRE 3ms5476kbC++1411.4kb2023-02-09 21:46:172023-02-09 21:46:39

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-09 21:46:39]
  • 评测
  • 测评结果:RE
  • 用时:3ms
  • 内存:5476kb
  • [2023-02-09 21:46:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll long long
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 8e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
ll n,m,cnt=0,dir[1010][1010],d[4][2]={{0,-1},{1,0},{0,1},{-1,0}};
bl ck[1010][1010];
bl doleft(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy);
bl doright(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy);
bl doup(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy);
bl dodown(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy);
il void work(ll x,ll y,ll k,bl t){
	if(!t) dir[x][y]=k;
	else dir[x+d[k][0]][y+d[k][1]]=k^2;
}
bl dfs0(ll x,ll y,ll xx,ll yy,ll edx,ll edy,ll nx,ll ny,ll dep){
	ck[nx][ny]=1;
	if(nx==edx&&ny==edy&&dep==(xx-x+1)*(yy-y+1)) return 1;
	if(nx==edx&&ny==edy){
		ck[nx][ny]=0;
		return 0;
	}
	fr(i,0,3){
		ll px=nx+d[i][0],py=ny+d[i][1];
		if(px<x||px>xx||py<y||py>yy) continue;
		dir[nx][ny]=i;
		if(ck[px][py]) continue;
		if(dfs0(x,y,xx,yy,edx,edy,px,py,dep+1)) return 1;
	}
	ck[nx][ny]=0;
	return 0;
}
void dfs1(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy){
	if((xx-x+1)<=5&&(yy-y+1)<=5){
		if(!dfs0(x,y,xx,yy,edx,edy,stx,sty,1)){
			pf("NIE\n");
			exit(0);
		}
		return;
	}
	if((xx-x+1)>5){
		if(doleft(x,y,xx,yy,stx,sty,edx,edy)) return;
		if(doright(x,y,xx,yy,stx,sty,edx,edy)) return;
	}
	if((yy-y+1)>5){
		if(doup(x,y,xx,yy,stx,sty,edx,edy)) return;
		if(dodown(x,y,xx,yy,stx,sty,edx,edy)) return;
	}
}
bl doleft(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy){
	ll nx=stx,ny=sty,t=0;
	if(stx>edx){
		nx=edx;
		ny=edy;
		t=1;
	}
	if(nx>=(x+2)){
		dfs1(x+2,y,xx,yy,stx,sty,edx,edy);
		fr(i,y,yy-1){
			if(dir[x+2][i]==2){
				dir[x+2][i]=3;
				fr(j,y+1,i) dir[x+1][j]=0;
				dir[x+1][y]=3;
				fr(j,y,yy-1) dir[x][j]=2;
				dir[x][yy]=1;
				fr(j,i+2,yy) dir[x+1][j]=0;
				dir[x+1][i+1]=1;
				return 1;
			}
		}
		fr(i,y+1,yy){
			if(dir[x+2][i]==0){
				dir[x+2][i]=3;
				fr(j,i,yy-1) dir[x+1][j]=2;
				dir[x+1][yy]=3;
				fr(j,y+1,yy) dir[x][j]=0;
				dir[x][y]=1;
				fr(j,y,i-2) dir[x+1][j]=2;
				dir[x+1][i-1]=1;
				return 1;
			}
		}
	}
	if((x+2)<=(stx+edx-nx)){
		if(x==nx){
			if(ny>(y+1)){
				dfs1(x+2,y,xx,yy,stx+2*(!t),sty-2*(!t),edx+2*t,edy-2*t);
				fr(i,ny,yy-1) work(x,i,2,t);
				work(x,yy,1,t);
				fr(i,ny,yy) work(x+1,i,0,t);
				work(x+1,ny-1,3,t);
				fr(i,y+1,ny-1) work(x,i,0,t);
				work(x,y,1,t);
				fr(i,y,ny-3) work(x+1,i,2,t);
				work(x+1,ny-2,1,t);
			}
			else{
				dfs1(x+2,y,xx,yy,stx+2*(!t),sty+2*(!t),edx+2*t,edy+2*t);
				fr(i,y+1,ny) work(x,i,0,t);
				work(x,y,1,t);
				fr(i,y,ny) work(x+1,i,2,t);
				work(x+1,ny+1,3,t);
				fr(i,ny+1,yy-1) work(x,i,2,t);
				work(x,yy,1,t);
				fr(i,ny+3,yy) work(x+1,i,0,t);
				work(x+1,ny+2,1,t);
			}
		}
		else{
			if(ny>y){
				dfs1(x+2,y,xx,yy,stx+(!t),sty-(!t),edx+t,edy-t);
				fr(i,ny,yy-1) work(x+1,i,2,t);
				work(x+1,yy,3,t);
				fr(i,y+1,yy) work(x,i,0,t);
				work(x,y,1,t);
				fr(i,y,ny-2) work(x+1,i,2,t);
				work(x+1,ny-1,1,t);
			}
			else{
				dfs1(x+2,y,xx,yy,stx+(!t),sty+(!t),edx+t,edy+t);
				fr(i,y+1,ny) work(x+1,i,0,t);
				work(x+1,y,3,t);
				fr(i,y,yy-1) work(x,i,2,t);
				work(x,yy,1,t);
				fr(i,ny+2,yy) work(x+1,i,0,t);
				work(x+1,ny+1,1,t);
			}
		}
		return 1;
	}
	return 0;
}
bl doright(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy){
	ll nx=stx,ny=sty,t=0;
	if(stx<edx){
		nx=edx;
		ny=edy;
		t=1;
	}
	if(nx<=(xx-2)){
		dfs1(x,y,xx-2,yy,stx,sty,edx,edy);
		fr(i,y,yy-1){
			if(dir[xx-2][i]==2){
				dir[xx-2][i]=1;
				fr(j,y+1,i) dir[xx-1][j]=0;
				dir[xx-1][y]=1;
				fr(j,y,yy-1) dir[xx][j]=2;
				dir[xx][yy]=3;
				fr(j,i+2,yy) dir[xx-1][j]=0;
				dir[xx-1][i+1]=3;
				return 1;
			}
		}
		fr(i,y+1,yy){
			if(dir[xx-2][i]==0){
				dir[xx-2][i]=1;
				fr(j,i,yy-1) dir[xx-1][j]=2;
				dir[xx-1][yy]=1;
				fr(j,y+1,yy) dir[xx][j]=0;
				dir[xx][y]=3;
				fr(j,y,i-2) dir[xx-1][j]=2;
				dir[xx-1][i-1]=3;
				return 1;
			}
		}
	}
	if((xx-2)>=(stx+edx-nx)){
		if(xx==nx){
			if(ny<(yy-1)){
				dfs1(x,y,xx-2,yy,stx-2*(!t),sty+2*(!t),edx-2*t,edy+2*t);
				fr(i,y+1,ny) work(xx,i,0,t);
				work(xx,y,3,t);
				fr(i,y,ny) work(xx-1,i,2,t);
				work(xx-1,ny+1,1,t);
				fr(i,ny+1,yy-1) work(xx,i,2,t);
				work(xx,yy,3,t);
				fr(i,ny+3,yy) work(xx-1,i,0,t);
				work(xx-1,ny+2,3,t);
			}
			else{
				dfs1(x,y,xx-2,yy,stx-2*(!t),sty-2*(!t),edx-2*t,edy-2*t);
				fr(i,ny,yy-1) work(xx,i,2,t);
				work(xx,yy,3,t);
				fr(i,ny,yy) work(xx-1,i,0,t);
				work(xx-1,ny-1,1,t);
				fr(i,y+1,ny-1) work(xx,i,0,t);
				work(xx,y,3,t);
				fr(i,y,ny-3) work(xx-1,i,2,t);
				work(xx-1,ny-2,3,t);
			}
		}
		else{
			if(ny<yy){
				dfs1(x,y,xx-2,yy,stx-(!t),sty+(!t),edx-t,edy+t);
				fr(i,y+1,ny) work(xx-1,i,0,t);
				work(xx-1,y,1,t);
				fr(i,y,yy-1) work(xx,i,2,t);
				work(xx,yy,3,t);
				fr(i,ny+2,yy) work(xx-1,i,0,t);
				work(xx-1,ny+1,3,t);
			}
			else{
				dfs1(x,y,xx-2,yy,stx-(!t),sty-(!t),edx-t,edy-t);
				fr(i,ny,yy-1) work(xx-1,i,2,t);
				work(xx-1,yy,1,t);
				fr(i,y+1,yy) work(xx,i,0,t);
				work(xx,y,3,t);
				fr(i,y,ny-2) work(xx-1,i,2,t);
				work(xx-1,ny-1,3,t);
			}
		}
		return 1;
	}
	return 0;
}
bl doup(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy){
	ll nx=stx,ny=sty,t=0;
	if(sty>edy){
		nx=edx;
		ny=edy;
		t=1;
	}
	if(ny>=(y+2)){
		dfs1(x,y+2,xx,yy,stx,sty,edx,edy);
		fr(i,x,xx-1){
			if(dir[i][y+2]==1){
				dir[i][y+2]=0;
				fr(j,x+1,i) dir[j][y+1]=3;
				dir[x][y+1]=0;
				fr(j,x,xx-1) dir[j][y]=1;
				dir[xx][y]=2;
				fr(j,i+2,xx) dir[j][y+1]=3;
				dir[i+1][y+1]=2;
				return 1;
			}
		}
		fr(i,x+1,xx){
			if(dir[i][y+2]==3){
				dir[i][y+2]=0;
				fr(j,i,xx-1) dir[j][y+1]=1;
				dir[xx][y+1]=0;
				fr(j,x+1,xx) dir[j][y]=3;
				dir[x][y]=2;
				fr(j,x,i-2) dir[j][y+1]=1;
				dir[i-1][y+1]=2;
				return 1;
			}
		}
	}
	if((y+2)<=(sty+edy-ny)){
		if(y==ny){
			if(nx>(x+1)){
				dfs1(x,y+2,xx,yy,stx-2*(!t),sty+2*(!t),edx-2*t,edy+2*t);
				fr(i,nx,xx-1) work(i,y,1,t);
				work(xx,y,2,t);
				fr(i,nx,xx) work(i,y+1,3,t);
				work(nx-1,y+1,0,t);
				fr(i,x+1,nx-1) work(i,y,3,t);
				work(x,y,2,t);
				fr(i,x,nx-3) work(i,y+1,1,t);
				work(nx-2,y+1,2,t);
			}
			else{
				dfs1(x,y+2,xx,yy,stx+2*(!t),sty+2*(!t),edx+2*t,edy+2*t);
				fr(i,x+1,nx) work(i,y,3,t);
				work(x,y,2,t);
				fr(i,x,nx) work(i,y+1,1,t);
				work(nx+1,y+1,0,t);
				fr(i,nx+1,xx-1) work(i,y,1,t);
				work(xx,y,2,t);
				fr(i,nx+3,xx) work(i,y+1,3,t);
				work(nx+2,y+1,2,t);
			}
		}
		else{
			if(nx>x){
				dfs1(x,y+2,xx,yy,stx-(!t),sty+(!t),edx-t,edy+t);
				fr(i,nx,xx-1) work(i,y+1,1,t);
				work(xx,y+1,0,t);
				fr(i,x+1,xx) work(i,y,3,t);
				work(x,y,2,t);
				fr(i,x,nx-2) work(i,y+1,1,t);
				work(nx-1,y+1,2,t);
			}
			else{
				dfs1(x,y+2,xx,yy,stx+(!t),sty+(!t),edx+t,edy+t);
				fr(i,x+1,nx) work(i,y+1,3,t);
				work(x,y+1,0,t);
				fr(i,x,xx-1) work(i,y,1,t);
				work(xx,y,2,t);
				fr(i,nx+2,xx) work(i,y+1,3,t);
				work(nx+1,y+1,2,t);
			}
		}
		return 1;
	}
	return 0;
}
bl dodown(ll x,ll y,ll xx,ll yy,ll stx,ll sty,ll edx,ll edy){
	ll nx=stx,ny=sty,t=0;
	if(sty<edy){
		nx=edx;
		ny=edy;
		t=1;
	}
	if(ny<=(yy-2)){
		dfs1(x,y,xx,yy-2,stx,sty,edx,edy);
		fr(i,x,xx-1){
			if(dir[i][yy-2]==1){
				dir[i][yy-2]=2;
				fr(j,x+1,i) dir[j][yy-1]=3;
				dir[x][yy-1]=2;
				fr(j,x,xx-1) dir[j][yy]=1;
				dir[xx][yy]=0;
				fr(j,i+2,xx) dir[j][yy-1]=3;
				dir[i+1][yy-1]=0;
				return 1;
			}
		}
		fr(i,x+1,xx){
			if(dir[i][yy-2]==3){
				dir[i][yy-2]=2;
				fr(j,i,xx-1) dir[j][yy-1]=1;
				dir[xx][yy-1]=2;
				fr(j,x+1,xx) dir[j][yy]=3;
				dir[x][yy]=0;
				fr(j,x,i-2) dir[j][yy-1]=1;
				dir[i-1][yy-1]=0;
				return 1;
			}
		}
	}
	if((yy-2)>=(sty+edy-ny)){
		if(yy==ny){
			if(nx<(xx-1)){
				dfs1(x,y,xx,yy-2,stx+2*(!t),sty-2*(!t),edx+2*t,edy-2*t);
				fr(i,x+1,nx) work(i,yy,3,t);
				work(x,yy,0,t);
				fr(i,x,nx) work(i,yy-1,1,t);
				work(nx+1,yy-1,2,t);
				fr(i,nx+1,xx-1) work(i,yy,1,t);
				work(xx,yy,0,t);
				fr(i,nx+3,xx) work(i,yy-1,3,t);
				work(nx+2,yy-1,0,t);
			}
			else{
				dfs1(x,y,xx,yy-2,stx-2*(!t),sty-2*(!t),edx-2*t,edy-2*t);
				fr(i,nx,xx-1) work(i,yy,1,t);
				work(xx,yy,0,t);
				fr(i,nx,xx) work(i,yy-1,3,t);
				work(nx-1,yy-1,2,t);
				fr(i,x+1,nx-1) work(i,yy,3,t);
				work(x,yy,0,t);
				fr(i,x,nx-3) work(i,yy-1,1,t);
				work(nx-2,yy-1,0,t);
			}
		}
		else{
			if(nx<xx){
				dfs1(x,y,xx,yy-2,stx+(!t),sty-(!t),edx+t,edy-t);
				fr(i,x+1,nx) work(i,yy-1,3,t);
				work(x,yy-1,2,t);
				fr(i,x,xx-1) work(i,yy,1,t);
				work(xx,yy,0,t);
				fr(i,nx+2,xx) work(i,yy-1,3,t);
				work(nx+1,yy-1,0,t);
			}
			else{
				dfs1(x,y,xx,yy-2,stx-(!t),sty-(!t),edx-t,edy-t);
				fr(i,nx,xx-1) work(i,yy-1,1,t);
				work(xx,yy-1,2,t);
				fr(i,x+1,xx) work(i,yy,3,t);
				work(x,yy,0,t);
				fr(i,x,nx-2) work(i,yy-1,1,t);
				work(nx-1,yy-1,0,t);
			}
		}
		return 1;
	}
	return 0;
}
void print(ll stx,ll sty,ll edx,ll edy){
	fr(j,1,m){
		fr(i,1,n){
			if(i==stx&&j==sty) pf("S");
			else if(i==edx&&j==edy) pf("T");
			else pf("o");
			if(i<n&&dir[i][j]==1&&(i!=edx||j!=edy)) pf("--->");
			else if(i<n&&dir[i+1][j]==3&&((i+1)!=edx||j!=edy)) pf("<---");
			else pf("    ");
		}
		enter;
		if(j<m){
			fr(i,1,n){
				if(dir[i][j]==2&&(i!=edx||j!=edy)) pf("|");
				else if(dir[i][j+1]==0&&(i!=edx||(j+1)!=edy)) pf("^");
				else pf(" ");
				if(i<n) pf("    ");
			}
			enter;
			fr(i,1,n){
				if(dir[i][j]==2&&(i!=edx||j!=edy)) pf("v");
				else if(dir[i][j+1]==0&&(i!=edx||(j+1)!=edy)) pf("|");
				else pf(" ");
				if(i<n) pf("    ");
			}
			enter;
		}
	}
}
int main(){
//	freopen("wa.out","w",stdout);
	n=read();
	m=read();
	ll stx=read(),sty=read(),edx=read(),edy=read();
	bl ck1=0,ck2=0;
	if(stx>edx){
		swap(stx,edx);
		ck1=1;
	}
	if(sty>edy){
		swap(sty,edy);
		ck2=1;
	}
	if(n*m%2==0&&(stx+sty)%2==(edx+edy)%2){
		pf("NIE");
		return 0;
	}
	if(n*m%2==1&&(stx+sty)%2!=(edx+edy)%2){
		pf("NIE");
		return 0;
	}
	dfs1(1,1,n,m,stx,sty,edx,edy);
//	print(stx,sty,edx,edy);
	ll x=stx,y=sty;
	while(x!=edx||y!=edy){
		ll o=dir[x][y],nx=x+d[o][0],ny=y+d[o][1];
		if(ck1&&(o&1)) o^=2;
		if(ck2&&!(o&1)) o^=2;
		if(!o) pc('G');
		else if(o==1) pc('P');
		else if(o==2) pc('D');
		else pc('L');
		x=nx;
		y=ny;
	}
}
/*
6 6
1 1
1 2

64 32
35 13
48 15
ans:
not NIE(YAK)

14 11
10 9
5 3
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3300kb

input:

4 4
1 1
1 4

output:

PPPDDDLGGLLDPDL

result:

ok correct path

Test #2:

score: 0
Accepted
time: 2ms
memory: 3316kb

input:

4 4
3 2
2 3

output:

NIE

result:

ok no solution

Test #3:

score: 0
Accepted
time: 2ms
memory: 3548kb

input:

5 5
1 2
1 4

output:

NIE

result:

ok no solution

Test #4:

score: 0
Accepted
time: 0ms
memory: 3312kb

input:

6 6
1 1
1 4

output:

DPGPPPPDDDDDLGGGGLLDPDDDLLLGPPGLGLD

result:

ok correct path

Test #5:

score: 0
Accepted
time: 2ms
memory: 5312kb

input:

4 5
2 3
3 5


output:

GGLDDDDPGPGGGPDDDDL

result:

ok correct path

Test #6:

score: 0
Accepted
time: 2ms
memory: 3372kb

input:

4 6
1 2
2 5

output:

NIE

result:

ok no solution

Test #7:

score: 0
Accepted
time: 2ms
memory: 5308kb

input:

6 6
1 5
4 5

output:

DPGGLGGGPDDPGGPPPDLLDPPDDDLGGLLDDPG

result:

ok correct path

Test #8:

score: 0
Accepted
time: 1ms
memory: 5212kb

input:

38 6
33 5
36 5

output:

LGGGGLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLDDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPGGGGPDDDDPPPGGLGGGPDDPGGPPPDLLDPPDDDLGGLLDDPG

result:

ok correct path

Test #9:

score: 0
Accepted
time: 1ms
memory: 5348kb

input:

57 6
26 3
29 5

output:

DDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGGPPPPPPPPPPPPPPPPPPPPPPPPPDPGPDDLDDDPGGPGGGPPPPPPPPPPPPPPPPPPPPPPPPPPPPDDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGLDDDDLGGGGL...

result:

ok correct path

Test #10:

score: 0
Accepted
time: 1ms
memory: 5348kb

input:

64 126
45 13
48 15


output:

LGGGGGGGGGGGGLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDPGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG...

result:

ok correct path

Test #11:

score: 0
Accepted
time: 3ms
memory: 5476kb

input:

64 32
35 13
48 15


output:

LGGGGGGGGGGGGLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDPGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGPDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDPGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGPDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDPGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGPDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDPGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGPDDDDD...

result:

ok correct path

Test #12:

score: 0
Accepted
time: 2ms
memory: 5340kb

input:

7 6
2 6
6 3


output:

GGGLDDDDDPGPDPPPPGLLLGLGPGLGPPDDDPPGLGPGL

result:

ok correct path

Test #13:

score: 0
Accepted
time: 0ms
memory: 3320kb

input:

7 6
7 3
2 5


output:

DDDPGGGGGLDLGLLLLDPPPDPDLLGLLDPDPPPDLLLLG

result:

ok correct path

Test #14:

score: 0
Accepted
time: 2ms
memory: 3320kb

input:

7 6
6 3
2 4


output:

DDDPGGGGGLDLGLLLLDPPPDPDLLGLLDDDPPPPGLLLG

result:

ok correct path

Test #15:

score: -100
Checker Runtime Error

input:

7 6
5 1
1 4


output:

LDPDDDDLGGGLGGLLLLDPPPDLLLDDDPPPPGGLDLLGP

result: