Submission #7273388


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int n;

int quadrant(int x, int y) {
  if (x > 0 && y >= 0) return 0;
  if (x <= 0 && y > 0) return 1;
  if (x < 0 && y >= 0) return 2;
  return 3;
}

bool cmp(pair<int, int> p, pair<int, int> q) {
  int q1 = quadrant(p.first, p.second);
  int q2 = quadrant(q.first, q.second);
  
  if (q1 != q2) return q1 < q2;
  
  if (q1 == 0 || q1 == 2) {
    p = {abs(p.first), abs(p.second)};
    q = {abs(q.first), abs(q.second)};
  } else {
    p = {abs(p.second), abs(p.first)};
    q = {abs(q.second), abs(q.first)};
  }
  
  return 1LL * p.second * q.first < 1LL * p.first * q.second;
}

int main() {
  vector<pair<int, int>> v;
  scanf("%d", &n);
  
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x == 0 && y == 0) continue;
    
    v.emplace_back(x, y);
  }
  
  sort(v.begin(), v.end(), cmp);
  n = v.size();
  
  double ans = 0;
  for (int i = 0; i < n; ++i) {
    long long curx = 0, cury = 0;
    for (int j = 0; j < n; ++j) {
      curx += v[(i+j) % n].first;
      cury += v[(i+j) % n].second;
      
      ans = max(ans, hypot(curx, cury));
    }
  }
  
  printf("%.18lf\n", ans);
  return 0;
}

Submission Info

Submission Time
Task F - Engines
User prabowo
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1240 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:32:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &n);
                  ^
./Main.cpp:36:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &x, &y);
                           ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 7
AC × 33
WA × 8
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt
All 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 00-sample-04.txt, 00-sample-05.txt, 00-sample-06.txt, 00-sample-07.txt, 01-random-very-small-01.txt, 01-random-very-small-02.txt, 01-random-very-small-03.txt, 02-random-small-01.txt, 02-random-small-02.txt, 02-random-small-03.txt, 03-random-01.txt, 03-random-02.txt, 03-random-03.txt, 04-zero-01.txt, 05-same-01.txt, 05-same-02.txt, 06-linear-01.txt, 06-linear-02.txt, 06-linear-03.txt, 07-linear-positive-01.txt, 07-linear-positive-02.txt, 07-linear-positive-03.txt, 08-90-degree-01.txt, 08-90-degree-02.txt, 09-180-degree-01.txt, 09-180-degree-02.txt, 10-sandglass-01.txt, 10-sandglass-02.txt, 11-circle-01.txt, 11-circle-02.txt, 11-circle-03.txt, 11-circle-04.txt, 11-circle-05.txt, 12-square-01.txt, 12-square-02.txt, 12-square-03.txt, 13-corner-01.txt, 13-corner-02.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 1 ms 256 KB
00-sample-02.txt AC 1 ms 256 KB
00-sample-03.txt AC 1 ms 256 KB
00-sample-04.txt AC 1 ms 256 KB
00-sample-05.txt AC 1 ms 256 KB
00-sample-06.txt AC 1 ms 256 KB
00-sample-07.txt AC 1 ms 256 KB
01-random-very-small-01.txt WA 1 ms 256 KB
01-random-very-small-02.txt WA 1 ms 256 KB
01-random-very-small-03.txt WA 1 ms 256 KB
02-random-small-01.txt AC 1 ms 256 KB
02-random-small-02.txt WA 1 ms 256 KB
02-random-small-03.txt WA 1 ms 256 KB
03-random-01.txt AC 1 ms 256 KB
03-random-02.txt WA 1 ms 256 KB
03-random-03.txt WA 1 ms 256 KB
04-zero-01.txt AC 1 ms 256 KB
05-same-01.txt AC 1 ms 256 KB
05-same-02.txt AC 1 ms 256 KB
06-linear-01.txt AC 1 ms 256 KB
06-linear-02.txt AC 1 ms 256 KB
06-linear-03.txt AC 1 ms 256 KB
07-linear-positive-01.txt AC 1 ms 256 KB
07-linear-positive-02.txt AC 1 ms 256 KB
07-linear-positive-03.txt AC 1 ms 256 KB
08-90-degree-01.txt AC 1 ms 256 KB
08-90-degree-02.txt AC 1 ms 256 KB
09-180-degree-01.txt AC 1 ms 256 KB
09-180-degree-02.txt AC 1 ms 256 KB
10-sandglass-01.txt AC 1 ms 256 KB
10-sandglass-02.txt AC 1 ms 256 KB
11-circle-01.txt AC 1 ms 256 KB
11-circle-02.txt AC 1 ms 256 KB
11-circle-03.txt AC 1 ms 256 KB
11-circle-04.txt AC 1 ms 256 KB
11-circle-05.txt WA 1 ms 256 KB
12-square-01.txt AC 1 ms 256 KB
12-square-02.txt AC 1 ms 256 KB
12-square-03.txt AC 1 ms 256 KB
13-corner-01.txt AC 1 ms 256 KB
13-corner-02.txt AC 1 ms 256 KB