Submission #549946

# Submission time Handle Problem Language Result Execution time Memory
549946 2022-04-16T22:44:51 Z hidden1 IOI Fever (JOI21_fever) C++14
0 / 100
1 ms 340 KB
#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) {
    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) {
                dfs(i, DIR::LEFT);
                continue;
            }
            if(p[x].first - p[x].second == p[i].first - p[i].second) {
                dfs(i, DIR::DOWN);
                continue;
            }
            if(p[x].first + p[x].second == p[i].first + p[i].second) {
                dfs(i, DIR::UP);
                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) {
                dfs(i, DIR::UP);
                continue;
            }
            if(p[x].first - p[x].second == p[i].first - p[i].second) {
                dfs(i, DIR::RIGHT);
                continue;
            }
            if(p[x].first + p[x].second == p[i].first + p[i].second) {
                dfs(i, DIR::LEFT);
                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) {
                dfs(i, DIR::RIGHT);
                continue;
            }
            if(p[x].first - p[x].second == p[i].first - p[i].second) {
                dfs(i, DIR::UP);
                continue;
            }
            if(p[x].first + p[x].second == p[i].first + p[i].second) {
                dfs(i, DIR::DOWN);
                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) {
                dfs(i, DIR::DOWN);
                continue;
            }
            if(p[x].first - p[x].second == p[i].first - p[i].second) {
                dfs(i, DIR::LEFT);
                continue;
            }
            if(p[x].first + p[x].second == p[i].first + p[i].second) {
                dfs(i, DIR::RIGHT);
                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;
    }

    int ret = 0;
    int now = 0;

    now = 0;
    dfs(0, DIR::DOWN);
    for(int i = 0; i < n; i ++) {
        if(used[i]) {
            now ++;
            used[i] = false;
        }
    }
    chkmax(ret, now);
    now = 0;
    dfs(0, DIR::UP);
    for(int i = 0; i < n; i ++) {
        if(used[i]) {
            now ++;
            used[i] = false;
        }
    }
    chkmax(ret, now);
    now = 0;
    dfs(0, DIR::LEFT);
    for(int i = 0; i < n; i ++) {
        if(used[i]) {
            now ++;
            used[i] = false;
        }
    }
    chkmax(ret, now);
    now = 0;
    dfs(0, DIR::RIGHT);
    for(int i = 0; i < n; i ++) {
        if(used[i]) {
            now ++;
            used[i] = false;
        }
    }
    chkmax(ret, now);

    cout << ret << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 324 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Incorrect 1 ms 212 KB Output isn't correct
17 Halted 0 ms 0 KB -