Submission #532183

#TimeUsernameProblemLanguageResultExecution timeMemory
532183Killer2501Kućice (COCI21_kucice)C++14
110 / 110
129 ms9804 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pll pair<ll, ll> #define pii pair<ll, int> #define fi first #define se second using namespace std; const int N = 2e5+2; const int M = 52; const int mod = 1e9+7; const ll base = 75; const ll inf = 1e16; int n, lab[N], t, c[N], h[N], m, a[N], b[N], k; ll ans, d[N]; vector<int> adj[N], g[N]; vector<pll> vi; string s; bool vis[N]; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n&1)total = total * k % mod; k = k * k % mod; } return total; } void add(int& x, int y) { x += y; if(x >= mod)x -= mod; } int findp(int u) { return lab[u] < 0 ? u : lab[u] = findp(lab[u]); } void hop(int u, int v) { u = findp(u); v = findp(v); if(u == v)return; if(lab[u] > lab[v])swap(u, v); lab[u] += lab[v]; lab[v] = u; } struct BIT { int n; vector<ll> fe; BIT(){} void init(int _n) { n = _n; fe.resize(n+1, 0); } void reset() { fill(fe.begin(), fe.end(), 0); } void add(int id, int x) { for(; id <= n; id += id & -id)fe[id] += x; } ll get(int id) { ll total = 0; for(; id; id -= id & -id)total += fe[id]; return total; } }; pll p[N]; ll ccw(pll x, pll y) { return x.se * y.fi - x.fi * y.se; } bool cmp(const pll& x, pll& y) { if((x.fi > 0) != (y.fi > 0))return x.fi < y.fi; return ccw(x, y) > 0; } void sol() { cin >> n; d[0] = 1; for(int i = 1; i <= n; i ++) { cin >> p[i].fi >> p[i].se; d[i] = d[i-1] * 2 % mod; } ans = d[n] * n % mod; ans = (ans - n + mod) % mod; for(int i = 1; i <= n; i ++) { vi.clear(); for(int j = 1; j <= n; j ++) { if(i == j)continue; p[j].fi -= p[i].fi; p[j].se -= p[i].se; vi.pb(p[j]); } sort(vi.begin(), vi.end(), cmp); for(int l = 0, r = 0; l < n-1; l ++) { if(l > r)r = l; while(ccw(vi[l%(n-1)], vi[(r+1)%(n-1)]) > 0)++r; //cout << l <<" "<<r<<" "<<d[r-l] << '\n'; ans = (ans - d[r-l] + mod) % mod; } for(int j = 1; j <= n; j ++) { if(i == j)continue; p[j].fi += p[i].fi; p[j].se += p[i].se; } } cout << ans; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define task "test" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; //cin >> test; while(test -- > 0)sol(); return 0; } /* 1234 21 */

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:131:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  131 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:132:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  132 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...