Submission #430918

#TimeUsernameProblemLanguageResultExecution timeMemory
430918HideoIOI Fever (JOI21_fever)C++17
6 / 100
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define all(s) s.begin(), s.end() #define ll long long #define fr first #define sc second #define pb push_back #define mk make_pair #define pi pair < int, int > const int N = 3007; const int INF = 1e9 + 7; pi d[4] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}}; int x[N], y[N]; int us[N]; int n, ans; int check (int v, int u, int k, int t){ if (abs(x[v] - x[u]) != abs(y[v] - y[u])){ if (x[v] == x[u]){ } else if (y[v] == y[u]){ } return -1; } if (t > abs(x[v] - x[u])) return -1; if (k == 0){ if (x[u] < x[v]) return -1; if (y[u] > y[v]) return 2; else return 3; } if (k == 1){ if (x[u] > x[v]) return -1; if (y[u] > y[v]) return 2; else return 3; } if (k == 2){ if (y[u] > y[v]) return -1; if (x[u] > x[v]) return 1; else return 0; } if (k == 3){ if (y[u] < y[v]) return -1; if (x[u] > x[v]) return 1; else return 0; } } int solve (int ks){ int r = 0; priority_queue < pair < int, pi > > qr; qr.push({0, {ks, 1}}); while (!qr.empty()){ int t = qr.top().fr, k = qr.top().sc.fr, v = qr.top().sc.sc; qr.pop(); if (us[v]) continue; r++; us[v] = 1; for (int i = 2; i <= n; i++){ if (us[i]) continue; int nk = check(v, i, k, t); if (nk != -1){ qr.push({abs(x[v] - x[i]), {nk, i}}); } } } return r; } main (){ cin >> n; for (int i = 1; i <= n; i++){ cin >> x[i] >> y[i]; } ans = max(ans, solve(0)); memset(us, 0, sizeof(us)); ans = max(ans, solve(1)); memset(us, 0, sizeof(us)); ans = max(ans, solve(2)); memset(us, 0, sizeof(us)); ans = max(ans, solve(3)); cout << ans; }

Compilation message (stderr)

fever.cpp:90:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   90 | main (){
      | ^~~~
fever.cpp: In function 'int check(int, int, int, int)':
fever.cpp:65:1: warning: control reaches end of non-void function [-Wreturn-type]
   65 | }
      | ^
#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...