QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#131854#5130. Failing FlagshipYarema#WA 1ms3732kbC++171023b2023-07-28 16:09:212023-07-28 16:09:22

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:09:22]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3732kb
  • [2023-07-28 16:09:21]
  • 提交

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 res = m[s[0]];
	FOR (i, 1, SZ(s))
	{
		double x = m[s[i]];
		if (s[i] == 'N' && res > 180) x = 360; 
		res = (res + x) / 2;
	}
	return res;
}

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(7) << ans << '\n';
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

N S

output:

180.0000000

result:

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

Test #2:

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

input:

NNE SSSE

output:

146.2500000

result:

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

Test #3:

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

input:

ENE NW

output:

112.5000000

result:

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

Test #4:

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

input:

SW SE

output:

90.0000000

result:

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

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3660kb

input:

NENE SESSE

output:

118.1250000

result:

wrong answer 1st numbers differ - expected: '95.6250000', found: '118.1250000', error = '0.2352941'