Submission #549951

#TimeUsernameProblemLanguageResultExecution timeMemory
549951hidden1IOI Fever (JOI21_fever)C++14
6 / 100
1 ms472 KiB
#include <bits/stdc++.h> using namespace std; //#pragma GCC optimize ("O3") //#pragma GCC target ("sse4") #ifndef LOCAL #define cerr if(false) cerr #endif #define endl "\n" #define out(x) "[" << #x << "=" << x << "]" struct debug { debug() { cerr << "DEBUGGER: " << endl; } ~debug() { cerr << endl << "DEBUGGER_END " << endl; } template<class T> debug& operator <<(const T x) { cerr << x << " "; return *this; } }; template<class T> inline ostream &operator <<(ostream &out, const vector<T> &x) { for(const auto &it : x) { out << it << " "; } return out; } template<class T, class T2> inline ostream &operator <<(ostream &out, const pair<T, T2> &x) { return out << x.first << " " << x.second; } template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; } template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; } typedef long long ll; const ll mod = 1e9 + 7; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~// const int MAX_N = 5e5 + 10; int n; pair<int, int> p[MAX_N]; bool used[MAX_N]; enum DIR { RIGHT, DOWN, LEFT, UP }; void dfs(int x, DIR dir, int t) { used[x] = true; if(dir == DIR::RIGHT) { for(int i = 0; i < n; i ++) { if(used[i]) {continue;} if(p[x].first > p[i].first) {continue;} if(p[x].second == p[i].second) { int nowt = abs(p[x].first - p[i].first) / 2; if(nowt < t) {continue;} dfs(i, DIR::LEFT, nowt); continue; } if(p[x].first - p[x].second == p[i].first - p[i].second) { int nowt = abs(p[x].first - p[i].first); if(nowt < t) {continue;} dfs(i, DIR::DOWN, nowt); continue; } if(p[x].first + p[x].second == p[i].first + p[i].second) { int nowt = abs(p[x].first - p[i].first); if(nowt < t) {continue;} dfs(i, DIR::UP, nowt); continue; } } } else if(dir == DIR::DOWN) { for(int i = 0; i < n; i ++) { if(used[i]) {continue;} if(p[x].second < p[i].second) {continue;} if(p[x].first == p[i].first) { int nowt = abs(p[x].second - p[i].second) / 2; if(nowt < t) {continue;} dfs(i, DIR::UP, nowt); continue; } if(p[x].first - p[x].second == p[i].first - p[i].second) { int nowt = abs(p[x].second - p[i].second); if(nowt < t) {continue;} dfs(i, DIR::RIGHT, nowt); continue; } if(p[x].first + p[x].second == p[i].first + p[i].second) { int nowt = abs(p[x].second - p[i].second); if(nowt < t) {continue;} dfs(i, DIR::LEFT, nowt); continue; } } } else if(dir == DIR::LEFT) { for(int i = 0; i < n; i ++) { if(used[i]) {continue;} if(p[x].first < p[i].first) {continue;} if(p[x].second == p[i].second) { int nowt = abs(p[x].first - p[i].first) / 2; if(nowt < t) {continue;} dfs(i, DIR::RIGHT, nowt); continue; } if(p[x].first - p[x].second == p[i].first - p[i].second) { int nowt = abs(p[x].first - p[i].first); if(nowt < t) {continue;} dfs(i, DIR::UP, nowt); continue; } if(p[x].first + p[x].second == p[i].first + p[i].second) { int nowt = abs(p[x].first - p[i].first); if(nowt < t) {continue;} dfs(i, DIR::DOWN, nowt); continue; } } } else { for(int i = 0; i < n; i ++) { if(used[i]) {continue;} if(p[x].second > p[i].second) {continue;} if(p[x].first == p[i].first) { int nowt = abs(p[x].second - p[i].second) / 2; if(nowt < t) {continue;} dfs(i, DIR::DOWN, nowt); continue; } if(p[x].first - p[x].second == p[i].first - p[i].second) { int nowt = abs(p[x].second - p[i].second); if(nowt < t) {continue;} dfs(i, DIR::LEFT, nowt); continue; } if(p[x].first + p[x].second == p[i].first + p[i].second) { int nowt = abs(p[x].second - p[i].second); if(nowt < t) {continue;} dfs(i, DIR::RIGHT, nowt); continue; } } } } signed main() { #ifndef LOCAL ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #endif cin >> n; for(int i = 0; i < n; i ++) { cin >> p[i].first >> p[i].second; p[i].first *= 2; p[i].second *= 2; } int ret = 0; int now = 0; now = 0; dfs(0, DIR::DOWN, 0); for(int i = 0; i < n; i ++) { if(used[i]) { now ++; used[i] = false; } } chkmax(ret, now); now = 0; dfs(0, DIR::UP, 0); for(int i = 0; i < n; i ++) { if(used[i]) { now ++; used[i] = false; } } chkmax(ret, now); now = 0; dfs(0, DIR::LEFT, 0); for(int i = 0; i < n; i ++) { if(used[i]) { now ++; used[i] = false; } } chkmax(ret, now); now = 0; dfs(0, DIR::RIGHT, 0); for(int i = 0; i < n; i ++) { if(used[i]) { now ++; used[i] = false; } } chkmax(ret, now); cout << ret << endl; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...