Submission #299439

# Submission time Handle Problem Language Result Execution time Memory
299439 2020-09-14T22:35:51 Z Bruteforceman Wish (LMIO19_noras) C++11
100 / 100
558 ms 9216 KB
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const long long inf = 1e16;
typedef long long dtype;
struct point {
  dtype x, y;
  point (dtype x, dtype y) : x(x), y(y) {}
  point () {}
  point operator - (point p) const {
    return point(x - p.x, y - p.y);
  }
  point operator + (point p) const {
    return point(x + p.x, y + p.y);
  }
  point operator * (dtype val) const {
    return point(x * val, y * val);
  }
};
dtype dot(point p, point q) {
  return p.x * q.x + p.y * q.y;
}
int main() {
  int n, R;
  cin >> n >> R;
  map <long long, int> cnt;
  for(int i = 0; i < n; i++) {
    int a, b;
    int c, d;
    cin >> a >> b >> c >> d;
    point p (a, b);
    point q (c, d);
    long long u = dot(point(0, 0) - p, q - p) / dot(q - p, q - p);
    long long piv = LLONG_MAX;
    for(int x = -1; x <= 1; x++) {
      point r = p + ((q - p) * (u + x));
      if(dot(r, r) <= 1LL * R * R) {
        piv = u + x;
        break;
      }
    }
    if(piv == LLONG_MAX) continue;
    long long from, to;
    for(int dir : {-1, 1}) {
      long long l = 0, r = 2 * R + 1;
      while(l < r) {
        long long mid = (l + r + 1) >> 1;
        point f = p + ((q - p) * (piv + dir * mid));
        if(abs(f.x) <= R && abs(f.y) <= R && dot(f, f) <= 1LL * R * R) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      if(dir == -1) {
        from = piv + dir * l;
        from = max(0LL, from);
      } else {
        to = piv + dir * l;
      }
    }
    if(from <= to) {
      cnt[from] += 1;
      cnt[to + 1] -= 1; 
     // cout << from << " " << to << endl;
    }
  }
  int sum = 0;
  int ans = 0;
  for(auto i : cnt) {
    sum += i.second;
    ans = max(ans, sum);
  }
  cout << ans << endl;
  return 0;
}

Compilation message

noras.cpp: In function 'int main()':
noras.cpp:64:14: warning: 'to' may be used uninitialized in this function [-Wmaybe-uninitialized]
   64 |       cnt[to + 1] -= 1;
      |           ~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 376 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 376 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 177 ms 1912 KB Output is correct
24 Correct 172 ms 1912 KB Output is correct
25 Correct 175 ms 1912 KB Output is correct
26 Correct 174 ms 1912 KB Output is correct
27 Correct 199 ms 2168 KB Output is correct
28 Correct 186 ms 2040 KB Output is correct
29 Correct 195 ms 2040 KB Output is correct
30 Correct 195 ms 2040 KB Output is correct
31 Correct 191 ms 2040 KB Output is correct
32 Correct 211 ms 2168 KB Output is correct
33 Correct 200 ms 2040 KB Output is correct
34 Correct 205 ms 2184 KB Output is correct
35 Correct 206 ms 2168 KB Output is correct
36 Correct 206 ms 2040 KB Output is correct
37 Correct 174 ms 1912 KB Output is correct
38 Correct 171 ms 1912 KB Output is correct
39 Correct 176 ms 1912 KB Output is correct
40 Correct 174 ms 1912 KB Output is correct
41 Correct 176 ms 1968 KB Output is correct
42 Correct 179 ms 2040 KB Output is correct
43 Correct 558 ms 5776 KB Output is correct
44 Correct 545 ms 5764 KB Output is correct
45 Correct 545 ms 5880 KB Output is correct
46 Correct 543 ms 5880 KB Output is correct
47 Correct 552 ms 5752 KB Output is correct
48 Correct 414 ms 3832 KB Output is correct
49 Correct 414 ms 4088 KB Output is correct
50 Correct 413 ms 3960 KB Output is correct
51 Correct 407 ms 3960 KB Output is correct
52 Correct 404 ms 3832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 376 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 1 ms 288 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 376 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 177 ms 1912 KB Output is correct
24 Correct 172 ms 1912 KB Output is correct
25 Correct 175 ms 1912 KB Output is correct
26 Correct 174 ms 1912 KB Output is correct
27 Correct 199 ms 2168 KB Output is correct
28 Correct 186 ms 2040 KB Output is correct
29 Correct 195 ms 2040 KB Output is correct
30 Correct 195 ms 2040 KB Output is correct
31 Correct 191 ms 2040 KB Output is correct
32 Correct 211 ms 2168 KB Output is correct
33 Correct 200 ms 2040 KB Output is correct
34 Correct 205 ms 2184 KB Output is correct
35 Correct 206 ms 2168 KB Output is correct
36 Correct 206 ms 2040 KB Output is correct
37 Correct 174 ms 1912 KB Output is correct
38 Correct 171 ms 1912 KB Output is correct
39 Correct 176 ms 1912 KB Output is correct
40 Correct 174 ms 1912 KB Output is correct
41 Correct 176 ms 1968 KB Output is correct
42 Correct 179 ms 2040 KB Output is correct
43 Correct 558 ms 5776 KB Output is correct
44 Correct 545 ms 5764 KB Output is correct
45 Correct 545 ms 5880 KB Output is correct
46 Correct 543 ms 5880 KB Output is correct
47 Correct 552 ms 5752 KB Output is correct
48 Correct 414 ms 3832 KB Output is correct
49 Correct 414 ms 4088 KB Output is correct
50 Correct 413 ms 3960 KB Output is correct
51 Correct 407 ms 3960 KB Output is correct
52 Correct 404 ms 3832 KB Output is correct
53 Correct 171 ms 1912 KB Output is correct
54 Correct 212 ms 2428 KB Output is correct
55 Correct 210 ms 2296 KB Output is correct
56 Correct 207 ms 2296 KB Output is correct
57 Correct 242 ms 2936 KB Output is correct
58 Correct 239 ms 2808 KB Output is correct
59 Correct 242 ms 2856 KB Output is correct
60 Correct 244 ms 3064 KB Output is correct
61 Correct 255 ms 2808 KB Output is correct
62 Correct 224 ms 2296 KB Output is correct
63 Correct 218 ms 2296 KB Output is correct
64 Correct 219 ms 2296 KB Output is correct
65 Correct 219 ms 2296 KB Output is correct
66 Correct 222 ms 2424 KB Output is correct
67 Correct 170 ms 1912 KB Output is correct
68 Correct 174 ms 1912 KB Output is correct
69 Correct 177 ms 2040 KB Output is correct
70 Correct 186 ms 2056 KB Output is correct
71 Correct 539 ms 5924 KB Output is correct
72 Correct 532 ms 5880 KB Output is correct
73 Correct 536 ms 5884 KB Output is correct
74 Correct 536 ms 5880 KB Output is correct
75 Correct 528 ms 6008 KB Output is correct
76 Correct 442 ms 4216 KB Output is correct
77 Correct 445 ms 4216 KB Output is correct
78 Correct 446 ms 4216 KB Output is correct
79 Correct 450 ms 4216 KB Output is correct
80 Correct 443 ms 4216 KB Output is correct
81 Correct 1 ms 288 KB Output is correct
82 Correct 2 ms 384 KB Output is correct
83 Correct 3 ms 384 KB Output is correct
84 Correct 2 ms 384 KB Output is correct
85 Correct 2 ms 384 KB Output is correct
86 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 1 ms 376 KB Output is correct
13 Correct 1 ms 256 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 177 ms 1912 KB Output is correct
24 Correct 172 ms 1912 KB Output is correct
25 Correct 175 ms 1912 KB Output is correct
26 Correct 174 ms 1912 KB Output is correct
27 Correct 199 ms 2168 KB Output is correct
28 Correct 186 ms 2040 KB Output is correct
29 Correct 195 ms 2040 KB Output is correct
30 Correct 195 ms 2040 KB Output is correct
31 Correct 191 ms 2040 KB Output is correct
32 Correct 211 ms 2168 KB Output is correct
33 Correct 200 ms 2040 KB Output is correct
34 Correct 205 ms 2184 KB Output is correct
35 Correct 206 ms 2168 KB Output is correct
36 Correct 206 ms 2040 KB Output is correct
37 Correct 174 ms 1912 KB Output is correct
38 Correct 171 ms 1912 KB Output is correct
39 Correct 176 ms 1912 KB Output is correct
40 Correct 174 ms 1912 KB Output is correct
41 Correct 176 ms 1968 KB Output is correct
42 Correct 179 ms 2040 KB Output is correct
43 Correct 558 ms 5776 KB Output is correct
44 Correct 545 ms 5764 KB Output is correct
45 Correct 545 ms 5880 KB Output is correct
46 Correct 543 ms 5880 KB Output is correct
47 Correct 552 ms 5752 KB Output is correct
48 Correct 414 ms 3832 KB Output is correct
49 Correct 414 ms 4088 KB Output is correct
50 Correct 413 ms 3960 KB Output is correct
51 Correct 407 ms 3960 KB Output is correct
52 Correct 404 ms 3832 KB Output is correct
53 Correct 171 ms 1912 KB Output is correct
54 Correct 212 ms 2428 KB Output is correct
55 Correct 210 ms 2296 KB Output is correct
56 Correct 207 ms 2296 KB Output is correct
57 Correct 242 ms 2936 KB Output is correct
58 Correct 239 ms 2808 KB Output is correct
59 Correct 242 ms 2856 KB Output is correct
60 Correct 244 ms 3064 KB Output is correct
61 Correct 255 ms 2808 KB Output is correct
62 Correct 224 ms 2296 KB Output is correct
63 Correct 218 ms 2296 KB Output is correct
64 Correct 219 ms 2296 KB Output is correct
65 Correct 219 ms 2296 KB Output is correct
66 Correct 222 ms 2424 KB Output is correct
67 Correct 170 ms 1912 KB Output is correct
68 Correct 174 ms 1912 KB Output is correct
69 Correct 177 ms 2040 KB Output is correct
70 Correct 186 ms 2056 KB Output is correct
71 Correct 539 ms 5924 KB Output is correct
72 Correct 532 ms 5880 KB Output is correct
73 Correct 536 ms 5884 KB Output is correct
74 Correct 536 ms 5880 KB Output is correct
75 Correct 528 ms 6008 KB Output is correct
76 Correct 442 ms 4216 KB Output is correct
77 Correct 445 ms 4216 KB Output is correct
78 Correct 446 ms 4216 KB Output is correct
79 Correct 450 ms 4216 KB Output is correct
80 Correct 443 ms 4216 KB Output is correct
81 Correct 409 ms 8824 KB Output is correct
82 Correct 397 ms 8312 KB Output is correct
83 Correct 400 ms 7160 KB Output is correct
84 Correct 388 ms 6264 KB Output is correct
85 Correct 382 ms 5496 KB Output is correct
86 Correct 418 ms 8952 KB Output is correct
87 Correct 418 ms 9216 KB Output is correct
88 Correct 430 ms 8952 KB Output is correct
89 Correct 405 ms 9080 KB Output is correct
90 Correct 415 ms 8952 KB Output is correct
91 Correct 232 ms 2664 KB Output is correct
92 Correct 232 ms 2680 KB Output is correct
93 Correct 232 ms 2680 KB Output is correct
94 Correct 232 ms 2684 KB Output is correct
95 Correct 231 ms 2680 KB Output is correct
96 Correct 228 ms 2804 KB Output is correct
97 Correct 235 ms 2680 KB Output is correct
98 Correct 229 ms 2680 KB Output is correct
99 Correct 232 ms 2680 KB Output is correct
100 Correct 233 ms 2680 KB Output is correct
101 Correct 1 ms 288 KB Output is correct
102 Correct 2 ms 384 KB Output is correct
103 Correct 3 ms 384 KB Output is correct
104 Correct 2 ms 384 KB Output is correct
105 Correct 2 ms 384 KB Output is correct
106 Correct 3 ms 384 KB Output is correct