Submission #983066

#TimeUsernameProblemLanguageResultExecution timeMemory
983066vjudge1Strange Device (APIO19_strange_device)C++17
Compilation error
0 ms0 KiB
#include <time.h> #include <cstdlib> #include <stack> #include <numeric> #include <unordered_map> #include <unordered_set> #include <iomanip> #include <map> #include <set> #include <iterator> #include <deque> #include <queue> #include <sstream> #include <array> #include <string> #include <tuple> #include <chrono> #include <cassert> #include <cstdio> #include <cstring> #include <list> #include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <bitset> #define ll long long using namespace std; ll n, A, B; ll l[1000005], r[1000005], sum = 0; set<pair<ll, ll>> st1, st2, st; int main(){ ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> A >> B; for(int i = 1; i <= n; i++){ cin >> l[i] >> r[i]; sum += (r[i] - l[i] + 1); } if(sum <= 1e6){ for(int i = 1; i <= n; i++){ for(ll j = l[i]; j <= r[i]; j++){ ll x = (j + j / B) % A, y = (j % B); st.insert({x, y}); } } cout << int(st.size()) << "\n"; return 0; } if(n == 1){ ll x = (l[1] + l[1] / B) % A; if(l[1] + B <= r[1]){ ll num = l[1] + B; ll y = (num + num / B) % A; if(x == y){ cout << B << "\n"; return 0; } ll d = abs(x - y); ll ans = gcd(d, A); ll rg = l[1] + ans * B - 1; cout << min(r[1], rg) - l[1] + 1 << "\n"; return 0; } else{ cout << r[1] - l[1] + 1 << "\n"; return 0; } } ll lf[n + 2], rg[n + 2]; for(int i = 1; i <= n; i++){ lf[i] = l[i]; rg[i] = min(r[i], l[i] + A - 1); st1.insert({l[i], i}); // st2.insert({rg[i], i}); } ll ans = 0, mx = 0, mn = 0; bool f = 0; while(!st1.empty()){ if(!f){ auto it = st1.begin(); mn = it->first; mx = r[it->second]; f = 1; st1.erase(st1.begin()); continue; } else{ if(st1.begin()->first <= mx){ auto it = st1.begin(); mx = max(r[it->second], mx); st1.erase(st1.begin()); continue; } else{ ll res = A; if(res % 2 == 1) res *= 2; ans += min(mx - mn + 1, res / 2 - 1); auto it = st1.begin(); mn = it->first; mx = r[it->second]; f = 1; st1.erase(st1.begin()); } } } ll res = A; if(res % 2 == 1) res *= 2; ans += min((mx - mn + 1, res / 2)); cout << ans; }

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:110:25: warning: left operand of comma operator has no effect [-Wunused-value]
  110 |     ans += min((mx - mn + 1, res / 2));
      |                 ~~~~~~~~^~~
strange_device.cpp:110:38: error: no matching function for call to 'min(long long int)'
  110 |     ans += min((mx - mn + 1, res / 2));
      |                                      ^
In file included from /usr/include/c++/10/deque:60,
                 from /usr/include/c++/10/stack:60,
                 from strange_device.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
strange_device.cpp:110:38: note:   candidate expects 2 arguments, 1 provided
  110 |     ans += min((mx - mn + 1, res / 2));
      |                                      ^
In file included from /usr/include/c++/10/deque:60,
                 from /usr/include/c++/10/stack:60,
                 from strange_device.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
strange_device.cpp:110:38: note:   candidate expects 3 arguments, 1 provided
  110 |     ans += min((mx - mn + 1, res / 2));
      |                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from strange_device.cpp:25:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
strange_device.cpp:110:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  110 |     ans += min((mx - mn + 1, res / 2));
      |                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from strange_device.cpp:25:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
strange_device.cpp:110:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  110 |     ans += min((mx - mn + 1, res / 2));
      |                                      ^