답안 #523962

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523962 2022-02-08T13:22:35 Z Koosha_mv 이상한 기계 (APIO19_strange_device) C++14
100 / 100
485 ms 53304 KB
#include <bits/stdc++.h>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<(x.F)<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#define int ll

const int N=1e6+99,inf=1e18+99;

int n,A,B,mod;
ll ans;
vector<pair<int,int> > v;

void find(){
	__int128	a=A,b=B,INF=inf;
	a=a/__gcd(a,b+1);
	mod=min(INF,a*b);
	//eror(mod);
}

main(){
	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
	cin>>n>>A>>B;
	find();
	f(i,0,n){
		int l,r;
		cin>>l>>r;
		if(l/mod+1<r/mod){
			cout<<mod;
			exit(0);
		}
		if(l/mod==r/mod){
			v.pb(mp(l%mod,r%mod));
		}
		else{
			v.pb(mp(l%mod,mod-1));
			v.pb(mp(0,r%mod));
		}
	}
	sort(all(v));
	int mx=-1;
	f(i,0,v.size()){
		//erorp(v[i]);
		ans+=max(0ll,v[i].F-mx-1);
		maxm(mx,v[i].S);
	}
	ans+=mod-mx-1;
	cout<<mod-ans;
}

Compilation message

strange_device.cpp:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 | main(){
      | ^~~~
strange_device.cpp: In function 'int main()':
strange_device.cpp:8:31: 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]
    8 | #define f(i,a,b) for(int i=a;i<b;i++)
......
   58 |  f(i,0,v.size()){
      |    ~~~~~~~~~~~~                
strange_device.cpp:58:2: note: in expansion of macro 'f'
   58 |  f(i,0,v.size()){
      |  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 5 ms 1080 KB Output is correct
3 Correct 5 ms 1028 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 4 ms 964 KB Output is correct
17 Correct 47 ms 5684 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 312 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 312 KB Output is correct
2 Correct 1 ms 360 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 310 ms 41224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 403 ms 53276 KB Output is correct
3 Correct 392 ms 53296 KB Output is correct
4 Correct 377 ms 53172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 403 ms 53276 KB Output is correct
3 Correct 392 ms 53296 KB Output is correct
4 Correct 377 ms 53172 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 393 ms 53284 KB Output is correct
7 Correct 402 ms 53204 KB Output is correct
8 Correct 390 ms 53168 KB Output is correct
9 Correct 443 ms 53304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 403 ms 53276 KB Output is correct
3 Correct 392 ms 53296 KB Output is correct
4 Correct 377 ms 53172 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 45 ms 5704 KB Output is correct
7 Correct 41 ms 5704 KB Output is correct
8 Correct 39 ms 5688 KB Output is correct
9 Correct 40 ms 5620 KB Output is correct
10 Correct 42 ms 5724 KB Output is correct
11 Correct 44 ms 5608 KB Output is correct
12 Correct 40 ms 5700 KB Output is correct
13 Correct 43 ms 5612 KB Output is correct
14 Correct 38 ms 5620 KB Output is correct
15 Correct 50 ms 5680 KB Output is correct
16 Correct 43 ms 5696 KB Output is correct
17 Correct 40 ms 5612 KB Output is correct
18 Correct 414 ms 53256 KB Output is correct
19 Correct 408 ms 53216 KB Output is correct
20 Correct 456 ms 52776 KB Output is correct
21 Correct 42 ms 5688 KB Output is correct
22 Correct 38 ms 5596 KB Output is correct
23 Correct 126 ms 18536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 316 KB Output is correct
2 Correct 42 ms 5664 KB Output is correct
3 Correct 41 ms 5656 KB Output is correct
4 Correct 472 ms 52792 KB Output is correct
5 Correct 48 ms 5820 KB Output is correct
6 Correct 42 ms 5644 KB Output is correct
7 Correct 45 ms 5684 KB Output is correct
8 Correct 49 ms 5852 KB Output is correct
9 Correct 44 ms 5608 KB Output is correct
10 Correct 51 ms 5604 KB Output is correct
11 Correct 43 ms 5724 KB Output is correct
12 Correct 39 ms 5648 KB Output is correct
13 Correct 44 ms 5864 KB Output is correct
14 Correct 472 ms 52588 KB Output is correct
15 Correct 45 ms 5632 KB Output is correct
16 Correct 430 ms 52276 KB Output is correct
17 Correct 401 ms 52260 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 5 ms 1080 KB Output is correct
3 Correct 5 ms 1028 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 312 KB Output is correct
8 Correct 1 ms 308 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 4 ms 964 KB Output is correct
17 Correct 47 ms 5684 KB Output is correct
18 Correct 1 ms 308 KB Output is correct
19 Correct 0 ms 312 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 0 ms 312 KB Output is correct
25 Correct 1 ms 360 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 310 ms 41224 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 403 ms 53276 KB Output is correct
31 Correct 392 ms 53296 KB Output is correct
32 Correct 377 ms 53172 KB Output is correct
33 Correct 1 ms 312 KB Output is correct
34 Correct 393 ms 53284 KB Output is correct
35 Correct 402 ms 53204 KB Output is correct
36 Correct 390 ms 53168 KB Output is correct
37 Correct 443 ms 53304 KB Output is correct
38 Correct 1 ms 312 KB Output is correct
39 Correct 45 ms 5704 KB Output is correct
40 Correct 41 ms 5704 KB Output is correct
41 Correct 39 ms 5688 KB Output is correct
42 Correct 40 ms 5620 KB Output is correct
43 Correct 42 ms 5724 KB Output is correct
44 Correct 44 ms 5608 KB Output is correct
45 Correct 40 ms 5700 KB Output is correct
46 Correct 43 ms 5612 KB Output is correct
47 Correct 38 ms 5620 KB Output is correct
48 Correct 50 ms 5680 KB Output is correct
49 Correct 43 ms 5696 KB Output is correct
50 Correct 40 ms 5612 KB Output is correct
51 Correct 414 ms 53256 KB Output is correct
52 Correct 408 ms 53216 KB Output is correct
53 Correct 456 ms 52776 KB Output is correct
54 Correct 42 ms 5688 KB Output is correct
55 Correct 38 ms 5596 KB Output is correct
56 Correct 126 ms 18536 KB Output is correct
57 Correct 1 ms 316 KB Output is correct
58 Correct 42 ms 5664 KB Output is correct
59 Correct 41 ms 5656 KB Output is correct
60 Correct 472 ms 52792 KB Output is correct
61 Correct 48 ms 5820 KB Output is correct
62 Correct 42 ms 5644 KB Output is correct
63 Correct 45 ms 5684 KB Output is correct
64 Correct 49 ms 5852 KB Output is correct
65 Correct 44 ms 5608 KB Output is correct
66 Correct 51 ms 5604 KB Output is correct
67 Correct 43 ms 5724 KB Output is correct
68 Correct 39 ms 5648 KB Output is correct
69 Correct 44 ms 5864 KB Output is correct
70 Correct 472 ms 52588 KB Output is correct
71 Correct 45 ms 5632 KB Output is correct
72 Correct 430 ms 52276 KB Output is correct
73 Correct 401 ms 52260 KB Output is correct
74 Correct 1 ms 204 KB Output is correct
75 Correct 1 ms 204 KB Output is correct
76 Correct 1 ms 204 KB Output is correct
77 Correct 1 ms 204 KB Output is correct
78 Correct 0 ms 312 KB Output is correct
79 Correct 4 ms 960 KB Output is correct
80 Correct 477 ms 52376 KB Output is correct
81 Correct 485 ms 52152 KB Output is correct
82 Correct 448 ms 52244 KB Output is correct
83 Correct 474 ms 52428 KB Output is correct
84 Correct 462 ms 52832 KB Output is correct
85 Correct 436 ms 52768 KB Output is correct
86 Correct 125 ms 18400 KB Output is correct
87 Correct 0 ms 312 KB Output is correct