Submission #1261872

#TimeUsernameProblemLanguageResultExecution timeMemory
1261872wedonttalkanymore이상한 기계 (APIO19_strange_device)C++20
100 / 100
612 ms78740 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define int long long #define pii pair<ll, ll> #define fi first #define se second const ll N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7, block = 320, lim = 16; int n, A, B; map <__int128_t, int> mp; string convert(__int128_t x) { string s = ""; while(x > 0) { int t = x % 10; s += char(t + '0'); x /= 10; } reverse(s.begin(), s.end()); return s; } signed main() { ios::sync_with_stdio(false); cin.tie(0); if (fopen(".inp", "r")) { freopen(".inp", "r", stdin); freopen(".out", "w", stdout); } cin >> n >> A >> B; int t = __gcd(A, B + 1); int x = A / t; __int128_t L = __int128_t(x) * __int128_t(B); // chu ki mp[0] = mp[L] = 0; for (int i = 1; i <= n; i++) { int l, r; cin >> l >> r; if (L <= r - l + 1) { cout << convert(L); // cout << 1; return 0; } mp[l % L]++, mp[r % L + 1]--; if (l % L > r % L) mp[0]++, mp[L]--; } __int128_t ans = 0, last = 0, sum = 0; for (auto [id, val] : mp) { if (sum) { ans += id - last; } sum += val; last = id; } cout << convert(ans); return 0; }

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
strange_device.cpp:31:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |         freopen(".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...