QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131846 | #5130. Failing Flagship | mshcherba# | WA | 1ms | 3836kb | C++17 | 1.1kb | 2023-07-28 15:49:41 | 2023-07-28 15:49:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long double db;
map<char, int> dir = {{'N', 0}, {'E', 90}, {'S', 180}, {'W', 270}};
db getAngle(string s) {
bool ne = true;
for (char c : s) {
ne &= c == 'N' || c == 'E';
}
db res = 0;
RFOR(i, SZ(s), 0) {
db cur = s[i] == 'N' && !ne ? 360 : dir[s[i]];
if (i == SZ(s) - 1) {
res = cur;
}
else {
res = (res + cur) / 2;
}
}
return res;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(10);
string s, t;
cin >> s >> t;
db a = getAngle(s), b = getAngle(t), d = abs(a - b);
cerr << a << " " << b << endl;
cout << min(d, 360 - d) << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
input:
N S
output:
180.0000000000
result:
ok found '180.0000000', expected '180.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
NNE SSSE
output:
146.2500000000
result:
ok found '146.2500000', expected '146.2500000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3836kb
input:
ENE NW
output:
112.5000000000
result:
ok found '112.5000000', expected '112.5000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
SW SE
output:
90.0000000000
result:
ok found '90.0000000', expected '90.0000000', error '0.0000000'
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 3644kb
input:
NENE SESSE
output:
118.1250000000
result:
wrong answer 1st numbers differ - expected: '95.6250000', found: '118.1250000', error = '0.2352941'