QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#704941#9521. Giving Directions in Harbin2366503423WA 1ms3708kbC++14924b2024-11-02 21:34:592024-11-02 21:35:00

Judging History

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

  • [2024-11-02 21:35:00]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-11-02 21:34:59]
  • 提交

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)
		{
			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)
		{
			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: 3708kb

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: 3600kb

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 12
L
Z 14
3 W
Z 1
R
Z 7
3 W
Z 1
R
Z 18
3 E
Z 9
R
Z 3
1 W
Z 10
3 W
Z 9
L
Z 16
3 W
Z 3
R
Z 4
3 E
Z 5
R
Z 7
3 E
Z 3
R
Z 12
3 W
Z 6
L
Z 9
3 E
Z 8
R
Z 8
3 W
Z 4
L
Z 8
3 E
Z 9
L
Z 5
1 N
Z 10
3 W
Z 2
L
Z 5
3 E
Z 12
R
Z 10
3 W
Z 9
L
Z 1
3 E
Z 13
L
Z 14
3 E
Z 9
L
Z 4
1 N
Z 9
3 E
Z 1
R
Z 1...

result:

wrong answer Wrong destination (test case 2)