이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma")
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef long double ld;
typedef pair<int , int> pii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 3e6;
const ll mod = 1e9+7;
const ld PI = acos((ld)-1);
#define pb push_back
#define endl '\n'
#define dokme(x) cout << x , exit(0)
#define migmig ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(x , y) memset(x , y , sizeof x)
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}
int n , m , a , b;
map < int , int > mp;
int32_t main(){
migmig;
cin >> n >> a >> b;
int ans = 0;
m = a / __gcd(a , b + 1) > 1e18 / (b + 1) ? int(1e18 + 1) : a / __gcd(a , b + 1) * b;
while(n -- ){
int l , r;
cin >> l >> r;
int L = l % m , R = r % m;
if( r- l >= m) ans = m;
else if ( L < R ) mp[L] ++ , mp[R + 1]--;
else if ( L > R ) mp[L] ++ , mp[m]-- , mp[0] ++ , mp[R + 1]--;
else if (l == r) mp[L] ++ , mp[L + 1] --;
else ans = m;
}
int s = 0 , f = 1 , l;
if(ans ^ m){
for(auto i : mp){
s += i.second;
if(s and f)
l = i.first , f = 0;
else if (!s)
ans += i.first - l , f = 1;
}
}
cout << ans;
return(0);
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int32_t main()':
strange_device.cpp:54:20: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
54 | ans += i.first - l , f = 1;
| ~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |