Submission #71339332


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vmi = vector<mint>;
using vvmi = vector<vmi>;
using vvvmi = vector<vvmi>;
#define all(a) (a).begin(), (a).end()
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define rep(i, n) rep2(i, 0, n)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define drep(i, n) drep2(i, n, 0)

void solve(){
    
}
using p = pair<ll, ll>;

int main(){
    int n; cin >> n;
    vll x(n), r(n); rep(i, n)cin >> x[i] >> r[i];
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    set<ll> st;
    rep(i, n){
        st.insert(x[i]+r[i]);
        st.insert(x[i]-r[i]);
    }
    map<ll, int> mp;
    int itr = 0;
    for(auto i : st){
        mp[i] = itr;
        itr++;
    }
    vector<p> vp(n);
    rep(i, n)vp[i] = {mp[x[i]-r[i]], mp[x[i]+r[i]]};
    sort(all(vp));
    mf_graph<ll> graph(n + itr+ 2);
    int l = n + itr + 1;
    rep(i, n){
        graph.add_edge(0, i+1, 1);
        graph.add_edge(i+1, n+1 + vp[i].first, 1);
        graph.add_edge(i+1, n+1 + vp[i].second, 1);
    }
    rep(i, itr)graph.add_edge(n+1+i, l, 1);
    cout << graph.flow(0, l) << endl;
    
    return 0;
}

Submission Info

Submission Time
Task E - Distribute Bunnies
User applejam
Language C++23 (GCC 15.2.0)
Score 500
Code Size 1463 Byte
Status AC
Exec Time 1659 ms
Memory 137128 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 42
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 02_small_cc_00.txt, 02_small_cc_01.txt, 02_small_cc_02.txt, 02_small_cc_03.txt, 02_small_cc_04.txt, 02_small_cc_05.txt, 02_small_cc_06.txt, 02_small_cc_07.txt, 02_small_cc_08.txt, 02_small_cc_09.txt, 02_small_cc_10.txt, 02_small_cc_11.txt, 02_small_cc_12.txt, 02_small_cc_13.txt, 02_small_cc_14.txt, 02_small_cc_15.txt, 02_small_cc_16.txt, 02_small_cc_17.txt, 02_small_cc_18.txt, 02_small_cc_19.txt, 03_path_00.txt, 03_path_01.txt, 04_cycle_00.txt, 04_cycle_01.txt, 05_namori_00.txt, 05_namori_01.txt, 05_namori_02.txt, 05_namori_03.txt, 05_namori_04.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3592 KiB
00_sample_01.txt AC 1 ms 3424 KiB
00_sample_02.txt AC 1 ms 3552 KiB
01_random_00.txt AC 477 ms 101260 KiB
01_random_01.txt AC 635 ms 94848 KiB
01_random_02.txt AC 529 ms 108764 KiB
01_random_03.txt AC 704 ms 137128 KiB
01_random_04.txt AC 451 ms 98920 KiB
01_random_05.txt AC 722 ms 132856 KiB
01_random_06.txt AC 350 ms 74868 KiB
01_random_07.txt AC 667 ms 129296 KiB
01_random_08.txt AC 355 ms 76216 KiB
01_random_09.txt AC 516 ms 84172 KiB
02_small_cc_00.txt AC 347 ms 134152 KiB
02_small_cc_01.txt AC 329 ms 131540 KiB
02_small_cc_02.txt AC 333 ms 129364 KiB
02_small_cc_03.txt AC 361 ms 126904 KiB
02_small_cc_04.txt AC 337 ms 124356 KiB
02_small_cc_05.txt AC 344 ms 122416 KiB
02_small_cc_06.txt AC 350 ms 120052 KiB
02_small_cc_07.txt AC 346 ms 116332 KiB
02_small_cc_08.txt AC 343 ms 113732 KiB
02_small_cc_09.txt AC 344 ms 111972 KiB
02_small_cc_10.txt AC 345 ms 110692 KiB
02_small_cc_11.txt AC 336 ms 109088 KiB
02_small_cc_12.txt AC 331 ms 107664 KiB
02_small_cc_13.txt AC 332 ms 105552 KiB
02_small_cc_14.txt AC 336 ms 104124 KiB
02_small_cc_15.txt AC 339 ms 102724 KiB
02_small_cc_16.txt AC 334 ms 101852 KiB
02_small_cc_17.txt AC 329 ms 100576 KiB
02_small_cc_18.txt AC 330 ms 99368 KiB
02_small_cc_19.txt AC 323 ms 98380 KiB
03_path_00.txt AC 276 ms 100652 KiB
03_path_01.txt AC 1601 ms 101984 KiB
04_cycle_00.txt AC 289 ms 100596 KiB
04_cycle_01.txt AC 1659 ms 112788 KiB
05_namori_00.txt AC 540 ms 92952 KiB
05_namori_01.txt AC 621 ms 92404 KiB
05_namori_02.txt AC 553 ms 93012 KiB
05_namori_03.txt AC 525 ms 92468 KiB
05_namori_04.txt AC 540 ms 93016 KiB