Submission #571086

#TimeUsernameProblemLanguageResultExecution timeMemory
5710868e7IOI Fever (JOI21_fever)C++17
0 / 100
1 ms440 KiB
//Challenge: Accepted #include <bits/stdc++.h> using namespace std; #ifdef zisk void debug(){cout << endl;} template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);} template<class T> void pary(T l, T r) { while (l != r) cout << *l << " ", l++; cout << endl; } #else #define debug(...) 0 #define pary(...) 0 #endif #define ll long long #define maxn 200005 #define pii pair<int, int> #define x first #define y second #define ff first #define ss second #define io ios_base::sync_with_stdio(0);cin.tie(0); const ll inf = 1e9; pii a[maxn]; unordered_map<int, set<pii> > horz, vert, ru, rd; unordered_map<int, set<pii> > t0, t1, t2, t3; unordered_map<ll, int> mp; ll h(pii p) { return (ll)inf * p.x + p.y; } struct pnt{ pii p; int t, d; pnt(){t = d = 0;} pnt(pii P, int ti, int di){p = P, t = ti, d = di;} }; int mov[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}; int movru[4][2] = {{1, 1}, {1, 1}, {-1, -1}, {-1, -1}}; int movrd[4][2] = {{1, -1}, {-1, 1}, {-1, 1}, {1, -1}}; int mind[maxn], di[maxn]; bool vis[maxn]; int main() { io int n; cin >> n; for (int i = 0;i < n;i++) { cin >> a[i].x >> a[i].y; mp[h(a[i])] = i; horz[a[i].y].insert(a[i]); vert[a[i].x].insert(a[i]); ru[a[i].x - a[i].y].insert(a[i]); rd[a[i].x + a[i].y].insert(a[i]); } int ans = 0; for (int init_d = 0;init_d < 4;init_d++) { for (int i = 0;i < n;i++) { mind[i] = inf, vis[i] = 0; if (i == 0) continue; int dx = a[i].x - a[0].x, dy = a[i].y - a[0].y; if (abs(dx) > abs(dy)) { di[i] = dx > 0 ? 2 : 0; } else if (abs(dx) < abs(dy)) { di[i] = dy > 0 ? 3 : 1; } else { pii tmp = {dx, dy}; for (int j = 0;j < 4 - init_d;j++) tmp = {-tmp.y, tmp.x}; if (tmp.x > 0) di[i] = tmp.y > 0 ? 3 : 1; else di[i] = 0; di[i] = (di[i] + init_d)%4; } } mind[0] = 0; di[0] = init_d; int cnt = 0; auto col = [&] (int i, int j) { int dx = a[j].x - a[i].x, dy = a[j].y - a[i].y; int divx = mov[di[i]][0] - mov[di[j]][0], divy = mov[di[i]][1] - mov[di[j]][1]; if (dx && divx == 0) return -1; if (dy && divy == 0) return -1; if (dx == 0) { if (abs(di[i] - di[j]) == 2) return dy * 2 / divy; return -1; } if (dy == 0) { if (abs(di[i] - di[j]) == 2) return dx * 2 / divx; return -1; } if (dx * divy != dy * divx) return -1; return dx * 2 / divx; }; //debug(init_d); while (true) { int ind = -1, best = inf; for (int i = 0;i < n;i++) { if (!vis[i] && mind[i] < best) { best = mind[i]; ind = i; } } if (ind == -1) break; pii cur = a[ind]; vis[ind] = 1; cnt++; int ti = mind[ind]; for (int i = 0;i < n;i++) { if (i == ind) continue; int p = col(ind, i); if (p >= ti) { mind[i] = min(mind[i],p); } } } ans = max(ans, cnt); } cout << ans << "\n"; }

Compilation message (stderr)

fever.cpp: In function 'int main()':
fever.cpp:104:8: warning: variable 'cur' set but not used [-Wunused-but-set-variable]
  104 |    pii cur = a[ind];
      |        ^~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...