QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22837#2365. Flight CollisionDaBenZhongXiaSongKuaiDi#WA 41ms6904kbC++201.0kb2022-03-10 18:04:572022-04-30 01:45:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-30 01:45:39]
  • 评测
  • 测评结果:WA
  • 用时:41ms
  • 内存:6904kb
  • [2022-03-10 18:04:57]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int maxn=(int)1e5+5;
int n,cnt,st,L[maxn],R[maxn],vis[maxn];double x[maxn],v[maxn];
inline double calc(int a,int b){if(x[a]>x[b])swap(a,b);return v[a]>v[b] ? (x[b]-x[a])/(v[a]-v[b]) : -1;}
inline void del(int a){
	if(st==a) st=R[a];
	L[R[a]]=L[a],R[L[a]]=R[a]; L[a]=R[a]=0;
}
struct Node{int x,y;double t;bool operator <(const Node&q)const{return t>q.t;}};
priority_queue<Node> q;
int main(){
	scanf("%d",&n); cnt=n;
	for(int al=1;al<=n;al++) scanf("%lf%lf",&x[al],&v[al]);
	st=1;for(int al=1;al<n;al++)R[al]=al+1;for(int al=2;al<=n;al++)L[al]=al-1;
	for(int al=1;al<n;al++){
		double t=calc(al,al+1);
		if(t>0) q.push((Node){al,al+1,t});
	}
	while(!q.empty()){
		Node h=q.top(); q.pop(); if(vis[h.x] || vis[h.y])continue;
		vis[h.x] = vis[h.y] = 1;
		int pre=L[h.x], nxt=R[h.y]; del(h.x), del(h.y); cnt-=2;
		if(pre && nxt){
			double t=calc(pre,nxt);
			if(t>0) q.push((Node){pre,nxt,t});
		}
	}
	printf("%d\n",cnt);
	for(int al=1;al<=n;al++)if(!vis[al]) printf("%d ",al);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 5840kb

input:

1
-4 13

output:

1
1 

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 2ms
memory: 3776kb

input:

5
1 1000000000
2 1000000000
3 -1000000000
4 -1000000000
5 -1000000000

output:

1
5 

result:

ok 2 lines

Test #3:

score: 0
Accepted
time: 3ms
memory: 3932kb

input:

3
-1000000000 1
999999999 0
1000000000 0

output:

1
3 

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 2ms
memory: 3792kb

input:

2
5 4
10 5

output:

2
1 2 

result:

ok 2 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

9
10 10
20 7
30 5
40 0
42 0
50 -1
60 -2
70 -10
80 -12

output:

1
1 

result:

ok 2 lines

Test #6:

score: 0
Accepted
time: 3ms
memory: 3752kb

input:

5
10 0
20 0
30 1
40 0
50 0

output:

3
1 2 5 

result:

ok 2 lines

Test #7:

score: 0
Accepted
time: 35ms
memory: 6072kb

input:

98765
0 -48539
1 -48539
2 -48539
3 -48539
4 -48539
5 -48539
6 -48539
7 -48539
8 -48539
9 -48539
10 -48539
11 -48539
12 -48539
13 -48539
14 -48539
15 -48539
16 -48539
17 -48539
18 -48539
19 -48539
20 -48539
21 -48539
22 -48539
23 -48539
24 -48539
25 -48539
26 -48539
27 -48539
28 -48539
29 -48539
30 -...

output:

98765
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 2 lines

Test #8:

score: -100
Wrong Answer
time: 41ms
memory: 6904kb

input:

99999
-999999396 999999395
-999971669 999999396
-999971668 -999999396
-999961260 999999396
-999961259 -999999396
-999907239 999999396
-999907238 -999999396
-999754561 999999396
-999754560 -999999396
-999662011 999999396
-999662010 -999999396
-999651505 999999396
-999651504 -999999396
-999619141 9999...

output:

1
1 

result:

wrong answer 2nd lines differ - expected: '99999', found: '1 '