QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#131840#5130. Failing FlagshipPetroTarnavskyi#AC ✓1ms3840kbC++171.5kb2023-07-28 15:28:142023-07-28 15:28:16

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

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;


string ALP = "ENWS";

double angle(string s){
	if(SZ(s) == 1){
		FOR(i, 0, 4)
			if(ALP[i] == s[0])
				return 90 * i;
		assert(0);
		return 0;
	}
	int p1 = -1, p2 = -1;
	FOR(i, 0, SZ(s)){
		int cur = -1;
		FOR(j, 0, 4)
			if(s[i] == ALP[j])
				cur = j;
				
		if(p1 == -1){
			p1 = cur;
			continue;
		}
		if(p1 == cur)
			continue;
		p2 = cur;
	}
	if(p1 > p2)
		swap(p1, p2);
	double l = 90 * p1, r = 90 * p2;
	
	
	if(p1 == 0 && p2 == 3){
		swap(p1, p2);
		l = 270;
		r = 360;
	}
	//cout << p1 << " " << p2 << " " << l << " " << r << endl;
	
	RFOR(i, SZ(s) - 2, 0){
		int cur = -1;
		FOR(j, 0, 4)
			if(s[i] == ALP[j])
				cur = j;
				
				
		double m = (l + r) / 2.;
		if(cur == p2)
			l = m;
		else
			r = m;
	}
	//cout << l << " " << r << endl;
	return (l + r) / 2;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s0, s1;
	cin >> s0 >> s1;
	double a = angle(s0);
	//cout << a << endl;
	
	double b = angle(s1);
	
	if(a > b)
		swap(a, b);
	cout << fixed << setprecision(8);
	cout << min(b - a, a + 360 - b) << endl;


	
	
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

N S

output:

180.00000000

result:

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

Test #2:

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

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

input:

ENE NW

output:

112.50000000

result:

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

Test #4:

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

input:

SW SE

output:

90.00000000

result:

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

Test #5:

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

input:

NENE SESSE

output:

95.62500000

result:

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

Test #6:

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

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.78222656

result:

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

Test #8:

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

input:

N N

output:

0.00000000

result:

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

Test #9:

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

input:

S N

output:

180.00000000

result:

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

Test #10:

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

input:

NW SE

output:

180.00000000

result:

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

Test #11:

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

input:

SE SESE

output:

11.25000000

result:

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

Test #12:

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

input:

SE SSESE

output:

5.62500000

result:

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

Test #13:

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

input:

EEENE ENENE

output:

22.50000000

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.14750246

result:

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

Test #15:

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

input:

WNWWNWNWNNNWNWWWWNNNWWNWNWWNNWNNWWWNWNNWWWWWWWWWNWWNWNNWWNWNNNWWNNNNNNNWWWWNWWNWWNWWWNNWNWNWNNNNNNWNWWNNNWNWWWNNNNWWNWNWWWWWNWWWNWWWWWNNWNNWWNWWWWNNWNWNNWNNNWWNNNWWWWWNNWWWWWWNNWWNWNNWWWNNNNWNNNNNNWNNNWNNWNWWWWWWNNNNNWNWNNNWWNNNWNNNNNWWNWNWNWNNWNNNNNWWWNNNNNNWNNWNNNNWWWWNNNWNWWWWWNWWNWWWNNNWWWWWNWWN...

output:

82.26615478

result:

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

Test #16:

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

input:

NNNENNNNEENNEEENEENNNNENNNENEENEENNNNENENEENNNEENE WNNWWNWWWNNWNNNNWWNWNNWNNNWNNWWNNWWWWWNWNNWWNNWNNWNNNWNWWNWWNNNWNWNNWWWWWWWWWWWWNWWNNWWWNNNNWWWNNWNWNNNNWWNNNWNWNWNNNWWNNWWWNWWNNWNWNNNWNWWNWNNNNNNNNNWWWNWWNWWWNWNWNWNNNWNNNWNNWNWNWWWNNWWWWWWNWNNNNNWNNWWWWNNNNNNWWWNWNWNWNWNWNNWNWWWNNNNWNNWWWNWNWNWWW...

output:

82.77950034

result:

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

Test #17:

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

input:

WNNWNWWWWNNWWWWNWNNWWNNWWNWNNWNWWWWWNWNWNNWWNNWWNNNNWNNNNWWNWNNNWNWNWNWWWNNWNWWNNWWWNWNWWWNWWNNWWNWNWNNWNWWWWNNWNWNNNNWWNWWWNWNWNWNWNNNNWNWWNNNNNNNWNNWWNNWNWWNNWWNNWWWWWWWNNWNWNWWWNNWWWNWNWWNWNNWWNWNNWNNNNNNNNWWWWNWNNNNWNNWWNNNNWNWWNWWNNWNWNNWNNNNWWNWWNWNNWWWWWNNWNNNNWWWWNNWWWNWWNWWNNWNWNNWNNNNWNWWN...

output:

124.59323666

result:

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

Test #18:

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

input:

SSSEEEEEESEEEESSESEEEEEEEEESSEEESSESSESSSESSSESEEEEESSSSEESSSSSEESSSESESEEESEESEEEEEEESSSSESSESSESEESEESSESEESESSSSEESSESSESSEESEEEESSESEEEEEEEESEEEESEESEESSESEESEEESEESESEESSEESESESESSESESESSEESSEEESEESESESEEESESSSESEESESSESEESSSESESSESEESSEEEESSSSSSESSEESSSSEESEESESSESSSEESSEEESSSESEEESSSEEEEESEES...

output:

132.99531062

result:

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

Test #19:

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

input:

WWNWNNNWNWNNWNNNNNWNNWNWNWNWWWWWNWNWNNWWNWWWWNNNWNWWWWWWWWWWWWNNNNNNNWWWWNNNWNWNWWWNNWWNNNNNWWWWWNWWNWWNWNWNNNWNWWNNNNNNWNNNWNNWWNWWWWNNNNNNNWNNWWWWWNNWWWNWWWWWWWNWWNNWWWNNNNNNWNNWNNNNNWNWNNNNWWNNNNNWWNNNNWWNWNNWNWNNNWWWWWWWNWNNNNNWNWWNWWWWWNNNNWNNNNNWWWWWWWWWNWWNWNWNNNWNNWWNNNWWWNWWNNWWWNNNNWWWNNNW...

output:

153.44505212

result:

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

Test #20:

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

input:

N NNNNNNNNNW

output:

0.17578125

result:

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

Test #21:

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

input:

N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNE

output:

0.00000000

result:

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

Test #22:

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

input:

S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSW

output:

0.00000000

result:

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

Test #23:

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

input:

S SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSE

output:

0.00000000

result:

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

Test #24:

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

input:

N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN...

output:

0.00000000

result:

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

Test #25:

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

input:

NE EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE...

output:

0.00000000

result:

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

Test #26:

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

input:

E W

output:

180.00000000

result:

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

Test #27:

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

input:

W E

output:

180.00000000

result:

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

Test #28:

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

input:

EEEEEEEEEEEEEEEEEEEENE W

output:

179.99995708

result:

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

Test #29:

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

input:

EEEEEEEEEEEEEEEEEEEESE W

output:

179.99995708

result:

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

Test #30:

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

input:

EEEEEEEEEEEEEEEEEEEEESE W

output:

179.99997854

result:

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

Test #31:

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

input:

EEEEEEEEEEEEEEEEEEEEEEEEEEEEEESE W

output:

179.99999996

result:

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

Test #32:

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

input:

SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWSSW

output:

0.00000000

result:

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

Test #33:

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

input:

SSSSSSSSSSSSSSSSSSSSWSW WWWWWWWWWWWWWWWWWWWWSSW

output:

0.00004292

result:

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

Test #34:

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

input:

SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW SSSSSSSSSSSSSWWWSSSWSWSWSSSSSWWWWWWSWSWSWSSSWWSSW

output:

0.00000000

result:

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