Submission #110573

#TimeUsernameProblemLanguageResultExecution timeMemory
110573MAMBAThe Forest of Fangorn (CEOI14_fangorn)C++17
100 / 100
2681 ms832 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i , j , k) for (int i = j; i < k; i++) #define pb push_back #define mt make_tuple #define for_all(x) x.begin(),x.end() typedef long long ll; typedef pair<int , int> pii; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef long double ld; typedef complex<ld> point; inline void fileIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } template<class T , class S> inline bool smin(T &a, S b) { return (T)b < a ? a = b , 1 : 0; } template<class T , class S> inline bool smax(T &a, S b) { return a < (T)b ? a = b , 1 : 0; } constexpr int N = 1e4 + 10; constexpr int MOD = 1e9 + 7; template<typename T> inline T mod(T &v) { return v = (v % MOD + MOD) % MOD; } template<typename S, typename T> inline S add(S &l, T r) { return mod(l += r); } ll po(ll v, ll u) { return u ? po(v * v % MOD , u >> 1) * (u & 1 ? v : 1) % MOD : 1; } int n , c; ld junk, x , y; point a[N], b[N], s, p[N]; bitset<N> res; const ld PI = atan2(0 , -1); inline ld arg2(point p2) { ld me = arg(p2); if (me < 0) me += 2 * PI; return me; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifndef LOCAL // fileIO("forbidden1"); #endif cin >> junk >> junk >> x >> y >> c; s = point(x , y); rep(i , 0 , c) { cin >>x >> y; a[i] = point(x , y); } cin >> n; rep(i , 0 , n) { cin >> x >> y; b[i]= point(x , y); } res.set(); rep(i , 0 , n) { rep(j , 0 , n) p[j] = b[i] - b[j]; point local = s - b[i]; rep(j , 0 , n) p[j] /= local; ld lval = 2 * PI, rval = 0; rep(j , 0 , n) if (j != i) { // cout << i << ' ' << j << ' '<< arg2(p[j]) / PI << endl; smin(lval , arg2(p[j])); smax(rval , arg2(p[j])); } rep(j , 0 , c) { ld me = arg2((a[j] - b[i]) / local); if (me > lval && me < rval) { // cout << i << ' '<< j << " :: " << endl; res[j] = false; } } } vi vec; rep(i , 0 , c) if (res[i]) vec.pb(i); cout << vec.size() << endl; for (auto e :vec) cout << e + 1 << ' '; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...