Submission #410622

#TimeUsernameProblemLanguageResultExecution timeMemory
410622dynam1cStrange Device (APIO19_strange_device)C++17
Compilation error
0 ms0 KiB
//#pragma comment(linker, "/stack:200000000") //#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" #define all(c) (c).begin(),(c).end() // when you ponder, divide and conquer #define lo __int128 lo gcd(lo x, lo y) { if (x == 0) return y; return gcd(y % x, x); } signed main() { // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); std::ios::sync_with_stdio(false); cin.tie(0); ll n, a, b; cin >> n >> a >> b; lo g = gcd(b+1, (lo) a * b); lo m = (lo) a * b / g; vector<pair<lo, int>> evs; for (int i = 0; i < n; i++) { ll xl, xr; cin >> xl >> xr; xr++; lo l = xl % m; lo r = xr % m; if (r < l) evs.emplace_back(0, 1), evs.emplace_back(r, -1), evs.emplace_back(l, 1), evs.emplace_back(m, -1); else evs.emplace_back(l, 1), evs.emplace_back(r, -1); } sort(all(evs)); ll res = 0; lo p = 0; int c = 0; for (auto [x, t] : evs) { if (c == 0) p = x; c += t; if (c == 0) res += x-p; } cout << res << endl; } /* --- PSolving --- * Simplifying (getting rid of variables, conditions, code logic, etc.) * Reframing * Solving a subtask (subgoal, aux. problem, removing a condition or fixing a parameter, etc.) * Inducing * Divide and conquer * Working backwards * Visual intuition * !! Reductions don't have to be specializations, they can be generalizations */

Compilation message (stderr)

In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:84,
                 from strange_device.cpp:4:
/usr/include/c++/10/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]':
strange_device.cpp:28:28:   required from here
/usr/include/c++/10/numeric:134:21: error: static assertion failed: gcd arguments are integers
  134 |       static_assert(is_integral_v<_Nn>, "gcd arguments are integers");
      |                     ^~~~~~~~~~~~~~~~~~
/usr/include/c++/10/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]':
/usr/include/c++/10/numeric:139:29:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]'
strange_device.cpp:28:28:   required from here
/usr/include/c++/10/numeric:104:49: error: use of deleted function 'void std::__detail::__abs_integral(bool)'
  104 |       return __m == 0 ? __detail::__abs_integral(__n)
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/numeric:98:8: note: declared here
   98 |   void __abs_integral(bool) = delete;
      |        ^~~~~~~~~~~~~~
/usr/include/c++/10/numeric: In instantiation of 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = __int128; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]':
/usr/include/c++/10/numeric:106:19:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::__detail::__gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]'
/usr/include/c++/10/numeric:139:29:   required from 'constexpr std::common_type_t<_Mn, _Nn> std::gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; std::common_type_t<_Mn, _Nn> = __int128]'
strange_device.cpp:28:28:   required from here
/usr/include/c++/10/numeric:104:49: error: use of deleted function 'void std::__detail::__abs_integral(bool)'
  104 |       return __m == 0 ? __detail::__abs_integral(__n)
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/numeric:98:8: note: declared here
   98 |   void __abs_integral(bool) = delete;
      |        ^~~~~~~~~~~~~~
/usr/include/c++/10/numeric:105:39: error: use of deleted function 'void std::__detail::__abs_integral(bool)'
  105 |  : __n == 0 ? __detail::__abs_integral(__m)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/10/numeric:98:8: note: declared here
   98 |   void __abs_integral(bool) = delete;
      |        ^~~~~~~~~~~~~~