Submission #217011

#TimeUsernameProblemLanguageResultExecution timeMemory
217011sevlllStrange Device (APIO19_strange_device)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <cmath> #include <vector> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <queue> #include <ctime> #include <cassert> #include <complex> #include <string> #include <cstring> #include <chrono> #include <random> #include <queue> #include <bitset> #define pb push_back #define int long long #define str string using namespace std; const int M = 1e9 + 7; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n, a, b; cin >> n >> a >> b; vector<pair<int, int>> pr(n); for (int i = 0; i < n; i++) cin >> pr[i].first >> pr[i].second; int g = __gcd(a, b+1); a /= g; _int128 num = a * b; vector<pair<int, int>> ev; for (auto p : pr) { int l = p.first, r = p.second; l %= num; r %= num; if (r < l) { ev.pb({l, 1}); ev.pb({num, -1}); ev.pb({0, 1}); ev.pb({r+1, -1}); } else { ev.pb({l, 1}); ev.pb({r+1, -1}); } } sort(ev.begin(), ev.end()); int bal = 0; int last = 0; int ans = 0; for (auto p : ev) { int x = p.first, type = p.second; if (bal) { ans += (x - last); } last = x; bal += type; } cout << ans; }

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:38:5: error: '_int128' was not declared in this scope
     _int128 num = a * b;
     ^~~~~~~
strange_device.cpp:38:5: note: suggested alternative: '__int128_t'
     _int128 num = a * b;
     ^~~~~~~
     __int128_t
strange_device.cpp:42:14: error: 'num' was not declared in this scope
         l %= num;
              ^~~
strange_device.cpp:42:14: note: suggested alternative: 'enum'
         l %= num;
              ^~~
              enum
strange_device.cpp:46:28: error: no matching function for call to 'std::vector<std::pair<long long int, long long int> >::push_back(<brace-enclosed initializer list>)'
             ev.pb({num, -1});
                            ^
In file included from /usr/include/c++/7/vector:64:0,
                 from strange_device.cpp:6:
/usr/include/c++/7/bits/stl_vector.h:939:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]
       push_back(const value_type& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:939:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type& {aka const std::pair<long long int, long long int>&}'
/usr/include/c++/7/bits/stl_vector.h:953:7: note: candidate: void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<long long int, long long int>]
       push_back(value_type&& __x)
       ^~~~~~~~~
/usr/include/c++/7/bits/stl_vector.h:953:7: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<long long int, long long int> >::value_type&& {aka std::pair<long long int, long long int>&&}'