AtCoder Grand Contest 015

Submission #8395925

Source codeソースコード

#include <bits/stdc++.h>
#define rg register
#define LL long long 

using namespace std;

const int N=200010;
const int P=1e9+7;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int n;
struct node{
	int x,y;
	bool operator < (const node &rhs)const{
		return y==rhs.y?x<rhs.x:y<rhs.y;
	}
}b[N],a[N];
int mx[N][21],mn[N][21],sm=1;
void ST(){
	for(rg int i=1;i<=n;i++)
		mx[i][0]=mn[i][0]=b[i].x;
	int t=log2(n)+1;
	for(rg int j=1;j<t;j++)
		for(rg int i=1;i+(1<<j)-1<=n;i++){
			mx[i][j]=max(mx[i][j-1],mx[i+(1<<(j-1))][j-1]);
			mn[i][j]=min(mn[i][j-1],mn[i+(1<<(j-1))][j-1]);
		}
}
int getmax(int l,int r){
	int t=log2(r-l+1);
	return max(mx[l][t],mx[r-(1<<t)+1][t]);
}
int getmin(int l,int r){
	int t=log2(r-l+1);
	return min(mn[l][t],mn[r-(1<<t)+1][t]);
}
struct Binary_Index_Tree{
	int c[N];
	int lowbit(int x){
		return x&(-x);
	}
	void update(int x,int d){
		while(x<=n){
			c[x]=(c[x]+d+P)%P;
			x+=lowbit(x);	
		}
	}
	int query(int x){
		int rtn=x>=0;
		while(x>0){
			rtn=(rtn+c[x]+P)%P;
			x-=lowbit(x);
		}
		return rtn;
	}
}T;
int main()
{
	n=read();
	for(rg int i=1;i<=n;i++)
		b[i].x=read(),b[i].y=read();	
	sort(b+1,b+1+n);
	ST();
	for(rg int i=1;i<=n;i++){
		a[i].x=a[i].y=i;
		int l=1,r=i-1;
		while(l<=r){
			int mid=(l+r)>>1;
			if(getmax(1,mid)>b[i].x)a[i].x=mid,r=mid-1;
			else l=mid+1;
		}
		l=i+1,r=n;
		while(l<=r){
			int mid=(l+r)>>1;
			if(getmin(mid,r)<b[i].x)a[i].y=mid,l=mid+1;
			else r=mid-1;
		}
	}
	sort(a+1,a+1+n);
	for(rg int i=1;i<=n;i++){
		int L=a[i].x,R=a[i].y;
		int nf=(sm-T.query(L-2)+P)%P;
		sm=(sm+nf)%P;
		T.update(R,nf);
	}
	printf("%d\n",(sm-T.query(n-1)+P)%P);
	return 0;
}

Submission

Task問題 E - Mr.Aoki Incubator
User nameユーザ名 luogu_bot2
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 WA
Score得点 0
Source lengthソースコード長 1740 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
Sample - s1.txt,s2.txt
All 0 / 1200 01.txt,02.txt,03.txt,04.txt,05.txt,06.txt,07.txt,08.txt,09.txt,10.txt,11.txt,12.txt,13.txt,14.txt,15.txt,16.txt,17.txt,18.txt,19.txt,20.txt,21.txt,22.txt,23.txt,24.txt,25.txt,26.txt,27.txt,28.txt,29.txt,30.txt,31.txt,32.txt,33.txt,34.txt,s1.txt,s2.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01.txt WA
02.txt WA
03.txt WA
04.txt WA
05.txt WA
06.txt WA
07.txt WA
08.txt WA
09.txt AC 303 ms 36992 KB
10.txt AC 263 ms 36224 KB
11.txt WA
12.txt WA
13.txt WA
14.txt WA
15.txt WA
16.txt WA
17.txt WA
18.txt WA
19.txt WA
20.txt WA
21.txt WA
22.txt WA
23.txt WA
24.txt WA
25.txt WA
26.txt WA
27.txt WA
28.txt WA
29.txt WA
30.txt WA
31.txt AC 2 ms 4352 KB
32.txt AC 2 ms 4352 KB
33.txt AC 2 ms 4352 KB
34.txt AC 2 ms 4352 KB
s1.txt AC 2 ms 4352 KB
s2.txt AC 2 ms 4352 KB