QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#185647#3101. Event Hopping 2Pure_Furies#0 377ms45988kbC++141.6kb2023-09-22 13:55:262024-07-04 02:07:02

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 02:07:02]
  • 评测
  • 测评结果:0
  • 用时:377ms
  • 内存:45988kb
  • [2023-09-22 13:55:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n,k,l[100003],r[100003],pre[17][100003],nxt[17][100003];
int calc(int i,int L,int R){
	int t=i,ret=1;
	for(int j=16;~j;j--)
		if(L<=l[pre[j][t]])
			t=pre[j][t],ret+=1<<j;
	t=i;
	for(int j=16;~j;j--)
		if(r[nxt[j][t]]<=R)
			t=nxt[j][t],ret+=1<<j;
	return ret;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	map<int,vector<int> >mp;
	map<pair<int,int>,int>Mp;
	for(int i=0;i<n;i++){
		cin>>l[i]>>r[i];
		Mp[{l[i],r[i]}]=i;
		mp[l[i]].push_back(i);
		mp[r[i]].push_back(i+n);
	}l[n]=0;r[n]=1;
	l[n+1]=1e9;
	r[n+1]=l[n+1]+1;
	pre[0][n]=n;
	nxt[0][n+1]=n+1;
	int t=n;
	for(auto it:mp){
		for(auto i:it.second)
			if(i>=n&&l[i-n]>l[t])
				t=i-n;
		for(auto i:it.second)
			if(i<n)
				pre[0][i]=t;
	}pre[0][n+1]=t; 
	mp.clear();
	for(int i=0;i<n;i++)
		mp[-r[i]].push_back(i),
		mp[-l[i]].push_back(i+n);
	t=n+1;
	for(auto it:mp){
		for(auto i:it.second)
			if(i>=n&&r[i-n]<r[t])
				t=i-n;
		for(auto i:it.second)
			if(i<n)
				nxt[0][i]=t;
	}nxt[0][n]=t;
	set<pair<int,int> >st={{l[n],r[n]},{l[n+1],r[n+1]}};
	for(int i=1;i<17;i++)
		for(int j=0;j<n+2;j++)
			pre[i][j]=pre[i-1][pre[i-1][j]],
			nxt[i][j]=nxt[i-1][nxt[i-1][j]];
	int nw=calc(nxt[0][n],r[n],l[n+1]);
	if(nw<k){cout<<-1;return 0;}
	int ttklwxx=k;
	for(int i=0;i<n&&ttklwxx;i++){
		auto it=st.lower_bound({r[i],-1});it--;
		int L=(*it).second,R,ii=Mp[*it];
		if(L>l[i])continue;
		it++;R=(*it).first;
		if(R<r[i])continue;
		int tmp=nw-calc(nxt[0][ii],L,R)+calc(i,L,R);
		if(tmp>=k)
			nw=tmp,cout<<i+1<<'\n',ttklwxx--,st.insert({l[i],r[i]});
	}
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 16164kb

input:

1 1
1 3

output:


result:

wrong answer 1st lines differ - expected: '1', found: ''

Subtask #2:

score: 0
Wrong Answer

Test #47:

score: 0
Wrong Answer
time: 0ms
memory: 15908kb

input:

1 1
134842099 137944073

output:


result:

wrong answer 1st lines differ - expected: '1', found: ''

Subtask #3:

score: 0
Wrong Answer

Test #74:

score: 0
Wrong Answer
time: 7ms
memory: 16780kb

input:

3000 57
226083340 261990234
392684356 462929590
468018811 841719892
495096853 606046097
196983814 256423598
331199122 967656486
802593662 931108452
74501453 679054962
294344294 752837262
295708332 547261648
265421699 652708933
272959087 727136240
165667761 846917534
61770748 157663302
608516043 8492...

output:

50
85
104
139
173
189
257
273
297
347
374
411
543
600
665
686
750
850
971
977
990
1040
1069
1074
1109
1183
1226
1231
1316
1440
1508
1597
1611
1670
1676
1774
1811
1822
1885
1968
2005
2103
2153
2271
2304
2416
2562
2593
2608
2690
2798
2873
2884

result:

wrong answer 10th lines differ - expected: '327', found: '347'

Subtask #4:

score: 0
Wrong Answer

Test #111:

score: 0
Wrong Answer
time: 377ms
memory: 45988kb

input:

100000 361
136798318 785362988
255943758 535488232
175203444 266819907
766993466 893575347
67274251 589651108
662289594 883406317
830803801 849703610
729398668 798198453
202605534 677648797
66407931 925909114
174421361 601553812
522629146 701284080
136544340 295925673
299796891 499869765
736583725 8...

output:

42
102
185
660
950
3924
4471
4619
4677
5229
5430
6013
6316
6365
6575
7327
7833
9212
10114
10190
10260
10265
10321
10533
11184
11597
12001
12303
12483
12546
12771
14110
14379
14581
15421
15803
15963
16335
16475
17115
17138
17364
17536
17722
18203
18225
18557
18562
19484
19710
20935
21126
21166
21658
...

result:

wrong answer 4th lines differ - expected: '215', found: '660'