Submission #1149745

#TimeUsernameProblemLanguageResultExecution timeMemory
1149745Zero_OPRelay (COI16_relay)C++20
18 / 100
2095 ms5844 KiB
#include <bits/stdc++.h> using namespace std; #define FOR(i, l, r) for(int i = (l); i < (r); ++i) #define ROF(i, l, r) for(int i = (l) - 1; i >= (r); --i) #define mp make_pair #define mt make_tuple #define ff first #define ss second #define all(v) begin(v), end(v) #define rall(v) rbegin(v), rend(v) #define sz(v) (int)v.size() #define sum_of(v) accumulate(all(v), 0ll) #define pb push_back #define eb emplace_back #define compact(v) v.erase(unique(all(v)), end(v)) #define dbg(x) "[" #x " = " << (x) << "]" #define file(task) if(fopen(task".inp", "r")){ \ freopen(task".inp", "r", stdin); \ freopen(task".out", "w", stdout); } template<typename T> bool minimize(T& a, const T& b){ if(a > b) return a = b, true; return false; } template<typename T> bool maximize(T& a, const T& b){ if(a < b) return a = b, true; return false; } using ll = long long; using db = double; using ld = double; using ull = unsigned long long; using pi = pair<int, int>; using pl = pair<ll, ll>; using pd = pair<db, db>; using vi = vector<int>; using vb = vector<bool>; using vd = vector<db>; using vpi = vector<pi>; using vpl = vector<pl>; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); struct point{ ll x, y; point() : x(0), y(0) {} point(ll x, ll y) : x(x), y(y){ } point& operator += (const point& o){ x += o.x; y += o.y; return *this; } point& operator -= (const point& o){ x -= o.x; y -= o.y; return *this; } point& operator *= (const ll& o){ x *= o; y *= o; return *this; } point& operator /= (const ll& o){ x /= o; y /= o; return *this; } friend point operator + (point a, const point& b){ return a += b; } friend point operator - (point a, const point& b){ return a -= b; } friend point operator * (point a, const ll& b){ return a *= b; } friend point operator / (point a, const ll& b){ return a /= b; } friend bool operator == (const point& a, const point& b){ return a.x == b.x && a.y == b.y; } friend bool operator != (const point& a, const point& b){ return a.x != b.x || a.y != b.y; } friend istream& operator >> (istream& in, point& o){ return in >> o.x >> o.y; } friend ostream& operator << (ostream& out, const point& o){ return out << '(' << o.x << ',' << o.y << ')'; } }; ll cross(const point& a, const point& b){ return a.x * b.y - a.y * b.x; } ll cross3(const point& a, point b, point c){ return cross(b - a, c - a); } ll dot(const point& a, const point& b){ return a.x * b.x + a.y * b.y; } ll dot3(const point& a, point b, point c){ return dot(b - a, c - a); } int sign(ll x){ if(x < 0) return -1; if(x > 0) return +1; return 0; } bool point_on_segment(const point& a, const point& b, const point& c){ //C on AB return cross3(a, b, c) == 0 && dot3(c, a, b) <= 0; } bool intersect_two_segments(const point& a, const point& b, const point& c, const point& d, bool strictly){ if(!strictly) if(point_on_segment(a, b, c) || point_on_segment(a, b, d) || point_on_segment(c, d, a) || point_on_segment(c, d, b)) return true; return sign(cross3(a, b, c)) * sign(cross3(a, b, d)) < 0 && sign(cross3(c, d, a)) * sign(cross3(c, d, b)) < 0; } void testcase(int num_testcase){ int N; cin >> N; vector<point> pts(N); FOR(i, 0, N) cin >> pts[i]; int M; cin >> M; vector<point> polygons(N); FOR(i, 0, M) cin >> polygons[i]; vi vis; FOR(i, 1, N){ vis.pb(i); FOR(j, 0, M){ if(intersect_two_segments(polygons[j], polygons[(j + 1) % M], pts[0], pts[i], true)){ vis.pop_back(); break; } } } vi vis2; for(auto u : vis){ FOR(i, 1, N) if(u != i){ vis2.pb(i); FOR(j, 0, M){ if(intersect_two_segments(polygons[j], polygons[(j + 1) % M], pts[u], pts[i], true)){ vis2.pop_back(); break; } } } } vis.insert(vis.end(), all(vis2)); sort(all(vis)); compact(vis); cout << sz(vis) << '\n'; //exclude pts[0] } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); file("task"); int T = 1; //cin >> T; FOR(i, 0, T) testcase(i); return 0; }

Compilation message (stderr)

relay.cpp: In function 'int main()':
relay.cpp:23:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |                         freopen(task".inp", "r", stdin); \
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
relay.cpp:167:5: note: in expansion of macro 'file'
  167 |     file("task");
      |     ^~~~
relay.cpp:24:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |                         freopen(task".out", "w", stdout); }
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
relay.cpp:167:5: note: in expansion of macro 'file'
  167 |     file("task");
      |     ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...