QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#216625 | #5130. Failing Flagship | MovingUp# | WA | 0ms | 3908kb | C++20 | 974b | 2023-10-15 20:37:35 | 2023-10-15 20:37:36 |
Judging History
answer
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
using namespace std;
map<string, double> defaultAngles;
double getAngle(string s) {
if (s.size() <= 2) {
return defaultAngles[s];
}
double x = getAngle(s.substr(1));
double y = defaultAngles[s.substr(0, 1)];
if (s.substr(s.size() - 2, 2) == "NW") {
if (y == 0)
y = 360;
}
return (x + y) / 2;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(8);
defaultAngles["N"] = 0;
defaultAngles["E"] = 90;
defaultAngles["S"] = 180;
defaultAngles["W"] = 270;
defaultAngles["NE"] = 45;
defaultAngles["SE"] = 135;
defaultAngles["SW"] = 225;
defaultAngles["NW"] = 315;
string s, t;
cin >> s >> t;
double angleS = getAngle(s);
double angleT = getAngle(t);
if (abs(angleS - angleT) < 180) {
cout << abs(angleS - angleT) << endl;
} else {
cout << 360 - abs(angleS - angleT) << endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3784kb
input:
N S
output:
180.00000000
result:
ok found '180.0000000', expected '180.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
NNE SSSE
output:
146.25000000
result:
ok found '146.2500000', expected '146.2500000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3892kb
input:
ENE NW
output:
112.50000000
result:
ok found '112.5000000', expected '112.5000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
SW SE
output:
90.00000000
result:
ok found '90.0000000', expected '90.0000000', error '0.0000000'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3776kb
input:
NENE SESSE
output:
118.12500000
result:
wrong answer 1st numbers differ - expected: '95.6250000', found: '118.1250000', error = '0.2352941'