제출 #333138

#제출 시각아이디문제언어결과실행 시간메모리
333138qwe854896이상한 기계 (APIO19_strange_device)C++14
65 / 100
842 ms82256 KiB
#include<bits/stdc++.h> #define endl '\n' #define int long long #define X first #define Y second using namespace std; map <int, int> m; signed main() { ios::sync_with_stdio(0); cin.tie(0); int n, A, B; cin >> n >> A >> B; int ans = 0, MOD = log10(A) - log10(__gcd(A, B+1)) + log10(B) > 18 ? (long long)(1e18+1) : A / __gcd(A, B+1) * B; while (n--) { int l, r; cin >> l >> r; int L = l % MOD, R = r % MOD; if (L < R) m[L]++, m[R+1]--; else if (L > R) m[L]++, m[MOD]--, m[0]++, m[R+1]--; else if (l == r) m[L]++, m[L+1]--; else ans = MOD; } int sum = 0, f = 1, l; if (ans != MOD) { for (auto seg:m) { //cout << seg.X << ' ' << seg.Y << endl; sum += seg.Y; if (sum and f) l = seg.X, f = 0; else if (!sum) ans += seg.X - l, f = 1; } } cout << ans << endl; return 0; }

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

strange_device.cpp: In function 'int main()':
strange_device.cpp:32:32: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   32 |    else if (!sum) ans += seg.X - l, f = 1;
      |                          ~~~~~~^~~
#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...