제출 #1148942

#제출 시각아이디문제언어결과실행 시간메모리
1148942blackslexStrange Device (APIO19_strange_device)C++20
10 / 100
462 ms33388 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<ll, ll>; int n; ll a, b, x, y; int main() { scanf("%d %lld %lld", &n, &a, &b); ll m = (a > 1e18 / b ? 1e18 : 1LL * a * b); vector<pii> c; auto add = [&] (ll l, ll r) { if (l > r) return; l %= m; r %= m; if (l > r) { c.emplace_back(l, m - 1); c.emplace_back(0, r); } else { c.emplace_back(l, r); } }; for (int i = 0; i < n; i++) { scanf("%lld %lld", &x, &y); add(x, min(y, x + (m - x % m - 1))); add(x + (m - x % m), y - y % m - 1); add(max(x, y - y % m), y); } sort(c.begin(), c.end()); ll ans = 0, st = 0, ed = -1; for (auto &[x, y]: c) { if (x <= ed) ed = max(ed, y); else { ans += ed - st + 1; st = x; ed = y; } } ans += ed - st + 1; printf("%lld", ans); }

컴파일 시 표준 에러 (stderr) 메시지

strange_device.cpp: In function 'int main()':
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, &a, &b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%lld %lld", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...