QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#95398 | #5130. Failing Flagship | _b_ | AC ✓ | 2ms | 3736kb | C++14 | 1.5kb | 2023-04-09 16:09:58 | 2023-04-09 16:10:02 |
Judging History
answer
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define ld long double
double angle(string s) {
int len = s.length();
ld Init_angle = 0.0;
if (len == 1) {
switch (s[len - 1]) {
case 'N': Init_angle = 0.0; break;
case 'E': Init_angle = 90.0; break;
case 'S': Init_angle = 180.0; break;
case 'W': Init_angle = 270.0; break;
}
}
else if (len >= 2) {
string tmp = s.substr(len - 2, 2);
ld angle = 45.0;
if (tmp == "NE") {
Init_angle = 45.0;
for (int i = len - 3; i >= 0; i--) {
angle /= 2.0;
if (s[i] == 'N')
Init_angle -= angle;
else
Init_angle += angle;
}
}
else if (tmp == "SE") {
Init_angle = 135.0;
for (int i = len - 3; i >= 0; i--) {
angle /= 2.0;
if (s[i] == 'E')
Init_angle -= angle;
else
Init_angle += angle;
}
}
else if (tmp == "SW") {
Init_angle = 225.0;
for (int i = len - 3; i >= 0; i--) {
angle /= 2.0;
if (s[i] == 'S')
Init_angle -= angle;
else
Init_angle += angle;
}
}
else if (tmp == "NW") {
Init_angle = 315.0;
for (int i = len - 3; i >= 0; i--) {
angle /= 2.0;
if (s[i] == 'W')
Init_angle -= angle;
else
Init_angle += angle;
}
}
}
return Init_angle;
}
int main() {
string s1, s2;
cin >> s1 >> s2;
ld tmp1 = angle(s1); ld tmp2 = angle(s2);
cout << setprecision(18) << min(abs(tmp1 - tmp2), (ld)360.0 - abs(tmp1 - tmp2));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3464kb
input:
N S
output:
180
result:
ok found '180.0000000', expected '180.0000000', error '0.0000000'
Test #2:
score: 0
Accepted
time: 2ms
memory: 3644kb
input:
NNE SSSE
output:
146.25
result:
ok found '146.2500000', expected '146.2500000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3460kb
input:
ENE NW
output:
112.5
result:
ok found '112.5000000', expected '112.5000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3392kb
input:
SW SE
output:
90
result:
ok found '90.0000000', expected '90.0000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3716kb
input:
NENE SESSE
output:
95.625
result:
ok found '95.6250000', expected '95.6250000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3680kb
input:
NWWNNWNWNW E
output:
148.53515625
result:
ok found '148.5351562', expected '148.5351562', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
SWWWSWSSSSW NNNNNNNNNNNW
output:
171.7822265625
result:
ok found '171.7822266', expected '171.7822266', error '0.0000000'
Test #8:
score: 0
Accepted
time: 2ms
memory: 3672kb
input:
N N
output:
0
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #9:
score: 0
Accepted
time: 1ms
memory: 3712kb
input:
S N
output:
180
result:
ok found '180.0000000', expected '180.0000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 2ms
memory: 3720kb
input:
NW SE
output:
180
result:
ok found '180.0000000', expected '180.0000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 2ms
memory: 3464kb
input:
SE SESE
output:
11.25
result:
ok found '11.2500000', expected '11.2500000', error '0.0000000'
Test #12:
score: 0
Accepted
time: 2ms
memory: 3540kb
input:
SE SSESE
output:
5.625
result:
ok found '5.6250000', expected '5.6250000', error '0.0000000'
Test #13:
score: 0
Accepted
time: 2ms
memory: 3472kb
input:
EEENE ENENE
output:
22.5
result:
ok found '22.5000000', expected '22.5000000', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
NW NNWWNNNNWNWNNNNNNNNNWNNNWNWNWWNWNWNWNWNWWNNNNNNNNNNNWNWNWWWNWNNWNWWWWWWNWWWNNNWNNWNNNNNNNWWWWWNNNNNNWNWWWNNWNWNWNNNNNNWWNWWWNNNNWNNWWNNNNWWWWNWNNWWWNNWWWNNNWNNWWWWWWWNNWWWWWNWNNNNWWWNWWNNNWNWNWNNNNWNNWWWNWNNNNWWWWNNNWWNWNWNWNNNWNWNNWNWNWNNNNNNWNNNWWNNNNNWNWWWNWWNWNWWWWWNWNNWWWNNWNWNNWNWWWWWWWNNWW...
output:
3.14750246340423701
result:
ok found '3.1475025', expected '3.1475025', error '0.0000000'
Test #15:
score: 0
Accepted
time: 2ms
memory: 3648kb
input:
WNWWNWNWNNNWNWWWWNNNWWNWNWWNNWNNWWWNWNNWWWWWWWWWNWWNWNNWWNWNNNWWNNNNNNNWWWWNWWNWWNWWWNNWNWNWNNNNNNWNWWNNNWNWWWNNNNWWNWNWWWWWNWWWNWWWWWNNWNNWWNWWWWNNWNWNNWNNNWWNNNWWWWWNNWWWWWWNNWWNWNNWWWNNNNWNNNNNNWNNNWNNWNWWWWWWNNNNNWNWNNNWWNNNWNNNNNWWNWNWNWNNWNNNNNWWWNNNNNNWNNWNNNNWWWWNNNWNWWWWWNWWNWWWNNNWWWWWNWWN...
output:
82.266154781057935
result:
ok found '82.2661548', expected '82.2661548', error '0.0000000'
Test #16:
score: 0
Accepted
time: 2ms
memory: 3476kb
input:
NNNENNNNEENNEEENEENNNNENNNENEENEENNNNENENEENNNEENE WNNWWNWWWNNWNNNNWWNWNNWNNNWNNWWNNWWWWWNWNNWWNNWNNWNNNWNWWNWWNNNWNWNNWWWWWWWWWWWWNWWNNWWWNNNNWWWNNWNWNNNNWWNNNWNWNWNNNWWNNWWWNWWNNWNWNNNWNWWNWNNNNNNNNNWWWNWWNWWWNWNWNWNNNWNNNWNNWNWNWWWNNWWWWWWNWNNNNNWNNWWWWNNNNNNWWWNWNWNWNWNWNNWNWWWNNNNWNNWWWNWNWNWWW...
output:
82.7795003411508645
result:
ok found '82.7795003', expected '82.7795003', error '0.0000000'
Test #17:
score: 0
Accepted
time: 0ms
memory: 3552kb
input:
WNNWNWWWWNNWWWWNWNNWWNNWWNWNNWNWWWWWNWNWNNWWNNWWNNNNWNNNNWWNWNNNWNWNWNWWWNNWNWWNNWWWNWNWWWNWWNNWWNWNWNNWNWWWWNNWNWNNNNWWNWWWNWNWNWNWNNNNWNWWNNNNNNNWNNWWNNWNWWNNWWNNWWWWWWWNNWNWNWWWNNWWWNWNWWNWNNWWNWNNWNNNNNNNNWWWWNWNNNNWNNWWNNNNWNWWNWWNNWNWNNWNNNNWWNWWNWNNWWWWWNNWNNNNWWWWNNWWWNWWNWWNNWNWNNWNNNNWNWWN...
output:
124.593236661150897
result:
ok found '124.5932367', expected '124.5932367', error '0.0000000'
Test #18:
score: 0
Accepted
time: 2ms
memory: 3656kb
input:
SSSEEEEEESEEEESSESEEEEEEEEESSEEESSESSESSSESSSESEEEEESSSSEESSSSSEESSSESESEEESEESEEEEEEESSSSESSESSESEESEESSESEESESSSSEESSESSESSEESEEEESSESEEEEEEEESEEEESEESEESSESEESEEESEESESEESSEESESESESSESESESSEESSEEESEESESESEEESESSSESEESESSESEESSSESESSESEESSEEEESSSSSSESSEESSSSEESEESESSESSSEESSEEESSSESEEESSSEEEEESEES...
output:
132.995310618995219
result:
ok found '132.9953106', expected '132.9953106', error '0.0000000'
Test #19:
score: 0
Accepted
time: 2ms
memory: 3724kb
input:
WWNWNNNWNWNNWNNNNNWNNWNWNWNWWWWWNWNWNNWWNWWWWNNNWNWWWWWWWWWWWWNNNNNNNWWWWNNNWNWNWWWNNWWNNNNNWWWWWNWWNWWNWNWNNNWNWWNNNNNNWNNNWNNWWNWWWWNNNNNNNWNNWWWWWNNWWWNWWWWWWWNWWNNWWWNNNNNNWNNWNNNNNWNWNNNNWWNNNNNWWNNNNWWNWNNWNWNNNWWWWWWWNWNNNNNWNWWNWWWWWNNNNWNNNNNWWWWWWWWWNWWNWNWNNNWNNWWNNNWWWNWWNNWWWNNNNWWWNNNW...
output:
153.445052118082401
result:
ok found '153.4450521', expected '153.4450521', error '0.0000000'
Test #20:
score: 0
Accepted
time: 2ms
memory: 3640kb
input:
N NNNNNNNNNW
output:
0.17578125
result:
ok found '0.1757812', expected '0.1757812', error '0.0000000'
Test #21:
score: 0
Accepted
time: 2ms
memory: 3648kb
input:
N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNE
output:
4.09272615797817707e-11
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #22:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSW
output:
8.52651282912120223e-14
result:
ok found '0.0000000', expected '0.0000000', error '0.0000000'
Test #23:
score: 0
Accepted
time: 2ms
memory: 3544kb
input:
S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSE
output:
0
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #24:
score: 0
Accepted
time: 2ms
memory: 3552kb
input:
N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...
output:
0
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #25:
score: 0
Accepted
time: 2ms
memory: 3676kb
input:
NE EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...
output:
0
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #26:
score: 0
Accepted
time: 2ms
memory: 3460kb
input:
E W
output:
180
result:
ok found '180.0000000', expected '180.0000000', error '0.0000000'
Test #27:
score: 0
Accepted
time: 1ms
memory: 3464kb
input:
W E
output:
180
result:
ok found '180.0000000', expected '180.0000000', error '0.0000000'
Test #28:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
EEEEEEEEEEEEEEEEEEEENE W
output:
179.999957084655762
result:
ok found '179.9999571', expected '179.9999571', error '0.0000000'
Test #29:
score: 0
Accepted
time: 1ms
memory: 3676kb
input:
EEEEEEEEEEEEEEEEEEEESE W
output:
179.999957084655762
result:
ok found '179.9999571', expected '179.9999571', error '0.0000000'
Test #30:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
EEEEEEEEEEEEEEEEEEEEESE W
output:
179.999978542327881
result:
ok found '179.9999785', expected '179.9999785', error '0.0000000'
Test #31:
score: 0
Accepted
time: 2ms
memory: 3452kb
input:
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEESE W
output:
179.999999958090484
result:
ok found '180.0000000', expected '180.0000000', error '0.0000000'
Test #32:
score: 0
Accepted
time: 0ms
memory: 3496kb
input:
SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWSSW
output:
0
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'
Test #33:
score: 0
Accepted
time: 2ms
memory: 3468kb
input:
SSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWSSW
output:
4.291534423828125e-05
result:
ok found '0.0000429', expected '0.0000429', error '0.0000000'
Test #34:
score: 0
Accepted
time: 2ms
memory: 3668kb
input:
SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW
output:
0
result:
ok found '0.0000000', expected '0.0000000', error '-0.0000000'