QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#216625#5130. Failing FlagshipMovingUp#WA 0ms3908kbC++20974b2023-10-15 20:37:352023-10-15 20:37:36

Judging History

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

  • [2023-10-15 20:37:36]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3908kb
  • [2023-10-15 20:37:35]
  • 提交

answer

#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>

using namespace std;

map<string, double> defaultAngles;

double getAngle(string s) {
  if (s.size() <= 2) {
    return defaultAngles[s];
  }

  double x = getAngle(s.substr(1));
  double y = defaultAngles[s.substr(0, 1)];

  if (s.substr(s.size() - 2, 2) == "NW") {
    if (y == 0)
      y = 360;
  }

  return (x + y) / 2;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cout << fixed << setprecision(8);

  defaultAngles["N"] = 0;
  defaultAngles["E"] = 90;
  defaultAngles["S"] = 180;
  defaultAngles["W"] = 270;

  defaultAngles["NE"] = 45;
  defaultAngles["SE"] = 135;
  defaultAngles["SW"] = 225;
  defaultAngles["NW"] = 315;

  string s, t;
  cin >> s >> t;

  double angleS = getAngle(s);
  double angleT = getAngle(t);

  if (abs(angleS - angleT) < 180) {
    cout << abs(angleS - angleT) << endl;
  } else {
    cout << 360 - abs(angleS - angleT) << endl;
  }
}

詳細信息

Test #1:

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

input:

N S

output:

180.00000000

result:

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

Test #2:

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

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

input:

ENE NW

output:

112.50000000

result:

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

Test #4:

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

input:

SW SE

output:

90.00000000

result:

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

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3776kb

input:

NENE SESSE

output:

118.12500000

result:

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