Submission #934700

#TimeUsernameProblemLanguageResultExecution timeMemory
934700haxormanStrange Device (APIO19_strange_device)C++14
15 / 100
329 ms53824 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mxN = 1e6 + 7; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, a, b; cin >> n >> a >> b; __int128 p = a; p *= b; p /= __gcd(a, b+1); int ans = 0; vector<pair<int,int>> ranges; for (int i = 0; i < n; ++i) { int l, r; cin >> l >> r; if (r - l + 1 >= p) { ans = p; } l %= p, r %= p; if (r < l) { ranges.push_back({l, p-1}); ranges.push_back({0, r}); } else { ranges.push_back({l, r}); } } if (ans == p) { cout << ans << "\n"; exit(0); } sort(ranges.begin(), ranges.end()); auto [l, r] = ranges[0]; for (int i = 1; i < ranges.size(); ++i) { auto [lb, rb] = ranges[i]; if (lb <= r) { rb = r; } else { ans += r - l + 1; l = lb, r = rb; } } ans += r - l + 1; cout << ans << "\n"; }

Compilation message (stderr)

strange_device.cpp: In function 'int32_t main()':
strange_device.cpp:44:10: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   44 |     auto [l, r] = ranges[0];
      |          ^
strange_device.cpp:45:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for (int i = 1; i < ranges.size(); ++i) {
      |                     ~~^~~~~~~~~~~~~~~
strange_device.cpp:46:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   46 |         auto [lb, rb] = ranges[i];
      |              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...