답안 #203145

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
203145 2020-02-19T14:10:54 Z Mercenary 이상한 기계 (APIO19_strange_device) C++14
5 / 100
588 ms 53472 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 2e5 + 5;
const int mod = 1e9 + 7;
int n  , A , B;
const ll inf = 1e18 + 3;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n >> A >> B;
    ll d = __gcd(A,B+1);A /= d;
    if(A > inf / B)A = inf;
    else A *= B;
    vector<pair<ll,ll>> val;
    while(n--){
        ll l ,r;cin >> l >> r;
        if(r - l + 1 >= A)return cout << A , 0;
        l %= A;r %= A;
//        cout << l << " " << r << endl;
        if(l <= r)val.pb(mp(l,r));
        else val.pb(mp(0,r)),val.pb(mp(l,A-1));
    }
    sort(val.begin(),val.end());
    ll cur = 0 , res = 0;
    for(auto c : val){
        if(cur <= c.second){
            res += c.second - max(cur,c.first) + 1;
        }
//        cout << c.first << " " <<  c.second << " " << cur << " " << res << endl;
        cur = max(cur,c.second+1);
    }
    cout << res;
}


Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:32:24: warning: overflow in implicit constant conversion [-Woverflow]
     if(A > inf / B)A = inf;
                        ^~~
strange_device.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:28:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 11 ms 1108 KB Output is correct
3 Correct 11 ms 1144 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 10 ms 1144 KB Output is correct
17 Correct 67 ms 5736 KB Output is correct
18 Runtime error 5 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Runtime error 5 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 407 ms 41408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 588 ms 53472 KB Output is correct
3 Runtime error 5 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 588 ms 53472 KB Output is correct
3 Runtime error 5 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 588 ms 53472 KB Output is correct
3 Runtime error 5 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 61 ms 5708 KB Output is correct
3 Incorrect 58 ms 5736 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 11 ms 1108 KB Output is correct
3 Correct 11 ms 1144 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 380 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 380 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 10 ms 1144 KB Output is correct
17 Correct 67 ms 5736 KB Output is correct
18 Runtime error 5 ms 504 KB Execution killed with signal 8 (could be triggered by violating memory limits)