Submission #549952

# Submission time Handle Problem Language Result Execution time Memory
549952 2022-04-16T23:23:56 Z hidden1 IOI Fever (JOI21_fever) C++14
6 / 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 ll MAX_N = 5e5 + 10;
ll n;
pair<ll, ll> p[MAX_N];

bool used[MAX_N];

enum DIR {
    RIGHT,
    DOWN,
    LEFT,
    UP
};

void dfs(ll x, DIR dir, ll t) {
    used[x] = true;

    if(dir == DIR::RIGHT) {
        for(ll i = 0; i < n; i ++) {
            if(used[i]) {continue;}
            if(p[x].first > p[i].first) {continue;}

            if(p[x].second == p[i].second) {
                ll 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) {
                ll 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) {
                ll nowt = abs(p[x].first - p[i].first);
                if(nowt < t) {continue;}
                dfs(i, DIR::UP, nowt);
                continue;
            }
        }
    } else if(dir == DIR::DOWN) {
        for(ll i = 0; i < n; i ++) {
            if(used[i]) {continue;}
            if(p[x].second < p[i].second) {continue;}

            if(p[x].first == p[i].first) {
                ll 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) {
                ll 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) {
                ll nowt = abs(p[x].second - p[i].second);
                if(nowt < t) {continue;}
                dfs(i, DIR::LEFT, nowt);
                continue;
            }
        }
    } else if(dir == DIR::LEFT) {
        for(ll i = 0; i < n; i ++) {
            if(used[i]) {continue;}
            if(p[x].first < p[i].first) {continue;}

            if(p[x].second == p[i].second) {
                ll 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) {
                ll 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) {
                ll nowt = abs(p[x].first - p[i].first);
                if(nowt < t) {continue;}
                dfs(i, DIR::DOWN, nowt);
                continue;
            }
        }
    } else {
        for(ll i = 0; i < n; i ++) {
            if(used[i]) {continue;}
            if(p[x].second > p[i].second) {continue;}

            if(p[x].first == p[i].first) {
                ll 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) {
                ll 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) {
                ll 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(ll i = 0; i < n; i ++) {
        cin >> p[i].first >> p[i].second;
        p[i].first *= 2;
        p[i].second *= 2;
    }

    ll ret = 0;
    ll now = 0;

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

    now = 0;
    dfs(0, DIR::UP, 0);
    for(ll i = 0; i < n; i ++) {
        if(used[i]) {
            now ++;
            used[i] = false;
        }
    }
    chkmax(ret, now);
    now = 0;
    dfs(0, DIR::LEFT, 0);
    for(ll i = 0; i < n; i ++) {
        if(used[i]) {
            now ++;
            used[i] = false;
        }
    }
    chkmax(ret, now);
    now = 0;
    dfs(0, DIR::RIGHT, 0);
    for(ll 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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 212 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 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 0 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Incorrect 0 ms 212 KB Output isn't correct
33 Halted 0 ms 0 KB -