Submission #965261

# Submission time Handle Problem Language Result Execution time Memory
965261 2024-04-18T09:04:32 Z AtabayRajabli Wish (LMIO19_noras) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

// author : a1abay

#define all(v)      v.begin(), v.end()
#define GCD(a, b)   __gcd(a, b)
#define LCM(a, b)   (a*b / (__gcd(a, b)))
#define int         ll

typedef long long           ll;
typedef long double         ld;
const int inf =             1e9 + 7;
const int inff =            (int)1e18 + 7;
const int sz =              2e5 + 5;
using namespace             std;

int n;
ld r;
vector<array<int, 2>> v;

ld disc(ld a, ld b, ld c)
{
    return b * b - 4 * a * c;
}

ld get(ld a, ld b, ld d)
{
    return (-b + sqrtl(d)) / (2 * a);
}

ld get2(ld a, ld b, ld d)
{
    return (-b - sqrtl(d)) / (2 * a);
}

signed main()   
{       
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    cin >> n >> r;
    
    for(int i = 1; i <= n; i++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        c -= a;
        d -= b;
        int ds = disc(c * c + d * d, 2 * a * c + 2 * b * d, a * a + b * b - r * r);
        if(ds < 0)continue;
        ld x1 = get(c * c + d * d, 2 * a * c + 2 * b * d, ds);
        ld x2 = get2(c * c + d * d, 2 * a * c + 2 * b * d, ds);
        if(x2 < 0LL)continue;
        x1 = ceil(x1);
        x2 = floor(x2);
        if(x1 > x2)continue;
        x1 = max(x1, 0LL);
        v.push_back({(int)x1, 1});
        v.push_back({(int)x2 + 1, -1});
    }

    int s = 0, mx = 0;
    sort(all(v));
    for(auto i : v)
    {
        s += i[1];
        mx = max(mx, s);
    }
    cout << mx;
}

Compilation message

noras.cpp: In function 'int main()':
noras.cpp:58:25: error: no matching function for call to 'max(ld&, long long int)'
   58 |         x1 = max(x1, 0LL);
      |                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from noras.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
noras.cpp:58:25: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and 'long long int')
   58 |         x1 = max(x1, 0LL);
      |                         ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from noras.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
noras.cpp:58:25: note:   deduced conflicting types for parameter 'const _Tp' ('long double' and 'long long int')
   58 |         x1 = max(x1, 0LL);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from noras.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
noras.cpp:58:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   58 |         x1 = max(x1, 0LL);
      |                         ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from noras.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
noras.cpp:58:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long double'
   58 |         x1 = max(x1, 0LL);
      |                         ^