답안 #716096

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
716096 2023-03-29T03:20:43 Z tengiz05 Wish (LMIO19_noras) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>

using i64 = long long;

struct Vector {
    i64 x, y;
    Vector(i64 x = 0, i64 y = 0) : x(x), y(y) {}
    Vector operator-(Vector b) {
        return Vector(x - b.x, y - b.y);
    }
    Vector operator+(Vector b) {
        return Vector(x + b.x, y + b.y);
    }
    Vector operator*(i64 k) {
        return Vector(x * k, y * k);
    }
    i64 length() {
        return x * x + y * y;
    }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int n;
    i64 R;
    std::cin >> n >> R;
    
    std::vector<Vector> a(n), b(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i].x >> a[i].y >> b[i].x >> b[i].y;
    }
    
    std::vector<std::pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        Vector cur = a[i];
        Vector delta = b[i] - a[i];
        int lo = 0, hi = 1E9;
        while (lo < hi) {
            int m = (lo + hi + 1) / 2;
            if (cur.length() >= (delta * m).length()) {
                lo = m;
            } else {
                hi = m - 1;
            }
        }
        Vector orig = cur;
        cur = cur + delta * lo;
        if (cur.length() > R * R) {
            cur = cur + delta;
            lo++;
        }
        if (cur.length() > R * R) continue;
        cur = orig;
        for (int j = 0; j < 20005; j++) {
            if (cur.length() <= R * R) {
                if (l == -1) {
                    l = j;
                }
                r = j;
            }
            cur = cur + delta;
        }
        if (l != -1) {
            v.push_back({l, r});
        }
    }
    
    std::vector<std::pair<int, int>> events;
    for (auto [l, r] : v) {
        events.emplace_back(l, 1);
        events.emplace_back(r + 1, -1);
    }
    std::sort(events.begin(), events.end());
    int k = events.size();
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < k; ) {
        int j = i;
        while (j < k && events[i].first == events[j].first)
            j++;
        while (i < j) {
            cnt += events[i].second;
            i++;
        }
        ans = std::max(ans, cnt);
    }
    
    std::cout << ans << "\n";
    
    return 0;
}

Compilation message

noras.cpp: In function 'int main()':
noras.cpp:58:21: error: 'l' was not declared in this scope
   58 |                 if (l == -1) {
      |                     ^
noras.cpp:61:17: error: 'r' was not declared in this scope
   61 |                 r = j;
      |                 ^
noras.cpp:65:13: error: 'l' was not declared in this scope; did you mean 'lo'?
   65 |         if (l != -1) {
      |             ^
      |             lo
noras.cpp:66:29: error: 'r' was not declared in this scope
   66 |             v.push_back({l, r});
      |                             ^
noras.cpp:66:31: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   66 |             v.push_back({l, r});
      |                               ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from noras.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~