답안 #359366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
359366 2021-01-27T00:34:11 Z eyangch 이상한 기계 (APIO19_strange_device) C++17
5 / 100
859 ms 100460 KB
#include <bits/stdc++.h>
#define endl "\n"
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;

int N;
ll A, B, MOD;
set<pii> s1;

void upd(ll l, ll r){
    auto it = s1.upper_bound({l, LLONG_MAX});
    vector<pii> rm;
    if(it != s1.begin()){
        it--;
        if(it -> second >= r){
            return;
        }
        if(it -> second >= l){
            l = it -> first;
            rm.push_back(*it);
        }
        it++;
    }
    for(; it != s1.end(); it++){
        if(it -> first > r) break;
        l = min(l, it -> first);
        r = max(r, it -> second);
        rm.push_back(*it);
    }
    for(pii i : rm){
        s1.erase(i);
    }
    s1.insert({l, r});
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> A >> B;
    __int128 mp = A * B;
    MOD = (mp > 1e18 ? 1e18+1 : (ll)mp);
    for(int i = 0; i < N; i++){
        ll l, r; cin >> l >> r;
        l %= MOD, r %= MOD;
        if(l > r){
            upd(l, MOD-1);
            upd(0, r);
        }else{
            upd(l, r);
        }
    }
    ll ans = 0;
    for(pii i : s1){
        ans += i.se - i.fi + 1;
    }
    cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 8 ms 1388 KB Output is correct
3 Correct 7 ms 1388 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 312 ms 25580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 804 ms 90500 KB Output is correct
3 Incorrect 832 ms 100260 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 804 ms 90500 KB Output is correct
3 Incorrect 832 ms 100260 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 804 ms 90500 KB Output is correct
3 Incorrect 832 ms 100260 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 80 ms 10220 KB Output is correct
3 Correct 81 ms 10376 KB Output is correct
4 Correct 829 ms 100460 KB Output is correct
5 Correct 80 ms 10348 KB Output is correct
6 Correct 85 ms 10348 KB Output is correct
7 Correct 81 ms 10348 KB Output is correct
8 Correct 82 ms 10348 KB Output is correct
9 Correct 77 ms 10348 KB Output is correct
10 Correct 76 ms 10348 KB Output is correct
11 Correct 85 ms 10348 KB Output is correct
12 Correct 77 ms 10348 KB Output is correct
13 Correct 81 ms 10348 KB Output is correct
14 Correct 859 ms 100332 KB Output is correct
15 Incorrect 76 ms 10476 KB Output isn't correct
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 8 ms 1388 KB Output is correct
3 Correct 7 ms 1388 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -