QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131852#5130. Failing Flagshipmshcherba#AC ✓1ms3852kbC++171.6kb2023-07-28 16:06:592023-07-28 16:07:01

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:07:01]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3852kb
  • [2023-07-28 16:06:59]
  • 提交

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) {
	if (SZ(s) == 1) {
		return dir[s[0]];
	}
	vector<char> chars(ALL(s));
	sort(ALL(chars));
	chars.resize(unique(ALL(chars)) - chars.begin());
	char smaller, bigger;
	smaller = chars[0];
	bigger = chars[1];
	if (dir[bigger] < dir[smaller]) {
		swap(smaller, bigger);
	}
	if (smaller == 'N' && bigger == 'W') {
		swap(smaller, bigger);
	}
	db res;
	if (smaller == 'N' && bigger == 'E') {
		res = 45;
	}
	else if (smaller == 'E' && bigger == 'S') {
		res = 135;
	}
	else if (smaller == 'S' && bigger == 'W') {
		res = 225;
	}
	else {
		assert(smaller == 'W' && bigger == 'N');
		res = 315;
	}
	db pw = 22.5;
	RFOR(i, SZ(s) - 2, 0) {
		if (s[i] == smaller) {
			res -= pw;
		}
		else {
			res += pw;
		}
		pw /= 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: 3836kb

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: 3712kb

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: 3652kb

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: 3788kb

input:

SW SE

output:

90.0000000000

result:

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

Test #5:

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

input:

NENE SESSE

output:

95.6250000000

result:

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

Test #6:

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

input:

NWWNNWNWNW E

output:

148.5351562500

result:

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

Test #7:

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

input:

SWWWSWSSSSW NNNNNNNNNNNW

output:

171.7822265625

result:

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

Test #8:

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

input:

N N

output:

0.0000000000

result:

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

Test #9:

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

input:

S N

output:

180.0000000000

result:

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

Test #10:

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

input:

NW SE

output:

180.0000000000

result:

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

Test #11:

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

input:

SE SESE

output:

11.2500000000

result:

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

Test #12:

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

input:

SE SSESE

output:

5.6250000000

result:

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

Test #13:

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

input:

EEENE ENENE

output:

22.5000000000

result:

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

Test #14:

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

input:

NW NNWWNNNNWNWNNNNNNNNNWNNNWNWNWWNWNWNWNWNWWNNNNNNNNNNNWNWNWWWNWNNWNWWWWWWNWWWNNNWNNWNNNNNNNWWWWWNNNNNNWNWWWNNWNWNWNNNNNNWWNWWWNNNNWNNWWNNNNWWWWNWNNWWWNNWWWNNNWNNWWWWWWWNNWWWWWNWNNNNWWWNWWNNNWNWNWNNNNWNNWWWNWNNNNWWWWNNNWWNWNWNWNNNWNWNNWNWNWNNNNNNWNNNWWNNNNNWNWWWNWWNWNWWWWWNWNNWWWNNWNWNNWNWWWWWWWNNWW...

output:

3.1475024634

result:

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

Test #15:

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

input:

WNWWNWNWNNNWNWWWWNNNWWNWNWWNNWNNWWWNWNNWWWWWWWWWNWWNWNNWWNWNNNWWNNNNNNNWWWWNWWNWWNWWWNNWNWNWNNNNNNWNWWNNNWNWWWNNNNWWNWNWWWWWNWWWNWWWWWNNWNNWWNWWWWNNWNWNNWNNNWWNNNWWWWWNNWWWWWWNNWWNWNNWWWNNNNWNNNNNNWNNNWNNWNWWWWWWNNNNNWNWNNNWWNNNWNNNNNWWNWNWNWNNWNNNNNWWWNNNNNNWNNWNNNNWWWWNNNWNWWWWWNWWNWWWNNNWWWWWNWWN...

output:

82.2661547811

result:

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

Test #16:

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

input:

NNNENNNNEENNEEENEENNNNENNNENEENEENNNNENENEENNNEENE WNNWWNWWWNNWNNNNWWNWNNWNNNWNNWWNNWWWWWNWNNWWNNWNNWNNNWNWWNWWNNNWNWNNWWWWWWWWWWWWNWWNNWWWNNNNWWWNNWNWNNNNWWNNNWNWNWNNNWWNNWWWNWWNNWNWNNNWNWWNWNNNNNNNNNWWWNWWNWWWNWNWNWNNNWNNNWNNWNWNWWWNNWWWWWWNWNNNNNWNNWWWWNNNNNNWWWNWNWNWNWNWNNWNWWWNNNNWNNWWWNWNWNWWW...

output:

82.7795003412

result:

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

Test #17:

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

input:

WNNWNWWWWNNWWWWNWNNWWNNWWNWNNWNWWWWWNWNWNNWWNNWWNNNNWNNNNWWNWNNNWNWNWNWWWNNWNWWNNWWWNWNWWWNWWNNWWNWNWNNWNWWWWNNWNWNNNNWWNWWWNWNWNWNWNNNNWNWWNNNNNNNWNNWWNNWNWWNNWWNNWWWWWWWNNWNWNWWWNNWWWNWNWWNWNNWWNWNNWNNNNNNNNWWWWNWNNNNWNNWWNNNNWNWWNWWNNWNWNNWNNNNWWNWWNWNNWWWWWNNWNNNNWWWWNNWWWNWWNWWNNWNWNNWNNNNWNWWN...

output:

124.5932366612

result:

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

Test #18:

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

input:

SSSEEEEEESEEEESSESEEEEEEEEESSEEESSESSESSSESSSESEEEEESSSSEESSSSSEESSSESESEEESEESEEEEEEESSSSESSESSESEESEESSESEESESSSSEESSESSESSEESEEEESSESEEEEEEEESEEEESEESEESSESEESEEESEESESEESSEESESESESSESESESSEESSEEESEESESESEEESESSSESEESESSESEESSSESESSESEESSEEEESSSSSSESSEESSSSEESEESESSESSSEESSEEESSSESEEESSSEEEEESEES...

output:

132.9953106190

result:

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

Test #19:

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

input:

WWNWNNNWNWNNWNNNNNWNNWNWNWNWWWWWNWNWNNWWNWWWWNNNWNWWWWWWWWWWWWNNNNNNNWWWWNNNWNWNWWWNNWWNNNNNWWWWWNWWNWWNWNWNNNWNWWNNNNNNWNNNWNNWWNWWWWNNNNNNNWNNWWWWWNNWWWNWWWWWWWNWWNNWWWNNNNNNWNNWNNNNNWNWNNNNWWNNNNNWWNNNNWWNWNNWNWNNNWWWWWWWNWNNNNNWNWWNWWWWWNNNNWNNNNNWWWWWWWWWNWWNWNWNNNWNNWWNNNWWWNWWNNWWWNNNNWWWNNNW...

output:

153.4450521181

result:

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

Test #20:

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

input:

N NNNNNNNNNW

output:

0.1757812500

result:

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

Test #21:

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

input:

N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNE

output:

0.0000000000

result:

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

Test #22:

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

input:

S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSW

output:

0.0000000000

result:

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

Test #23:

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

input:

S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSE

output:

0.0000000000

result:

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

Test #24:

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

input:

N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

0.0000000000

result:

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

Test #25:

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

input:

NE EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

0.0000000000

result:

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

Test #26:

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

input:

E W

output:

180.0000000000

result:

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

Test #27:

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

input:

W E

output:

180.0000000000

result:

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

Test #28:

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

input:

EEEEEEEEEEEEEEEEEEEENE W

output:

179.9999570847

result:

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

Test #29:

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

input:

EEEEEEEEEEEEEEEEEEEESE W

output:

179.9999570847

result:

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

Test #30:

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

input:

EEEEEEEEEEEEEEEEEEEEESE W

output:

179.9999785423

result:

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

Test #31:

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

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEESE W

output:

179.9999999581

result:

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

Test #32:

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

input:

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWSSW

output:

0.0000000000

result:

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

Test #33:

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

input:

SSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWSSW

output:

0.0000429153

result:

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

Test #34:

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

input:

SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW

output:

0.0000000000

result:

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