QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#710375 | #9521. Giving Directions in Harbin | HaoHaovo | WA | 0ms | 3664kb | C++23 | 1.8kb | 2024-11-04 19:37:05 | 2024-11-04 19:37:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ull unsigned long long
#define inf 0x3f3f3f3f3f3f3f3f // int请忽略后四个3f
#define endl '\n'
#define YES cout<<"YES\n";
#define NO cout<<"NO\n";
const double eps = 1e-14;
const int maxn = 3e5 + 10;
const int mod = 998244353;
inline int read()
{
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
x = x * 10 + ch - '0', ch = getchar();
return x * f;
}
void solve(int _) {
int n;
cin >> n;
vector<int>v(n + 1);
vector<char>w(n + 1);
for (int i = 1; i <= n; i++) {
cin >> w[i] >> v[i];
}
vector<pair<int,char>>ans;
char x = w[1];
char now=w[1];
char qq=';';
ans.push_back({v[1],'Z'});
for (int i = 2; i <= n; i++) {
if(now=='N'){
if(w[i]=='W')ans.push_back({0,'L'});
else ans.push_back({0,'R'});
}else if(now=='S'){
if(w[i]=='W')ans.push_back({0,'R'});
else ans.push_back({0,'L'});
}else if(now=='W'){
if(w[i]=='N')ans.push_back({0,'R'});
else ans.push_back({0,'L'});
}else if(now=='E'){
if(w[i]=='N')ans.push_back({0,'L'});
else ans.push_back({0,'R'});
}
now=ans[ans.size()-1].second;
ans.push_back({v[i],'Z'});
}
cout<<ans.size()<<" "<<x<<endl;
for(auto [a,b]:ans){
if(a==0)cout<<b<<endl;
else cout<<b<<" "<<a<<endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int _ = 1;
cin >> _;
for (int i = 1; i <= _; i++) {
solve(i);
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3664kb
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: 0ms
memory: 3456kb
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:
5 E Z 6 L Z 1 Z 2 Z 8 9 W Z 10 R Z 1 Z 10 Z 2 Z 2 Z 2 Z 2 Z 1 10 N Z 5 R Z 4 Z 7 Z 6 Z 9 Z 8 Z 4 Z 6 Z 7 7 N Z 6 R Z 6 Z 8 Z 9 Z 7 Z 2 9 E Z 6 R Z 9 Z 5 Z 4 Z 6 Z 4 Z 5 Z 9 9 N Z 6 L Z 10 Z 6 Z 6 Z 6 Z 6 Z 6 Z 10 11 N Z 7 L Z 3 Z 5 Z 5 Z 8 Z 10 Z 6 Z 9 Z 8 Z 8 9 W Z 9 R Z 10 Z 6 Z 10 Z 9 Z 10 Z 6 Z ...
result:
wrong answer Same direction appears twice (test case 1)