Submission #66310

# Submission time Handle Problem Language Result Execution time Memory
66310 2018-08-10T07:58:08 Z 정원준(#1889) 초음속철도 (OJUZ11_rail) C++11
100 / 100
825 ms 13812 KB
#include <bits/stdc++.h>
#define L long long
#define mod 1000000007


using namespace std;

L ln,n,ans;

struct S{
	L s,e;
}a[200020];

bool operator<(S a,S b){
	return a.e<b.e;
}

L dp[200020];
L tr[800080],sum[800080];

void init(L now,L S,L E){
	tr[now]=1;
	if(S==E)
	{
		sum[now]=1;
		return;
	}
	L mid=(S+E)/2;
	init(now*2,S,mid);
	init(now*2+1,mid+1,E);
	sum[now]=(sum[now*2]+sum[now*2+1])%mod;
}

void givelazy(L now,L S,L E){
	sum[now]*=tr[now];
	sum[now]%=mod;
	if(S==E)
	{
		tr[now]=1;
		return;
	}
	tr[now*2]*=tr[now];
	tr[now*2]%=mod;
	tr[now*2+1]*=tr[now];
	tr[now*2+1]%=mod;
	tr[now]=1;
}

void update(L now,L S,L E,L s,L e,L val){
	//printf("%lld %lld %lld %lld %lld %lld\n",now,S,E,s,e,val);
	givelazy(now,S,E);
	if(S>e||E<s) return;
	if(s<=S&&E<=e)
	{
		tr[now]*=val;
		tr[now]%=mod;
		givelazy(now,S,E);
		return;
	}
	L mid=(S+E)/2;
	update(now*2,S,mid,s,e,val);
	update(now*2+1,mid+1,E,s,e,val);
	sum[now]=(sum[now*2]+sum[now*2+1])%mod;
}

void updpos(L now,L S,L E,L loc,L val){
	givelazy(now,S,E);
	if(S>loc||E<loc) return;
	if(S==E)
	{
		sum[now]+=val;
		sum[now]%=mod;
		return;
	}
	L mid=(S+E)/2;
	updpos(now*2,S,mid,loc,val);
	updpos(now*2+1,mid+1,E,loc,val);
	sum[now]=(sum[now*2]+sum[now*2+1])%mod;
	
}

L getsum(L now,L S,L E,L s,L e){
	givelazy(now,S,E);
	if(S>e||E<s) return 0;
	if(s<=S&&E<=e)
	{
		return sum[now];
	}
	L mid=(S+E)/2;
	return (getsum(now*2,S,mid,s,e)+getsum(now*2+1,mid+1,E,s,e))%mod;
}

int main()
{
	scanf("%lld %lld",&ln,&n);
	L i;
	init(1,1,n+1);
	for(i=1;i<=n;i++)
	{
		scanf("%lld %lld",&a[i].s,&a[i].e);
	}
	sort(a+1,a+n+1);
	a[0].s=a[0].e=1;
	for(i=1;i<=n;i++)
	{
		L S=0,E=i;//Ŀ���DZ� �����ϴ� ��
		while(S<E)
		{
			L mid=(S+E)/2;
			if(a[mid].e>=a[i].s) E=mid;
			else S=mid+1; 
		}
		/*if(a[i].s==1)
		{
			dp[i][1]=ds[i-1][0]+ds[i-1][1];
			dp[i][0]=0;
		}
		else
		{
			dp[i][1]=ds[i-1][1]-ds[S-1][1];
			dp[i][0]=ds[i-1][0]-ds[S-1][0]+1;
		}*/
		dp[i]=getsum(1,1,n+1,S+1,i);
		updpos(1,1,n+1,i+1,dp[i]-getsum(1,1,n+1,i+1,i+1));
		if(a[i].s!=1) update(1,1,n+1,1,S,2);
		//printf("%lld ",dp[i]);
	}
	/*
	puts("");
	for(i=1;i<=n*4;i++)
	{
		printf("%lld ",tr[i]);
	}
	puts("");
	for(i=1;i<=n*4;i++)
	{
		printf("%lld ",sum[i]);
	}*/
	
	for(i=1;i<=n;i++)
	{
		if(a[i].e==ln)
		{
			ans=(ans+dp[i])%mod;
		}
	}
	printf("%lld",ans);
}

Compilation message

rail.cpp: In function 'int main()':
rail.cpp:95:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld %lld",&ln,&n);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
rail.cpp:100:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld %lld",&a[i].s,&a[i].e);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 3 ms 548 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 2 ms 596 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 3 ms 548 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 2 ms 596 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 3 ms 596 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 3 ms 596 KB Output is correct
23 Correct 2 ms 596 KB Output is correct
24 Correct 2 ms 596 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
27 Correct 2 ms 620 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 3 ms 620 KB Output is correct
30 Correct 2 ms 620 KB Output is correct
31 Correct 2 ms 620 KB Output is correct
32 Correct 2 ms 748 KB Output is correct
33 Correct 3 ms 748 KB Output is correct
34 Correct 2 ms 748 KB Output is correct
35 Correct 3 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 748 KB Output is correct
2 Correct 2 ms 748 KB Output is correct
3 Correct 2 ms 748 KB Output is correct
4 Correct 12 ms 1016 KB Output is correct
5 Correct 656 ms 13600 KB Output is correct
6 Correct 567 ms 13600 KB Output is correct
7 Correct 584 ms 13600 KB Output is correct
8 Correct 3 ms 13600 KB Output is correct
9 Correct 543 ms 13600 KB Output is correct
10 Correct 518 ms 13600 KB Output is correct
11 Correct 285 ms 13600 KB Output is correct
12 Correct 569 ms 13600 KB Output is correct
13 Correct 611 ms 13600 KB Output is correct
14 Correct 502 ms 13600 KB Output is correct
15 Correct 578 ms 13600 KB Output is correct
16 Correct 485 ms 13600 KB Output is correct
17 Correct 556 ms 13628 KB Output is correct
18 Correct 528 ms 13628 KB Output is correct
19 Correct 547 ms 13628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 3 ms 548 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 2 ms 596 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 3 ms 596 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 3 ms 596 KB Output is correct
23 Correct 2 ms 596 KB Output is correct
24 Correct 2 ms 596 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
27 Correct 2 ms 620 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 3 ms 620 KB Output is correct
30 Correct 2 ms 620 KB Output is correct
31 Correct 2 ms 620 KB Output is correct
32 Correct 2 ms 748 KB Output is correct
33 Correct 3 ms 748 KB Output is correct
34 Correct 2 ms 748 KB Output is correct
35 Correct 3 ms 748 KB Output is correct
36 Correct 18 ms 13628 KB Output is correct
37 Correct 11 ms 13628 KB Output is correct
38 Correct 11 ms 13628 KB Output is correct
39 Correct 11 ms 13628 KB Output is correct
40 Correct 12 ms 13628 KB Output is correct
41 Correct 14 ms 13628 KB Output is correct
42 Correct 20 ms 13628 KB Output is correct
43 Correct 2 ms 13628 KB Output is correct
44 Correct 13 ms 13628 KB Output is correct
45 Correct 9 ms 13628 KB Output is correct
46 Correct 13 ms 13628 KB Output is correct
47 Correct 14 ms 13628 KB Output is correct
48 Correct 16 ms 13628 KB Output is correct
49 Correct 12 ms 13628 KB Output is correct
50 Correct 18 ms 13628 KB Output is correct
51 Correct 16 ms 13628 KB Output is correct
52 Correct 5 ms 13628 KB Output is correct
53 Correct 15 ms 13628 KB Output is correct
54 Correct 11 ms 13628 KB Output is correct
55 Correct 17 ms 13628 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 432 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 3 ms 484 KB Output is correct
7 Correct 2 ms 484 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 3 ms 548 KB Output is correct
10 Correct 2 ms 592 KB Output is correct
11 Correct 2 ms 592 KB Output is correct
12 Correct 2 ms 592 KB Output is correct
13 Correct 3 ms 592 KB Output is correct
14 Correct 2 ms 596 KB Output is correct
15 Correct 2 ms 596 KB Output is correct
16 Correct 2 ms 596 KB Output is correct
17 Correct 3 ms 596 KB Output is correct
18 Correct 4 ms 596 KB Output is correct
19 Correct 3 ms 596 KB Output is correct
20 Correct 3 ms 596 KB Output is correct
21 Correct 2 ms 596 KB Output is correct
22 Correct 3 ms 596 KB Output is correct
23 Correct 2 ms 596 KB Output is correct
24 Correct 2 ms 596 KB Output is correct
25 Correct 2 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
27 Correct 2 ms 620 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 3 ms 620 KB Output is correct
30 Correct 2 ms 620 KB Output is correct
31 Correct 2 ms 620 KB Output is correct
32 Correct 2 ms 748 KB Output is correct
33 Correct 3 ms 748 KB Output is correct
34 Correct 2 ms 748 KB Output is correct
35 Correct 3 ms 748 KB Output is correct
36 Correct 3 ms 748 KB Output is correct
37 Correct 2 ms 748 KB Output is correct
38 Correct 2 ms 748 KB Output is correct
39 Correct 12 ms 1016 KB Output is correct
40 Correct 656 ms 13600 KB Output is correct
41 Correct 567 ms 13600 KB Output is correct
42 Correct 584 ms 13600 KB Output is correct
43 Correct 3 ms 13600 KB Output is correct
44 Correct 543 ms 13600 KB Output is correct
45 Correct 518 ms 13600 KB Output is correct
46 Correct 285 ms 13600 KB Output is correct
47 Correct 569 ms 13600 KB Output is correct
48 Correct 611 ms 13600 KB Output is correct
49 Correct 502 ms 13600 KB Output is correct
50 Correct 578 ms 13600 KB Output is correct
51 Correct 485 ms 13600 KB Output is correct
52 Correct 556 ms 13628 KB Output is correct
53 Correct 528 ms 13628 KB Output is correct
54 Correct 547 ms 13628 KB Output is correct
55 Correct 18 ms 13628 KB Output is correct
56 Correct 11 ms 13628 KB Output is correct
57 Correct 11 ms 13628 KB Output is correct
58 Correct 11 ms 13628 KB Output is correct
59 Correct 12 ms 13628 KB Output is correct
60 Correct 14 ms 13628 KB Output is correct
61 Correct 20 ms 13628 KB Output is correct
62 Correct 2 ms 13628 KB Output is correct
63 Correct 13 ms 13628 KB Output is correct
64 Correct 9 ms 13628 KB Output is correct
65 Correct 13 ms 13628 KB Output is correct
66 Correct 14 ms 13628 KB Output is correct
67 Correct 16 ms 13628 KB Output is correct
68 Correct 12 ms 13628 KB Output is correct
69 Correct 18 ms 13628 KB Output is correct
70 Correct 16 ms 13628 KB Output is correct
71 Correct 5 ms 13628 KB Output is correct
72 Correct 15 ms 13628 KB Output is correct
73 Correct 11 ms 13628 KB Output is correct
74 Correct 17 ms 13628 KB Output is correct
75 Correct 796 ms 13628 KB Output is correct
76 Correct 481 ms 13628 KB Output is correct
77 Correct 722 ms 13628 KB Output is correct
78 Correct 491 ms 13628 KB Output is correct
79 Correct 759 ms 13668 KB Output is correct
80 Correct 755 ms 13668 KB Output is correct
81 Correct 14 ms 13668 KB Output is correct
82 Correct 767 ms 13668 KB Output is correct
83 Correct 363 ms 13668 KB Output is correct
84 Correct 772 ms 13668 KB Output is correct
85 Correct 724 ms 13668 KB Output is correct
86 Correct 740 ms 13668 KB Output is correct
87 Correct 614 ms 13668 KB Output is correct
88 Correct 606 ms 13668 KB Output is correct
89 Correct 823 ms 13812 KB Output is correct
90 Correct 780 ms 13812 KB Output is correct
91 Correct 760 ms 13812 KB Output is correct
92 Correct 703 ms 13812 KB Output is correct
93 Correct 708 ms 13812 KB Output is correct
94 Correct 825 ms 13812 KB Output is correct
95 Correct 793 ms 13812 KB Output is correct