답안 #649809

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
649809 2022-10-11T11:04:15 Z ToroTN 이상한 기계 (APIO19_strange_device) C++14
100 / 100
514 ms 34196 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;
ll gcdprajao(ll a,ll b)
{
    if(b==0)return a;
    return gcdprajao(b,a%b);
}
int main()
{
    scanf("%lld%lld%lld",&n,&a,&b);
    di=a/gcdprajao(b+1,a);
    if((double)di>(double)(1e18+1)/b)
    {
        md=1e18+1;
    }else
    {
        md=di*b;
    }
    //printf("%lld\n",md);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld%lld",&x,&y);
        if(y-x>=md-1)
        {
            v.pb({0,md-1});
            continue;
        }
        if(x!=0)x%=md;
        if(y!=0)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:47: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]
   47 |     for(int i=0;i<v.size();i++)
      |                 ~^~~~~~~~~
strange_device.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%lld%lld%lld",&n,&a,&b);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf("%lld%lld",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 7 ms 852 KB Output is correct
3 Correct 5 ms 904 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 300 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 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 904 KB Output is correct
17 Correct 52 ms 2536 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 352 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 328 ms 17048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 440 ms 16816 KB Output is correct
3 Correct 441 ms 17308 KB Output is correct
4 Correct 402 ms 17108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 440 ms 16816 KB Output is correct
3 Correct 441 ms 17308 KB Output is correct
4 Correct 402 ms 17108 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 433 ms 17180 KB Output is correct
7 Correct 433 ms 17244 KB Output is correct
8 Correct 411 ms 17124 KB Output is correct
9 Correct 427 ms 17188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 440 ms 16816 KB Output is correct
3 Correct 441 ms 17308 KB Output is correct
4 Correct 402 ms 17108 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 42 ms 2460 KB Output is correct
7 Correct 49 ms 2688 KB Output is correct
8 Correct 49 ms 2532 KB Output is correct
9 Correct 39 ms 2556 KB Output is correct
10 Correct 40 ms 2432 KB Output is correct
11 Correct 43 ms 2492 KB Output is correct
12 Correct 48 ms 2448 KB Output is correct
13 Correct 46 ms 2492 KB Output is correct
14 Correct 40 ms 2472 KB Output is correct
15 Correct 42 ms 2644 KB Output is correct
16 Correct 45 ms 2508 KB Output is correct
17 Correct 44 ms 2448 KB Output is correct
18 Correct 413 ms 17152 KB Output is correct
19 Correct 412 ms 17180 KB Output is correct
20 Correct 442 ms 17188 KB Output is correct
21 Correct 48 ms 2492 KB Output is correct
22 Correct 38 ms 2472 KB Output is correct
23 Correct 131 ms 8964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 45 ms 2488 KB Output is correct
3 Correct 45 ms 2564 KB Output is correct
4 Correct 478 ms 17160 KB Output is correct
5 Correct 41 ms 2552 KB Output is correct
6 Correct 58 ms 2624 KB Output is correct
7 Correct 46 ms 2492 KB Output is correct
8 Correct 43 ms 2496 KB Output is correct
9 Correct 44 ms 2624 KB Output is correct
10 Correct 45 ms 2496 KB Output is correct
11 Correct 56 ms 2556 KB Output is correct
12 Correct 39 ms 2560 KB Output is correct
13 Correct 42 ms 2448 KB Output is correct
14 Correct 439 ms 17112 KB Output is correct
15 Correct 44 ms 2436 KB Output is correct
16 Correct 391 ms 17304 KB Output is correct
17 Correct 388 ms 17180 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 7 ms 852 KB Output is correct
3 Correct 5 ms 904 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 300 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 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 296 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 5 ms 904 KB Output is correct
17 Correct 52 ms 2536 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 296 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 352 KB Output is correct
27 Correct 1 ms 312 KB Output is correct
28 Correct 328 ms 17048 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 440 ms 16816 KB Output is correct
31 Correct 441 ms 17308 KB Output is correct
32 Correct 402 ms 17108 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 433 ms 17180 KB Output is correct
35 Correct 433 ms 17244 KB Output is correct
36 Correct 411 ms 17124 KB Output is correct
37 Correct 427 ms 17188 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 42 ms 2460 KB Output is correct
40 Correct 49 ms 2688 KB Output is correct
41 Correct 49 ms 2532 KB Output is correct
42 Correct 39 ms 2556 KB Output is correct
43 Correct 40 ms 2432 KB Output is correct
44 Correct 43 ms 2492 KB Output is correct
45 Correct 48 ms 2448 KB Output is correct
46 Correct 46 ms 2492 KB Output is correct
47 Correct 40 ms 2472 KB Output is correct
48 Correct 42 ms 2644 KB Output is correct
49 Correct 45 ms 2508 KB Output is correct
50 Correct 44 ms 2448 KB Output is correct
51 Correct 413 ms 17152 KB Output is correct
52 Correct 412 ms 17180 KB Output is correct
53 Correct 442 ms 17188 KB Output is correct
54 Correct 48 ms 2492 KB Output is correct
55 Correct 38 ms 2472 KB Output is correct
56 Correct 131 ms 8964 KB Output is correct
57 Correct 1 ms 212 KB Output is correct
58 Correct 45 ms 2488 KB Output is correct
59 Correct 45 ms 2564 KB Output is correct
60 Correct 478 ms 17160 KB Output is correct
61 Correct 41 ms 2552 KB Output is correct
62 Correct 58 ms 2624 KB Output is correct
63 Correct 46 ms 2492 KB Output is correct
64 Correct 43 ms 2496 KB Output is correct
65 Correct 44 ms 2624 KB Output is correct
66 Correct 45 ms 2496 KB Output is correct
67 Correct 56 ms 2556 KB Output is correct
68 Correct 39 ms 2560 KB Output is correct
69 Correct 42 ms 2448 KB Output is correct
70 Correct 439 ms 17112 KB Output is correct
71 Correct 44 ms 2436 KB Output is correct
72 Correct 391 ms 17304 KB Output is correct
73 Correct 388 ms 17180 KB Output is correct
74 Correct 0 ms 212 KB Output is correct
75 Correct 1 ms 300 KB Output is correct
76 Correct 1 ms 212 KB Output is correct
77 Correct 1 ms 212 KB Output is correct
78 Correct 0 ms 212 KB Output is correct
79 Correct 5 ms 980 KB Output is correct
80 Correct 514 ms 34016 KB Output is correct
81 Correct 501 ms 34072 KB Output is correct
82 Correct 456 ms 34196 KB Output is correct
83 Correct 445 ms 34076 KB Output is correct
84 Correct 443 ms 34004 KB Output is correct
85 Correct 435 ms 34064 KB Output is correct
86 Correct 132 ms 18456 KB Output is correct
87 Correct 1 ms 212 KB Output is correct