Submission #649764

# Submission time Handle Problem Language Result Execution time Memory
649764 2022-10-11T10:39:38 Z ToroTN Strange Device (APIO19_strange_device) C++14
65 / 100
472 ms 16856 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define X first
#define Y second
#define pb push_back
ll n,a,b,x,y,md,cnt=0,mx=-1,l,r,di;
set<pair<ll,ll> > s;
vector<pair<ll,ll> > v;
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    /*for(int i=1;i<=100;i++)
    {
        printf("%d %d %d\n",i,(i+i/b)%a,i%b);
    }*/
    //printf("%d\n",s.size());
    di=a/__gcd(b+1,a);
    if(di>1e18/b)
    {
        md=1e18;
    }else
    {
        md=di*b;
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&x,&y);
        x%=md;
        y%=md;
        if(x<=y)
        {
            v.pb({x,y});
        }else
        {
            v.pb({x,md-1});
            v.pb({0,y});
        }
    }
    sort(v.begin(),v.end());
    for(int i=0;i<v.size();i++)
    {
        l=v[i].X;
        r=v[i].Y;
        if(l>mx)
        {
            cnt+=(r-l+1);
            mx=r;
        }else
        {
            if(r>mx)
            {
                cnt+=r-mx;
                mx=r;
            }
        }
    }
    printf("%lld\n",cnt);
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
strange_device.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%lld%lld%lld",&n,&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%lld%lld",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 5 ms 596 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 6 ms 596 KB Output is correct
17 Correct 47 ms 2424 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 Correct 298 ms 16828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 413 ms 16752 KB Output is correct
3 Correct 431 ms 16748 KB Output is correct
4 Correct 381 ms 16828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 413 ms 16752 KB Output is correct
3 Correct 431 ms 16748 KB Output is correct
4 Correct 381 ms 16828 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 405 ms 16804 KB Output is correct
7 Correct 414 ms 16856 KB Output is correct
8 Correct 397 ms 16804 KB Output is correct
9 Correct 412 ms 16732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 413 ms 16752 KB Output is correct
3 Correct 431 ms 16748 KB Output is correct
4 Correct 381 ms 16828 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 41 ms 2376 KB Output is correct
7 Correct 42 ms 2356 KB Output is correct
8 Correct 42 ms 2452 KB Output is correct
9 Correct 55 ms 2464 KB Output is correct
10 Correct 38 ms 2400 KB Output is correct
11 Correct 38 ms 2396 KB Output is correct
12 Correct 37 ms 2468 KB Output is correct
13 Correct 39 ms 2468 KB Output is correct
14 Correct 37 ms 2376 KB Output is correct
15 Correct 41 ms 2376 KB Output is correct
16 Correct 43 ms 2444 KB Output is correct
17 Correct 42 ms 2412 KB Output is correct
18 Correct 393 ms 16800 KB Output is correct
19 Correct 403 ms 16716 KB Output is correct
20 Correct 448 ms 16716 KB Output is correct
21 Correct 59 ms 2368 KB Output is correct
22 Correct 40 ms 2428 KB Output is correct
23 Correct 119 ms 8532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 47 ms 2456 KB Output is correct
3 Correct 44 ms 2420 KB Output is correct
4 Correct 472 ms 16816 KB Output is correct
5 Correct 43 ms 2368 KB Output is correct
6 Correct 43 ms 2360 KB Output is correct
7 Correct 42 ms 2468 KB Output is correct
8 Correct 45 ms 2464 KB Output is correct
9 Correct 40 ms 2440 KB Output is correct
10 Correct 40 ms 2368 KB Output is correct
11 Correct 44 ms 2352 KB Output is correct
12 Correct 38 ms 2432 KB Output is correct
13 Correct 47 ms 2476 KB Output is correct
14 Correct 427 ms 16728 KB Output is correct
15 Correct 44 ms 2428 KB Output is correct
16 Correct 427 ms 16792 KB Output is correct
17 Correct 422 ms 16816 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 5 ms 604 KB Output is correct
3 Correct 5 ms 596 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 6 ms 596 KB Output is correct
17 Correct 47 ms 2424 KB Output is correct
18 Correct 1 ms 256 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Incorrect 0 ms 212 KB Output isn't correct
21 Halted 0 ms 0 KB -