Submission #114497

# Submission time Handle Problem Language Result Execution time Memory
114497 2019-06-01T13:15:40 Z 김세빈(#2861) The Forest of Fangorn (CEOI14_fangorn) C++14
50 / 100
3000 ms 568 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

pll P[2020], C[10101];
ll D[2020];
ll w, h, n, m, ans, f;
pll g;

ll ccw(pll pa, pll pb, pll pc)
{
	ll ret = (pa.first * pb.second + pb.first * pc.second + pc.first * pa.second) -
		(pb.first * pa.second + pc.first * pb.second + pa.first * pc.second);
	
	if(ret == 0){
		if(f == 1) return 1 / 0;
		else if(f == 2) for(; ; );
	}
	
	return ret;
}

bool inside(pll pa, pll pb, pll pc, pll pd)
{
	if(ccw(pa, pb, pc) >= 0){
		if(ccw(pa, pb, pd) > 0 && ccw(pa, pd, pc) > 0) return 1;
		else return 0;
	}
	else{
		if(ccw(pa, pb, pd) > 0 || ccw(pa, pd, pc) > 0) return 1;
		else return 0;
	}
}

int main()
{
	ll i, j, l, r;
	
	scanf("%lld%lld%lld%lld", &w, &h, &g.first, &g.second);
	
	scanf("%lld", &m);
	
	for(i=1; i<=m; i++){
		scanf("%lld%lld", &C[i].first, &C[i].second);
	}
	
	scanf("%lld", &n);
	
	for(i=1; i<=n; i++){
		scanf("%lld%lld", &P[i].first, &P[i].second);
	}
	
	for(i=1; i<=n; i++){
		l = r = -1;
		for(j=1; j<=n; j++) if(i != j){
			f = 1;
			P[j] = pll(2 * P[i].first - P[j].first, 2 * P[i].second - P[j].second);
			
			if(l == -1) l = j;
			else if(inside(P[i], P[l], g, P[j])) l = j;
			
			if(r == -1) r = j;
			else if(inside(P[i], g, P[r], P[j])) r = j;
		}
		
		for(j=1; j<=m; j++){
			f = 2;
			if(!inside(P[i], P[l], P[r], C[j])){
				D[j] = 1;
			}
		}
		
		for(j=1; j<=n; j++){
			P[j] = pll(2 * P[i].first - P[j].first, 2 * P[i].second - P[j].second);
		}
	}
	
	for(i=1; i<=m; i++){
		ans += 1 - D[i];
	}
	
	printf("%lld\n", ans);
	
	for(i=1; i<=m; i++){
		if(!D[i]) printf("%lld ", i);
	}
	
	printf("\n");
	
	return 0;
}

Compilation message

fangorn.cpp: In function 'll ccw(pll, pll, pll)':
fangorn.cpp:19:23: warning: division by zero [-Wdiv-by-zero]
   if(f == 1) return 1 / 0;
                     ~~^~~
fangorn.cpp: In function 'int main()':
fangorn.cpp:42:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld%lld", &w, &h, &g.first, &g.second);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fangorn.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &m);
  ~~~~~^~~~~~~~~~~~
fangorn.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &C[i].first, &C[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fangorn.cpp:50:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
fangorn.cpp:53:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld", &P[i].first, &P[i].second);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 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 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 3 ms 256 KB Output is correct
11 Correct 3 ms 256 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 3020 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 111 ms 504 KB Output is correct
2 Incorrect 217 ms 568 KB Output isn't correct
3 Halted 0 ms 0 KB -