Submission #444239

# Submission time Handle Problem Language Result Execution time Memory
444239 2021-07-13T12:20:38 Z qwerasdfzxcl Strange Device (APIO19_strange_device) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

typedef __int128_t l128;
typedef long long ll;
using namespace std;


int main(){
    int n;
    ll x, y;
    scanf("%d %lld %lld", &n, &x, &y);
    l128 t = y;
    t *= x/__gcd(x, y+1);
    ll MOD = (ll)1e18+10;
    if (t<=(ll)1e18+10) MOD = t;
    //printf("%lld\n", MOD);

    vector<pair<ll, ll>> ran;
    for (int i=0;i<n;i++){
        ll tmp1, tmp2;
        scanf("%lld %lld", &tmp1, &tmp2);
        if (tmp2-tmp1+1>=MOD) {printf("%lld\n", MOD); return 0;}
        tmp2++;
        tmp1 %= MOD, tmp2 %= MOD;
        if (tmp2<tmp1){
            ran.emplace_back(tmp1, MOD);
            ran.emplace_back(0, tmp2);
        }
        else ran.emplace_back(tmp1, tmp2);
    }
    sort(ran.begin(), ran.end());
    ll ans = 0;
    pair<ll, ll> cur = {0, 0};
    n = ran.size();
    for (int i=0;i<n;i++){
        if (cur.first<=ran[i].first && ran[i].first<=cur.second){
            ans += max(ran[i].second-cur.second, 0);
            cur.second = max(cur.second, ran[i].second);
        }
        else{
            ans += ran[i].second-ran[i].first;
            cur = ran[i];
        }
    }
    printf("%lld\n", ans);
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:37:51: error: no matching function for call to 'max(long long int, int)'
   37 |             ans += max(ran[i].second-cur.second, 0);
      |                                                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from strange_device.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:
strange_device.cpp:37:51: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   37 |             ans += max(ran[i].second-cur.second, 0);
      |                                                   ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from strange_device.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:
strange_device.cpp:37:51: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   37 |             ans += max(ran[i].second-cur.second, 0);
      |                                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from strange_device.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:
strange_device.cpp:37:51: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |             ans += max(ran[i].second-cur.second, 0);
      |                                                   ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from strange_device.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:
strange_device.cpp:37:51: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   37 |             ans += max(ran[i].second-cur.second, 0);
      |                                                   ^
strange_device.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     scanf("%d %lld %lld", &n, &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%lld %lld", &tmp1, &tmp2);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~