QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#697778#9521. Giving Directions in HarbinzzisjtuWA 1ms3648kbC++231.1kb2024-11-01 15:44:432024-11-01 15:44:44

Judging History

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

  • [2024-11-01 15:44:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3648kb
  • [2024-11-01 15:44:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
struct node {
	char x, y;
};
void solve() {
	int n;
	cin >> n;
	vector<node> a(n + 1);
	for(int i = 1; i <= n; i++) {
		cin >> a[i].x >> a[i].y;
		// cout << a[i].x << " " << a[i].y << endl;
	}
	char c = a[1].x;
	auto b = c;
	map<char, int>mp;
	mp['N'] = 1;mp['S'] = 3;
	mp['W'] = 4;mp['E'] = 2;
	vector<pair<char, char>> ans;
	ans.push_back({'Z', a[1].y});
	// cout << a[1].y << endl;
	for(int i = 2; i <= n; i++) {
		if(mp[a[i].x] > mp[c]) {
			int t = mp[a[i].x] - mp[c];
			if(t == 1) {
				ans.push_back({'R', ' '});
			}
			else ans.push_back({'L', ' '});
		}
		else if(mp[a[i].x] < mp[c]) {
			int t = mp[a[i].x] - mp[c];
			t = -t;
			if(t == 1) {
				ans.push_back({'L', ' '});
			}
			else ans.push_back({'R', ' '});
		}
		ans.push_back({'Z', a[i].y});
		c = a[i].x;
	}
	cout << ans.size() << " " << b << endl;
	for(auto [x, y]: ans) {
		cout << x << " " << y << endl;
	}
}

#undef int
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	cin >> t;
	while(t--) {
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
2
S 2
E 1

output:

3 S
Z 2
L  
Z 1

result:

ok ok (1 test case)

Test #2:

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

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:

7 E
Z 6
L  
Z 1
L  
Z 2
L  
Z 8
13 W
Z 1
R  
Z N
Z E
Z 0
L  
Z 2
L  
Z 2
L  
Z 2
L  
Z 2
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B
Z }
1 B...

result:

wrong output format Expected integer, but "N" found (test case 2)