QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#704986#9521. Giving Directions in Harbin2366503423WA 1ms3668kbC++141.0kb2024-11-02 21:47:022024-11-02 21:47:03

Judging History

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

  • [2024-11-02 21:47:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3668kb
  • [2024-11-02 21:47:02]
  • 提交

answer

#include <bits/stdc++.h> 
using namespace std;
int main()
{
	int t;cin>>t;
	while(t--)
	{
		int n;cin>>n;
		int x=0,y=0;
		while(n--)
		{
			char f;int len;cin>>f>>len;
			if(f=='N') x-=len;
			else if(f=='S') x+=len;
			else if(f=='W') y-=len;
			else if(f=='E') y+=len;
		}
	//	cout<<"x="<<x<<" y="<<y<<'\n';
	    if(x==0&&y==0)
	    {
	    	cout<<"3 E\n"<<"Z 1\n"<<"R\n"<<"Z 1\n"<<"R\n"<<"Z 1\n"<<"R\n"<<"Z 1\n";
		}
		else if(x==0&&y!=0)
		{
			if(y>0) cout<<1<<" E\n"<<"Z "<<y<<'\n';	
			else if(y<0) cout<<1<<" W\n"<<"Z "<<-y<<'\n';
		}
		else if(y==0&&x!=0)
		{
			if(x>0) cout<<1<<" S\n"<<"Z "<<x<<'\n';	
			else if(x<0) cout<<1<<" N\n"<<"Z "<<-x<<'\n';
		}
		else
		{
			cout<<3;
			if(y>0)
			{
				cout<<" E\n"<<"Z "<<y<<'\n';
				if(x>0) cout<<"R\n"<<"Z "<<x<<'\n';	
				else if(x<0) cout<<"L\n"<<"Z "<<-x<<'\n';	
			}
			else if(y<0)
			{
				cout<<" W\n"<<"Z "<<-y<<'\n'; 
				if(x>0) cout<<"L\n"<<"Z "<<x<<'\n';	
				else if(x<0) cout<<"R\n"<<"Z "<<-x<<'\n';	
			}
			
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3652kb

input:

1
2
S 2
E 1

output:

3 E
Z 1
R
Z 2

result:

ok ok (1 test case)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3668kb

input:

99
4
E 6
N 1
W 2
S 8
8
W 10
N 1
E 10
S 2
E 2
N 2
W 2
S 1
9
N 5
E 4
N 7
E 6
S 9
E 8
N 4
W 6
N 7
6
N 6
E 6
N 8
W 9
S 7
E 2
8
E 6
S 9
W 5
S 4
W 6
N 4
E 5
N 9
8
N 6
W 10
N 6
W 6
S 6
E 6
S 6
E 10
10
N 7
W 3
N 5
W 5
S 8
W 10
N 6
E 9
N 8
E 8
8
W 9
N 10
E 6
S 10
E 9
S 10
W 6
N 10
4
W 5
N 1
E 5
S 1
4
W 4
S 8...

output:

3 E
Z 4
R
Z 7
3 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 E
Z 12
L
Z 14
3 W
Z 1
R
Z 7
3 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 W
Z 1
R
Z 18
3 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 E
Z 9
R
Z 3
1 W
Z 10
3 E
Z 1
R
Z 1
R
Z 1
R
Z 1
3 W
Z 9
L
...

result:

wrong answer Wrong destination (test case 2)