Submission #99203

# Submission time Handle Problem Language Result Execution time Memory
99203 2019-03-01T16:29:04 Z dsg213 Relay (COI16_relay) C++14
100 / 100
238 ms 9436 KB
#include<bits/stdc++.h>
#define mp make_pair
#define st first
#define nd second
#define ll long long
using namespace std;
struct pkt{
	ll x;
	ll y;
};
ll det(pkt a,pkt b,pkt c){
	return a.x*b.y+b.x*c.y+c.x*a.y-a.x*c.y-b.x*a.y-c.x*b.y;
}
int nalewo(pkt pds1,pkt pds2,pkt spr){
	return det(pds1,pds2,spr)>0;
}
int naprawo(pkt pds1,pkt pds2,pkt spr){
	return det(pds1,pds2,spr)<0;
}
pkt sta[110000];
pkt wys[210000];
int zaz[110000];
int n,m;
pair<int,int> odpal(int x){
	int mxl=0,mxp=0;
	for(int i=0;i<m;i++){
		if(naprawo(sta[x],wys[mxp],wys[i])){
			mxp=i;
		}
	}
	for(int i=0;i<m;i++){
		if(nalewo(sta[x],wys[mxl],wys[i])){
			mxl=i;
		}
	}
	for(int i=0;i<n;i++){
		if(!naprawo(sta[x],wys[mxl],sta[i])){
			zaz[i]=1;
		}
	}
	for(int i=0;i<n;i++){
		if(!nalewo(sta[x],wys[mxp],sta[i])){
			zaz[i]=1;
		}
	}
	for(int i=0;i<n;i++){
		if(naprawo(wys[mxl],wys[mxp],sta[i])){
			zaz[i]=1;
		}
	}
	return mp(mxl,mxp);
}
int main(){
			
	cin >>n;
	for(int i=0;i<n;i++){
		zaz[i]=0;
		cin >>sta[i].x >>sta[i].y;
	}
	cin >>m;
	for(int i=0;i<m;i++){
		cin >>wys[i].x >>wys[i].y;
	}
	for(int i=0;i<m;i++){
		wys[i+m]=wys[i];
	}
	pair<int,int> pr=odpal(0);
	int mxl=pr.st+m,mxp=pr.nd;
	int ktl=-1,ktp=-1;
	/*for(int i=0;i<n;i++){
		cout <<zaz[i] <<" ";
	}
	cout <<"\n";*/
	int z=0;
	for(int i=0;i<n;i++){
		if(!zaz[i]){
			continue;
		}
		z++;
		while(mxl !=0 && naprawo(wys[mxl-1],wys[mxl],sta[i])){
			mxl--;
			ktl=-1;
		}
		if(mxl==0){
			cout <<""<<n;
			return 0;
		}
		if(ktl==-1 || nalewo(sta[ktl],wys[mxl],sta[i])){
			ktl=i;
		}
		while(mxp !=m+m-2 && naprawo(wys[mxp],wys[mxp+1],sta[i])){
			mxp++;
			ktp=-1;
		}
		if(mxp==m+m-2){
			cout <<""<<n;
			return 0;
		}
		if(ktp==-1 || nalewo(sta[i],wys[mxp],sta[ktp])){
			ktp=i;
		}
	}
	//cout <<"\n\n"<<ktl <<" "<<ktp<<"\n";
	//cout <<sta[ktl].x <<" "<<sta[ktl].y <<"	"<<sta[ktp].x <<" "<<sta[ktp].y <<"\n";
	odpal(ktl);
	odpal(ktp);
	int wyn=0;
	for(int i=0;i<n;i++){
		if(zaz[i])wyn++;
	}
	cout <<wyn-1<<"\n";
}















# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 8 ms 640 KB Output is correct
12 Correct 11 ms 640 KB Output is correct
13 Correct 9 ms 512 KB Output is correct
14 Correct 9 ms 512 KB Output is correct
15 Correct 8 ms 512 KB Output is correct
16 Correct 7 ms 512 KB Output is correct
17 Correct 8 ms 512 KB Output is correct
18 Correct 8 ms 512 KB Output is correct
19 Correct 7 ms 512 KB Output is correct
20 Correct 11 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 130 ms 4288 KB Output is correct
12 Correct 103 ms 4344 KB Output is correct
13 Correct 156 ms 4364 KB Output is correct
14 Correct 150 ms 4344 KB Output is correct
15 Correct 111 ms 4336 KB Output is correct
16 Correct 106 ms 4468 KB Output is correct
17 Correct 111 ms 4348 KB Output is correct
18 Correct 150 ms 4316 KB Output is correct
19 Correct 116 ms 4216 KB Output is correct
20 Correct 121 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 256 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 8 ms 640 KB Output is correct
12 Correct 11 ms 640 KB Output is correct
13 Correct 9 ms 512 KB Output is correct
14 Correct 9 ms 512 KB Output is correct
15 Correct 8 ms 512 KB Output is correct
16 Correct 7 ms 512 KB Output is correct
17 Correct 8 ms 512 KB Output is correct
18 Correct 8 ms 512 KB Output is correct
19 Correct 7 ms 512 KB Output is correct
20 Correct 11 ms 512 KB Output is correct
21 Correct 130 ms 4288 KB Output is correct
22 Correct 103 ms 4344 KB Output is correct
23 Correct 156 ms 4364 KB Output is correct
24 Correct 150 ms 4344 KB Output is correct
25 Correct 111 ms 4336 KB Output is correct
26 Correct 106 ms 4468 KB Output is correct
27 Correct 111 ms 4348 KB Output is correct
28 Correct 150 ms 4316 KB Output is correct
29 Correct 116 ms 4216 KB Output is correct
30 Correct 121 ms 4344 KB Output is correct
31 Correct 210 ms 9436 KB Output is correct
32 Correct 238 ms 9336 KB Output is correct
33 Correct 161 ms 6888 KB Output is correct
34 Correct 164 ms 7000 KB Output is correct
35 Correct 192 ms 6848 KB Output is correct
36 Correct 159 ms 6776 KB Output is correct
37 Correct 169 ms 6768 KB Output is correct
38 Correct 161 ms 6852 KB Output is correct
39 Correct 167 ms 6632 KB Output is correct
40 Correct 144 ms 6496 KB Output is correct