Submission #744180

# Submission time Handle Problem Language Result Execution time Memory
744180 2023-05-18T09:00:49 Z iamporrrrrrrrr Strange Device (APIO19_strange_device) C++14
35 / 100
567 ms 17716 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
set<int> s;
vector<pair<int,int>> v;
int g(int a,int b){
    if(b==0) return a;
    return g(b,a%b);
}
signed main()
{
    ios::sync_with_stdio(0),cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    int mod = (a*b)/g(max(a,b+1),min(a,b+1));
    for(int i=1;i<=n;i++){
        int x,y;
        cin>>x>>y;
        if(y-x>mod){
            cout<<mod;
            return 0;
        }
        x%=mod;
        y%=mod;
        if(y>=x){
            v.push_back({x,y});
        }
        else v.push_back({x,mod-1}),v.push_back({0,y});

    }
    sort(v.begin(),v.end());
    int rr=-1,ans=0;
    for(int i=0;i<v.size();i++){
        int l=v[i].first;
        int r=v[i].second;
        if(l>rr){
            ans+=(r-l+1);
            rr=r;
        }
        else if(l<=rr&&r>rr){
            ans+=(r-rr);
            rr=r;
        }
    }
    cout<<ans;
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:33:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<v.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 880 KB Output is correct
3 Correct 5 ms 856 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 904 KB Output is correct
17 Correct 55 ms 2844 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Incorrect 1 ms 212 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 290 ms 17264 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 412 ms 17112 KB Output is correct
3 Correct 392 ms 17292 KB Output is correct
4 Correct 362 ms 17392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 412 ms 17112 KB Output is correct
3 Correct 392 ms 17292 KB Output is correct
4 Correct 362 ms 17392 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 396 ms 17180 KB Output is correct
7 Correct 420 ms 17276 KB Output is correct
8 Correct 381 ms 17004 KB Output is correct
9 Correct 567 ms 17716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 412 ms 17112 KB Output is correct
3 Correct 392 ms 17292 KB Output is correct
4 Correct 362 ms 17392 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 42 ms 2976 KB Output is correct
7 Correct 53 ms 2860 KB Output is correct
8 Correct 46 ms 2920 KB Output is correct
9 Correct 45 ms 2892 KB Output is correct
10 Correct 52 ms 2904 KB Output is correct
11 Correct 59 ms 2972 KB Output is correct
12 Correct 47 ms 2896 KB Output is correct
13 Correct 48 ms 2952 KB Output is correct
14 Correct 45 ms 2956 KB Output is correct
15 Correct 53 ms 2960 KB Output is correct
16 Correct 54 ms 2924 KB Output is correct
17 Correct 52 ms 2884 KB Output is correct
18 Correct 465 ms 17360 KB Output is correct
19 Correct 442 ms 17168 KB Output is correct
20 Correct 527 ms 17344 KB Output is correct
21 Correct 56 ms 2988 KB Output is correct
22 Correct 47 ms 2964 KB Output is correct
23 Correct 152 ms 9196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 50 ms 2972 KB Output is correct
3 Correct 45 ms 2968 KB Output is correct
4 Correct 535 ms 17260 KB Output is correct
5 Correct 51 ms 3028 KB Output is correct
6 Correct 52 ms 2996 KB Output is correct
7 Correct 50 ms 2992 KB Output is correct
8 Correct 54 ms 3004 KB Output is correct
9 Correct 52 ms 2924 KB Output is correct
10 Correct 51 ms 2932 KB Output is correct
11 Correct 47 ms 3132 KB Output is correct
12 Correct 41 ms 3096 KB Output is correct
13 Correct 49 ms 2928 KB Output is correct
14 Correct 442 ms 17404 KB Output is correct
15 Correct 47 ms 2824 KB Output is correct
16 Correct 444 ms 17400 KB Output is correct
17 Correct 437 ms 17400 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 5 ms 880 KB Output is correct
3 Correct 5 ms 856 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 4 ms 904 KB Output is correct
17 Correct 55 ms 2844 KB Output is correct
18 Incorrect 1 ms 212 KB Output isn't correct
19 Halted 0 ms 0 KB -