QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#22740#2365. Flight Collisions8194272#WA 46ms15644kbC++142.2kb2022-03-10 15:51:452022-04-30 01:36:54

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:36:54]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:15644kb
  • [2022-03-10 15:51:45]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<map>
#include<set>

#define int long long
#define double long double
#define fi first
#define se second
#define max Max
#define min Min
#define abs Abs
#define lc (x<<1)
#define rc (x<<1|1)
#define mid ((l+r)>>1)
#define pb(x) push_back(x)
#define lowbit(x) (x&(-x))
#define fan(x) (((x-1)^1)+1)
#define mp(x,y) make_pair(x,y)
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
#define INF 0x3f3f3f3f

using namespace std;

inline int read()
{
	int ans=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){ans=(ans<<1)+(ans<<3)+c-'0';c=getchar();}
	return ans*f;
}

inline void write(int x)
{
	if(x<0) putchar('-'),x=-x;
	if(x/10) write(x/10);
	putchar((char)(x%10)+'0');
}

template<typename T>inline T Abs(T a){return a>0?a:-a;};
template<typename T,typename TT>inline T Min(T a,TT b){return a<b?a:b;}
template<typename T,typename TT> inline T Max(T a,TT b){return a<b?b:a;}

const int N=1e6+5;
int n,del[N];

struct Node
{
	int x,v;
}a[N];

double len(Node p1,Node p2)
{
	if(p1.v==p2.v) return -1;
	return (p2.x-p1.x+0.0)/(p1.v-p2.v);
}

set<pair<int,int> > ps;
priority_queue<pair<double,pair<int,int> > > qu;

inline void delet(int x)
{
	auto it=ps.find(mp(a[x].x,x));del[x]=1;
	if(it==ps.begin()||next(it)==ps.end())
	{
		ps.erase(it);
		return;
	}
	int it1=prev(it)->se,it2=next(it)->se;
	ps.erase(it);
	if(len(a[it1],a[it2])<=0) return;
	qu.push(mp(-len(a[it1],a[it2]),mp(it1,it2)));
}

signed main()
{
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i].x=read();
		a[i].v=read();
	}
	for(int i=1;i<=n;++i)
		ps.insert(mp(a[i].x,i));
	for(int i=1;i<n;++i)
	{
		double tmp=len(a[i],a[i+1]);
		if(tmp<=0) continue;
		qu.push(mp(-tmp,mp(i,i+1)));
	}
	while(!qu.empty())
	{
		auto U=qu.top();qu.pop();
		int p1=U.se.fi,p2=U.se.se;
		if(del[p1]||del[p2])
			continue;
		delet(p1);delet(p2);
	}
	int res=0;
	for(int i=1;i<=n;++i)
		if(!del[i]) res++;
	write(res);puts("");
	for(int i=1;i<=n;++i)
		if(!del[i]) write(i),putchar(' ');
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
-4 13

output:

1
1 

result:

ok 2 lines

Test #2:

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

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: 5628kb

input:

3
-1000000000 1
999999999 0
1000000000 0

output:

1
3 

result:

ok 2 lines

Test #4:

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

input:

2
5 4
10 5

output:

2
1 2 

result:

ok 2 lines

Test #5:

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

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: 5720kb

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: 46ms
memory: 11372kb

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: 43ms
memory: 15644kb

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 '