Submission #229263

# Submission time Handle Problem Language Result Execution time Memory
229263 2020-05-04T01:51:18 Z super_j6 The Forest of Fangorn (CEOI14_fangorn) C++14
0 / 100
3000 ms 65536 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<ll, ll>
#define f first
#define s second

const int maxn = 10000;
int n, m, w, h;
pi s;
pi a[maxn], b[maxn];
int ans[maxn];

bool cp(pi x, pi y){
    return x.f * y.s < x.s * y.f;
}

pi af(pi x, pi y){
    pi p = {x.f - y.f, x.s - y.s};
    return {(2 * (p.s > 0) - 1) * (abs(p.f) - p.f + abs(p.s)), abs(p.f) + abs(p.s)};
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> w >> h >> s.f >> s.s >> m;
	
	for(int i = 0; i < m; i++){
	    cin >> b[i].f >> b[i].s;
	    ans[i] = 1;
	}
	
	cin >> n;
	
	for(int i = 0; i < n; i++) cin >> a[i].f >> a[i].s;
	
	int ret = m;
	for(int i = 0; i < n; i++){
	    pi p = af(s, a[i]), pa = {3, 1}, pb = {-3, 1}, pc = {3, 1}, pd = {-3, 1}, px;
	    for(int j = 0; j < n; j++){
	        if(i == j) continue;
	        px = af(a[i], a[j]);
	        if(cp(p, px) && cp(px, pa)) pa = px;
	        if(cp(px, p) && cp(pb, px)) pb = px;
	        if(cp(px, pc)) pc = px;
	        if(cp(pd, px)) pd = px;
	    }
	    for(int j = 0; j < m; j++){
	        px = af(b[j], a[i]);
	        ret -= (ans[j] - (ans[j] &= pa.f == 3 ? cp(pb, px) || cp(px, pc) :
	                                    pb.f == -3 ? cp(pd, px) || cp(px, pa) :
	                                    cp(pb, px) && cp(px, pa)));
	    }
	}
	
	cout << ret << endl;
	for(int i = 0; i < m; i++){
	    if(ans[i]) cout << i + 1;
	    if(--ret) cout << " ";
	}
	cout << endl;
	
	if(ret) while(1) cout << ret << endl;

	return 0;
}

Compilation message

fangorn.cpp: In function 'int main()':
fangorn.cpp:54:35: warning: operation on 'ans[j]' may be undefined [-Wsequence-point]
          ret -= (ans[j] - (ans[j] &= pa.f == 3 ? cp(pb, px) || cp(px, pc) :
                           ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                      pb.f == -3 ? cp(pd, px) || cp(px, pa) :
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                      cp(pb, px) && cp(px, pa)));
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 3066 ms 65536 KB Time limit exceeded
2 Correct 4 ms 384 KB Output is correct
3 Execution timed out 3069 ms 65536 KB Time limit exceeded
4 Execution timed out 3064 ms 65536 KB Time limit exceeded
5 Execution timed out 3077 ms 65536 KB Time limit exceeded
6 Execution timed out 3076 ms 65536 KB Time limit exceeded
7 Execution timed out 3085 ms 65536 KB Time limit exceeded
8 Execution timed out 3070 ms 65536 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 3069 ms 65536 KB Time limit exceeded
2 Execution timed out 3069 ms 65536 KB Time limit exceeded
3 Execution timed out 3073 ms 65536 KB Time limit exceeded
4 Execution timed out 3071 ms 65536 KB Time limit exceeded
5 Execution timed out 3072 ms 65536 KB Time limit exceeded
6 Execution timed out 3027 ms 65536 KB Time limit exceeded
7 Execution timed out 3082 ms 65536 KB Time limit exceeded
8 Correct 5 ms 384 KB Output is correct
9 Execution timed out 3065 ms 65536 KB Time limit exceeded
10 Execution timed out 3079 ms 65536 KB Time limit exceeded
11 Correct 5 ms 384 KB Output is correct
12 Execution timed out 3073 ms 65536 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 3062 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3064 ms 65536 KB Time limit exceeded
2 Halted 0 ms 0 KB -