QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131857#5130. Failing FlagshipYarema#AC ✓1ms3844kbC++171.1kb2023-07-28 16:24:182023-07-28 16:24:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-28 16:24:19]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3844kb
  • [2023-07-28 16:24:18]
  • 提交

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;

const int INF = 1e9 + 7;

map<char, int> m;

double ang(string s)
{
	double l = m[s[0]];
	if (SZ(s) == 1) return l;
	double r = m[s[1]];
	if (s[0] == 'W' && s[1] == 'N') r = 360;
	FOR (i, 2, SZ(s))
	{
		double mid = (l + r) / 2;
		if (s[i] == s[0])
			r = mid;
		else
			l = mid;
	}
	return (l + r) / 2;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	m['N'] = 0;
	m['E'] = 90;
	m['S'] = 180;
	m['W'] = 270;
	
	string s, t;
	cin >> s >> t;
	reverse(ALL(s));
	reverse(ALL(t));
	
	double ans = ang(t) - ang(s);
	if (ans < 0) ans += 360;
	if (ans > 180) ans = 360 - ans;
	cout << fixed << setprecision(17) << ans << '\n';
	
	return 0;
}

详细

Test #1:

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

input:

N S

output:

180.00000000000000000

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

NNE SSSE

output:

146.25000000000000000

result:

ok found '146.2500000', expected '146.2500000', error '0.0000000'

Test #3:

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

input:

ENE NW

output:

112.50000000000000000

result:

ok found '112.5000000', expected '112.5000000', error '0.0000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3596kb

input:

SW SE

output:

90.00000000000000000

result:

ok found '90.0000000', expected '90.0000000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

NENE SESSE

output:

95.62500000000000000

result:

ok found '95.6250000', expected '95.6250000', error '0.0000000'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

NWWNNWNWNW E

output:

148.53515625000000000

result:

ok found '148.5351562', expected '148.5351562', error '0.0000000'

Test #7:

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

input:

SWWWSWSSSSW NNNNNNNNNNNW

output:

171.78222656250000000

result:

ok found '171.7822266', expected '171.7822266', error '0.0000000'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

N N

output:

0.00000000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #9:

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

input:

S N

output:

180.00000000000000000

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #10:

score: 0
Accepted
time: 1ms
memory: 3700kb

input:

NW SE

output:

180.00000000000000000

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #11:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

SE SESE

output:

11.25000000000000000

result:

ok found '11.2500000', expected '11.2500000', error '0.0000000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

SE SSESE

output:

5.62500000000000000

result:

ok found '5.6250000', expected '5.6250000', error '0.0000000'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

EEENE ENENE

output:

22.50000000000000000

result:

ok found '22.5000000', expected '22.5000000', error '0.0000000'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

NW NNWWNNNNWNWNNNNNNNNNWNNNWNWNWWNWNWNWNWNWWNNNNNNNNNNNWNWNWWWNWNNWNWWWWWWNWWWNNNWNNWNNNNNNNWWWWWNNNNNNWNWWWNNWNWNWNNNNNNWWNWWWNNNNWNNWWNNNNWWWWNWNNWWWNNWWWNNNWNNWWWWWWWNNWWWWWNWNNNNWWWNWWNNNWNWNWNNNNWNNWWWNWNNNNWWWWNNNWWNWNWNWNNNWNWNNWNWNWNNNNNNWNNNWWNNNNNWNWWWNWWNWNWWWWWNWNNWWWNNWNWNNWNWWWWWWWNNWW...

output:

3.14750246340429385

result:

ok found '3.1475025', expected '3.1475025', error '0.0000000'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

WNWWNWNWNNNWNWWWWNNNWWNWNWWNNWNNWWWNWNNWWWWWWWWWNWWNWNNWWNWNNNWWNNNNNNNWWWWNWWNWWNWWWNNWNWNWNNNNNNWNWWNNNWNWWWNNNNWWNWNWWWWWNWWWNWWWWWNNWNNWWNWWWWNNWNWNNWNNNWWNNNWWWWWNNWWWWWWNNWWNWNNWWWNNNNWNNNNNNWNNNWNNWNWWWWWWNNNNNWNWNNNWWNNNWNNNNNWWNWNWNWNNWNNNNNWWWNNNNNNWNNWNNNNWWWWNNNWNWWWWWNWWNWWWNNNWWWWWNWWN...

output:

82.26615478105799184

result:

ok found '82.2661548', expected '82.2661548', error '0.0000000'

Test #16:

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

input:

NNNENNNNEENNEEENEENNNNENNNENEENEENNNNENENEENNNEENE WNNWWNWWWNNWNNNNWWNWNNWNNNWNNWWNNWWWWWNWNNWWNNWNNWNNNWNWWNWWNNNWNWNNWWWWWWWWWWWWNWWNNWWWNNNNWWWNNWNWNNNNWWNNNWNWNWNNNWWNNWWWNWWNNWNWNNNWNWWNWNNNNNNNNNWWWNWWNWWWNWNWNWNNNWNNNWNNWNWNWWWNNWWWWWWNWNNNNNWNNWWWWNNNNNNWWWNWNWNWNWNWNNWNWWWNNNNWNNWWWNWNWNWWW...

output:

82.77950034115087874

result:

ok found '82.7795003', expected '82.7795003', error '0.0000000'

Test #17:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

WNNWNWWWWNNWWWWNWNNWWNNWWNWNNWNWWWWWNWNWNNWWNNWWNNNNWNNNNWWNWNNNWNWNWNWWWNNWNWWNNWWWNWNWWWNWWNNWWNWNWNNWNWWWWNNWNWNNNNWWNWWWNWNWNWNWNNNNWNWWNNNNNNNWNNWWNNWNWWNNWWNNWWWWWWWNNWNWNWWWNNWWWNWNWWNWNNWWNWNNWNNNNNNNNWWWWNWNNNNWNNWWNNNNWNWWNWWNNWNWNNWNNNNWWNWWNWNNWWWWWNNWNNNNWWWWNNWWWNWWNWWNNWNWNNWNNNNWNWWN...

output:

124.59323666115088258

result:

ok found '124.5932367', expected '124.5932367', error '0.0000000'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

SSSEEEEEESEEEESSESEEEEEEEEESSEEESSESSESSSESSSESEEEEESSSSEESSSSSEESSSESESEEESEESEEEEEEESSSSESSESSESEESEESSESEESESSSSEESSESSESSEESEEEESSESEEEEEEEESEEEESEESEESSESEESEEESEESESEESSEESESESESSESESESSEESSEEESEESESESEEESESSSESEESESSESEESSSESESSESEESSEEEESSSSSSESSEESSSSEESEESESSESSSEESSEEESSSESEEESSSEEEEESEES...

output:

132.99531061899523365

result:

ok found '132.9953106', expected '132.9953106', error '0.0000000'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

WWNWNNNWNWNNWNNNNNWNNWNWNWNWWWWWNWNWNNWWNWWWWNNNWNWWWWWWWWWWWWNNNNNNNWWWWNNNWNWNWWWNNWWNNNNNWWWWWNWWNWWNWNWNNNWNWWNNNNNNWNNNWNNWWNWWWWNNNNNNNWNNWWWWWNNWWWNWWWWWWWNWWNNWWWNNNNNNWNNWNNNNNWNWNNNNWWNNNNNWWNNNNWWNWNNWNWNNNWWWWWWWNWNNNNNWNWWNWWWWWNNNNWNNNNNWWWWWWWWWNWWNWNWNNNWNNWWNNNWWWNWWNNWWWNNNNWWWNNNW...

output:

153.44505211808245804

result:

ok found '153.4450521', expected '153.4450521', error '0.0000000'

Test #20:

score: 0
Accepted
time: 1ms
memory: 3744kb

input:

N NNNNNNNNNW

output:

0.17578125000000000

result:

ok found '0.1757812', expected '0.1757812', error '0.0000000'

Test #21:

score: 0
Accepted
time: 1ms
memory: 3840kb

input:

N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNE

output:

0.00000000004092726

result:

ok found '0.0000000', expected '0.0000000', error '0.0000000'

Test #22:

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

input:

S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSW

output:

0.00000000000008527

result:

ok found '0.0000000', expected '0.0000000', error '0.0000000'

Test #23:

score: 0
Accepted
time: 1ms
memory: 3776kb

input:

S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSE

output:

0.00000000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #24:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

0.00000000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #25:

score: 0
Accepted
time: 0ms
memory: 3784kb

input:

NE EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

0.00000000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

E W

output:

180.00000000000000000

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #27:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

W E

output:

180.00000000000000000

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #28:

score: 0
Accepted
time: 1ms
memory: 3844kb

input:

EEEEEEEEEEEEEEEEEEEENE W

output:

179.99995708465576172

result:

ok found '179.9999571', expected '179.9999571', error '0.0000000'

Test #29:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

EEEEEEEEEEEEEEEEEEEESE W

output:

179.99995708465576172

result:

ok found '179.9999571', expected '179.9999571', error '0.0000000'

Test #30:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

EEEEEEEEEEEEEEEEEEEEESE W

output:

179.99997854232788086

result:

ok found '179.9999785', expected '179.9999785', error '0.0000000'

Test #31:

score: 0
Accepted
time: 1ms
memory: 3600kb

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEESE W

output:

179.99999995809048414

result:

ok found '180.0000000', expected '180.0000000', error '0.0000000'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3700kb

input:

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWSSW

output:

0.00000000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #33:

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

input:

SSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWSSW

output:

0.00004291534423828

result:

ok found '0.0000429', expected '0.0000429', error '0.0000000'

Test #34:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW

output:

0.00000000000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'