답안 #700184

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
700184 2023-02-18T19:21:07 Z urosk 항공 노선도 (JOI18_airline) C++14
37 / 100
783 ms 58432 KB
#include "Alicelib.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include "bits/stdc++.h"
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll int
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}

#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;
#define maxn 2020
void Alice(ll N,ll M,ll A[],ll B[] ){
    ll n = N,m = M;
    ll d = 12;
    ll v = n+d,u = m;
    vector<pll> a;
    vector<ll> want(maxn,0);
    vector<ll> deg(maxn,0);
    vector<vector<bool> > ima(maxn,vector<bool>(maxn,0));
    for(ll i = 0;i<m;i++) a.pb({A[i],B[i]});
    for(ll i = 0;i<v-2;i++) a.pb({i,v-1});
    for(ll i = n;i<v-2;i++) a.pb({i,v-2});
    set<pll> s;
    for(ll i = n;i<v-2;i++) want[i] = i-n;
    for(ll i = 0;i<v;i++) ima[i][i] = 1;
    for(ll i = v-3;i>n;i--){
        if(want[i]){
            a.pb({i,n});
            deg[i]++;
            deg[n]++;
            want[i]--;
        }
        ll j = i-1;
        while(want[i]&&j>=n){
            if(want[j]&&!ima[i][j]){
                ima[i][j] = ima[j][i] = 1;
                a.pb({i,j});
                want[j]--;
                want[i]--;
                deg[i]++;
                deg[j]++;
            }
            j--;
        }
    }
    //ceri(deg,n,v-3);
    for(ll i = 0;i<n;i++){
        for(ll j = 0;j<d-2;j++){
            if((1<<j)&i) a.pb({i,n+j});
        }
    }
    u = sz(a);
    InitG(v,u);
    //dbg(sz(a));
    //for(pll p : a) cerr<<p.fi<< " "<<p.sc<<endl;
    for(ll i = 0;i<v;i++) deg[i] = 0;
    for(ll i = 0;i<u;i++) deg[a[i].fi]++,deg[a[i].sc]++;
    //ceri(deg,0,v-1);
    for(ll i = 0;i<u;i++) MakeG(i,a[i].fi,a[i].sc);
}
/**
4 3
0 1
0 2
0 3

5 7
0 1
0 2
1 3
1 4
3 4
2 3
2 4

11 10
0 1
2 1
3 0
4 2
5 3
6 1
7 4
8 4
9 0
10 1
**/
#include "Boblib.h"
#define here cerr<<"===========================================\n"
#define dbg(x) cerr<<#x<<": "<<x<<endl;
#include "bits/stdc++.h"
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ld double
#define ll int
#define llinf 100000000000000000LL // 10^17
#define pb push_back
#define popb pop_back
#define fi first
#define sc second
#define endl '\n'
#define pll pair<ll,ll>
#define pld pair<ld,ld>
#define sz(a) (ll)(a.size())
#define all(a) a.begin(),a.end()
#define ceri(a,l,r) {cerr<<#a<<": ";for(ll i_ = l;i_<=r;i_++) cerr<<a[i_]<< " ";cerr<<endl;}
#define cer(a) {cerr<<#a<<": ";for(ll x_ : a) cerr<<x_<< " ";cerr<<endl;}

#define daj_mi_malo_vremena ios_base::sync_with_stdio(false);cerr.tie(0);cout.tie(0);cin.tie(0);

using namespace std;
#define maxn 2020
void Bob(ll V,ll U,ll C[],ll D[]){
    ll n = V,m = U;
    vector<ll> ans(maxn,0);
    vector<ll> deg(maxn,0);
    vector<ll> sdeg(maxn,0);
    vector<pll> e(maxn*maxn);
    vector<bool> spec(maxn,0);
    vector<vector<ll> > g(maxn);
    vector<vector<bool> > ok(maxn,vector<bool>(maxn,0));
    for(ll i = 0;i<m;i++) e[i] = {C[i],D[i]};
    for(ll i = 0;i<m;i++){
        ll x = e[i].fi,y = e[i].sc;
        deg[x]++;
        deg[y]++;
        ok[x][y] = ok[y][x] = 1;
        g[x].pb(y);
        g[y].pb(x);
    }
    for(ll i = 0;i<n;i++) ok[i][i] = 1;
    ll u = 0;
    for(ll i = 0;i<n;i++) if(deg[i]>deg[u]) u = i;
    ll v = -1;
    for(ll i = 0;i<n;i++) if(!ok[u][i]){
        if(v==-1) v = i;
        else if(deg[i]>deg[v]) v = i;
    }
    vector<ll> w,W;
    for(ll x : g[v]){
        w.pb(x);
        spec[x] = 1;
    }
    vector<ll> v5;
    for(ll x : w){
        ll cnt = -1;
        for(ll y : w){
            if(ok[x][y]){
                cnt++;
            }
        }
        W.pb(cnt);
        if(cnt==5) v5.pb(x);
    }
    spec[u] = spec[v] = 1;
    for(ll i = 0;i<10;i++){
        ll x = w[i];
        ll cnt = W[i];
        if(cnt==5){
            if(deg[x]>deg[v5[0]^v5[1]^x]) cnt = 0;
        }
        //cerr<<x<< " "<<cnt<<" "<<deg[x]<<endl;
        for(ll y : g[x]){
            if(!spec[y]){
                ans[y]+=(1<<cnt);
            }
        }
    }

    ll gr = 0;
    for(ll i = 0;i<m;i++){
        ll x = e[i].fi,y = e[i].sc;
        if(spec[x]||spec[y]) continue;
        gr++;
    }
    InitMap(n-12,gr);
    for(ll i = 0;i<m;i++){
        ll x = e[i].fi,y = e[i].sc;
        if(spec[x]||spec[y]) continue;
        x = ans[x],y = ans[y];
        MakeMap(x,y);
    }
}
/**
4 3
0 1
0 2
0 3

11 10
0 1
2 1
3 0
4 2
5 3
6 1
7 4
8 4
9 0
10 1
**/
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 37868 KB Output is correct
2 Correct 17 ms 37904 KB Output is correct
3 Correct 19 ms 37820 KB Output is correct
4 Correct 16 ms 37816 KB Output is correct
5 Correct 23 ms 37748 KB Output is correct
6 Correct 19 ms 37848 KB Output is correct
7 Correct 19 ms 37880 KB Output is correct
8 Correct 22 ms 37796 KB Output is correct
9 Correct 17 ms 37796 KB Output is correct
10 Correct 17 ms 37864 KB Output is correct
11 Correct 17 ms 37892 KB Output is correct
12 Correct 18 ms 37856 KB Output is correct
13 Correct 20 ms 37804 KB Output is correct
14 Correct 17 ms 37808 KB Output is correct
15 Correct 17 ms 37884 KB Output is correct
16 Correct 17 ms 37856 KB Output is correct
17 Correct 17 ms 37856 KB Output is correct
18 Correct 19 ms 37872 KB Output is correct
19 Correct 23 ms 37796 KB Output is correct
20 Correct 17 ms 37844 KB Output is correct
21 Correct 17 ms 37888 KB Output is correct
22 Correct 18 ms 37908 KB Output is correct
23 Correct 17 ms 37796 KB Output is correct
24 Correct 17 ms 37868 KB Output is correct
25 Correct 20 ms 37900 KB Output is correct
26 Correct 17 ms 37844 KB Output is correct
27 Correct 18 ms 37796 KB Output is correct
28 Correct 17 ms 37832 KB Output is correct
29 Correct 17 ms 37896 KB Output is correct
30 Correct 20 ms 37828 KB Output is correct
31 Correct 19 ms 37800 KB Output is correct
32 Correct 18 ms 37848 KB Output is correct
33 Correct 16 ms 37892 KB Output is correct
34 Correct 19 ms 37796 KB Output is correct
35 Correct 17 ms 37816 KB Output is correct
36 Correct 19 ms 37832 KB Output is correct
37 Correct 18 ms 37948 KB Output is correct
38 Correct 17 ms 37768 KB Output is correct
39 Correct 18 ms 37896 KB Output is correct
40 Correct 20 ms 37852 KB Output is correct
41 Correct 18 ms 37732 KB Output is correct
42 Correct 19 ms 37764 KB Output is correct
43 Correct 17 ms 37840 KB Output is correct
44 Correct 17 ms 37820 KB Output is correct
45 Correct 18 ms 37876 KB Output is correct
46 Correct 18 ms 37876 KB Output is correct
47 Correct 17 ms 37872 KB Output is correct
48 Correct 17 ms 37896 KB Output is correct
49 Correct 17 ms 37900 KB Output is correct
50 Correct 17 ms 37820 KB Output is correct
51 Correct 18 ms 37796 KB Output is correct
52 Correct 17 ms 37768 KB Output is correct
53 Correct 18 ms 37816 KB Output is correct
54 Correct 18 ms 37820 KB Output is correct
55 Correct 17 ms 37896 KB Output is correct
56 Correct 18 ms 37888 KB Output is correct
57 Correct 22 ms 37784 KB Output is correct
58 Correct 17 ms 37892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 37868 KB Output is correct
2 Correct 17 ms 37904 KB Output is correct
3 Correct 19 ms 37820 KB Output is correct
4 Correct 16 ms 37816 KB Output is correct
5 Correct 23 ms 37748 KB Output is correct
6 Correct 19 ms 37848 KB Output is correct
7 Correct 19 ms 37880 KB Output is correct
8 Correct 22 ms 37796 KB Output is correct
9 Correct 17 ms 37796 KB Output is correct
10 Correct 17 ms 37864 KB Output is correct
11 Correct 17 ms 37892 KB Output is correct
12 Correct 18 ms 37856 KB Output is correct
13 Correct 20 ms 37804 KB Output is correct
14 Correct 17 ms 37808 KB Output is correct
15 Correct 17 ms 37884 KB Output is correct
16 Correct 17 ms 37856 KB Output is correct
17 Correct 17 ms 37856 KB Output is correct
18 Correct 19 ms 37872 KB Output is correct
19 Correct 23 ms 37796 KB Output is correct
20 Correct 17 ms 37844 KB Output is correct
21 Correct 17 ms 37888 KB Output is correct
22 Correct 18 ms 37908 KB Output is correct
23 Correct 17 ms 37796 KB Output is correct
24 Correct 17 ms 37868 KB Output is correct
25 Correct 20 ms 37900 KB Output is correct
26 Correct 17 ms 37844 KB Output is correct
27 Correct 18 ms 37796 KB Output is correct
28 Correct 17 ms 37832 KB Output is correct
29 Correct 17 ms 37896 KB Output is correct
30 Correct 20 ms 37828 KB Output is correct
31 Correct 19 ms 37800 KB Output is correct
32 Correct 18 ms 37848 KB Output is correct
33 Correct 16 ms 37892 KB Output is correct
34 Correct 19 ms 37796 KB Output is correct
35 Correct 17 ms 37816 KB Output is correct
36 Correct 19 ms 37832 KB Output is correct
37 Correct 18 ms 37948 KB Output is correct
38 Correct 17 ms 37768 KB Output is correct
39 Correct 18 ms 37896 KB Output is correct
40 Correct 20 ms 37852 KB Output is correct
41 Correct 18 ms 37732 KB Output is correct
42 Correct 19 ms 37764 KB Output is correct
43 Correct 17 ms 37840 KB Output is correct
44 Correct 17 ms 37820 KB Output is correct
45 Correct 18 ms 37876 KB Output is correct
46 Correct 18 ms 37876 KB Output is correct
47 Correct 17 ms 37872 KB Output is correct
48 Correct 17 ms 37896 KB Output is correct
49 Correct 17 ms 37900 KB Output is correct
50 Correct 17 ms 37820 KB Output is correct
51 Correct 18 ms 37796 KB Output is correct
52 Correct 17 ms 37768 KB Output is correct
53 Correct 18 ms 37816 KB Output is correct
54 Correct 18 ms 37820 KB Output is correct
55 Correct 17 ms 37896 KB Output is correct
56 Correct 18 ms 37888 KB Output is correct
57 Correct 22 ms 37784 KB Output is correct
58 Correct 17 ms 37892 KB Output is correct
59 Correct 16 ms 38032 KB Output is correct
60 Correct 17 ms 37868 KB Output is correct
61 Correct 19 ms 37804 KB Output is correct
62 Correct 20 ms 37848 KB Output is correct
63 Correct 18 ms 37812 KB Output is correct
64 Correct 20 ms 37908 KB Output is correct
65 Correct 18 ms 37956 KB Output is correct
66 Correct 17 ms 37912 KB Output is correct
67 Correct 18 ms 37876 KB Output is correct
68 Correct 17 ms 37832 KB Output is correct
69 Correct 17 ms 37880 KB Output is correct
70 Correct 17 ms 37808 KB Output is correct
71 Correct 19 ms 37888 KB Output is correct
72 Correct 18 ms 37980 KB Output is correct
73 Correct 17 ms 37836 KB Output is correct
74 Correct 19 ms 37832 KB Output is correct
75 Correct 17 ms 37816 KB Output is correct
76 Correct 18 ms 37764 KB Output is correct
77 Correct 17 ms 37984 KB Output is correct
78 Correct 17 ms 37828 KB Output is correct
79 Correct 17 ms 37800 KB Output is correct
80 Correct 18 ms 37824 KB Output is correct
81 Correct 20 ms 37784 KB Output is correct
82 Correct 17 ms 37748 KB Output is correct
83 Correct 20 ms 37716 KB Output is correct
84 Correct 18 ms 37832 KB Output is correct
85 Correct 20 ms 37888 KB Output is correct
86 Correct 16 ms 37824 KB Output is correct
87 Correct 19 ms 37792 KB Output is correct
88 Correct 20 ms 37772 KB Output is correct
89 Correct 19 ms 37812 KB Output is correct
90 Correct 17 ms 37804 KB Output is correct
91 Correct 22 ms 37820 KB Output is correct
92 Correct 17 ms 37892 KB Output is correct
93 Correct 17 ms 37816 KB Output is correct
94 Correct 18 ms 37924 KB Output is correct
95 Correct 17 ms 37844 KB Output is correct
96 Correct 16 ms 37872 KB Output is correct
97 Correct 18 ms 37868 KB Output is correct
98 Correct 20 ms 37884 KB Output is correct
99 Correct 17 ms 37860 KB Output is correct
100 Correct 19 ms 37808 KB Output is correct
101 Correct 17 ms 37820 KB Output is correct
102 Correct 18 ms 37824 KB Output is correct
103 Correct 16 ms 37872 KB Output is correct
104 Correct 16 ms 37820 KB Output is correct
105 Correct 18 ms 37796 KB Output is correct
106 Correct 20 ms 37916 KB Output is correct
107 Correct 17 ms 37808 KB Output is correct
108 Correct 17 ms 37832 KB Output is correct
109 Correct 17 ms 37808 KB Output is correct
110 Correct 17 ms 37844 KB Output is correct
111 Correct 18 ms 37880 KB Output is correct
112 Correct 17 ms 37832 KB Output is correct
113 Correct 19 ms 37904 KB Output is correct
114 Correct 20 ms 37808 KB Output is correct
115 Correct 19 ms 37832 KB Output is correct
116 Correct 16 ms 37896 KB Output is correct
117 Correct 17 ms 37796 KB Output is correct
118 Correct 20 ms 37788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 629 ms 58432 KB Output is correct : V - N = 12
2 Correct 598 ms 54588 KB Output is correct : V - N = 12
3 Correct 199 ms 44804 KB Output is correct : V - N = 12
4 Correct 23 ms 38380 KB Output is correct : V - N = 12
5 Correct 110 ms 41924 KB Output is correct : V - N = 12
6 Correct 431 ms 52700 KB Output is correct : V - N = 12
7 Correct 665 ms 58120 KB Output is correct : V - N = 12
8 Correct 596 ms 56416 KB Output is correct : V - N = 12
9 Correct 249 ms 47068 KB Output is correct : V - N = 12
10 Correct 55 ms 39076 KB Output is correct : V - N = 12
11 Correct 79 ms 39956 KB Output is correct : V - N = 12
12 Correct 339 ms 49264 KB Output is correct : V - N = 12
13 Correct 627 ms 57056 KB Output is correct : V - N = 12
14 Correct 783 ms 57472 KB Output is correct : V - N = 12
15 Correct 408 ms 51552 KB Output is correct : V - N = 12
16 Correct 120 ms 40928 KB Output is correct : V - N = 12
17 Correct 39 ms 38684 KB Output is correct : V - N = 12
18 Correct 292 ms 46008 KB Output is correct : V - N = 12
19 Correct 478 ms 55536 KB Output is correct : V - N = 12
20 Correct 680 ms 58052 KB Output is correct : V - N = 12
21 Correct 170 ms 44200 KB Output is correct : V - N = 12
22 Correct 120 ms 42224 KB Output is correct : V - N = 12
23 Incorrect 81 ms 39896 KB Wrong Answer [12]
24 Halted 0 ms 0 KB -