QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131846#5130. Failing Flagshipmshcherba#WA 1ms3836kbC++171.1kb2023-07-28 15:49:412023-07-28 15:49:42

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:49:42]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3836kb
  • [2023-07-28 15:49:41]
  • 提交

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) {
	bool ne = true;
	for (char c : s) {
		ne &= c == 'N' || c == 'E';
	}
	db res = 0;
	RFOR(i, SZ(s), 0) {
		db cur = s[i] == 'N' && !ne ? 360 : dir[s[i]];
		if (i == SZ(s) - 1) {
			res = cur;
		}
		else {
			res = (res + cur) / 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: 3664kb

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

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

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

input:

SW SE

output:

90.0000000000

result:

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

Test #5:

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

input:

NENE SESSE

output:

118.1250000000

result:

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