답안 #260425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260425 2020-08-10T08:47:09 Z 반딧불(#5056) 항공 노선도 (JOI18_airline) C++14
0 / 100
1222 ms 39592 KB
#include <bits/stdc++.h>
#include "Alicelib.h"

using namespace std;

typedef long long ll;

namespace AA{
    vector<int> link[2020];
    vector<pair<int, int> > edge;
    int cnt = 1;
}
using namespace AA;

void Alice(int N, int M, int A[], int B[]){
    for(int i=0; i<M; i++){ /// original graph
        link[A[i]].push_back(B[i]);
        link[B[i]].push_back(A[i]);
    }
    for(int i=0; i<N+10; i++){ /// vertex X
        link[N+11].push_back(i);
        link[i].push_back(N+11);
    }
    for(int d=0; d<10; d++){ /// vertex d0, d1, ..., d9
        for(int i=0; i<N; i++){
            if(i & (1<<d)) link[i].push_back(N+d), link[N+d].push_back(i);
        }
    }

    for(int i=0; i<10; i++){
        link[N+i].push_back(N+10);
        link[N+10].push_back(N+i);
    }

    for(int i=0; i<9; i++){
        link[N+i].push_back(N+i+1);
        link[N+i+1].push_back(N+i);
    }

    for(int i=0; i<N+12; i++){
        for(auto &j: link[i]){
            if(i < j) edge.push_back(make_pair(i, j));
        }
    }

    InitG(N+12, (int)edge.size());
    int cnt = 0;
    for(auto &x: edge){
//        printf("%d %d\n", x.first, x.second);
        MakeG(cnt++, x.first, x.second);
    }
}
#include <bits/stdc++.h>
#include "Boblib.h"

using namespace std;

typedef long long ll;

namespace BB{
    int n, m;
    int idx[2020];
    vector<int> glink[2020];
    vector<int> link[2002];

    int vertexX = -1, vertexY = -1;
    int vertexD[20];
    vector<int> specialVertices;
    bool isSpecial[2020];
    int specialDegree[2020];

    vector<int> specialLink[2020];

    vector<pair<int, int> > edge;

    vector<int> vec;
}
using namespace BB;

void Bob(int V, int U, int C[], int D[]){
    n = V-12;
    if(n==1){
        InitMap(1, 0);
        return;
    }

    for(int i=0; i<U; i++){
        glink[C[i]].push_back(D[i]);
        glink[D[i]].push_back(C[i]);
    }

    for(int i=0; i<V; i++){
        if((int)glink[i].size() == n+10){
            vertexX = i;

            for(int j=0; j<V; j++) isSpecial[j] = 1;
            isSpecial[i] = 0;
            for(auto &x: glink[i]) isSpecial[x] = 0;

            for(int j=0; j<V; j++){
                if(isSpecial[j]) specialVertices.push_back(j);
            }
            vertexY = specialVertices[0];

            memset(isSpecial, 0, sizeof(isSpecial));

            specialVertices.clear();
            for(auto &x: glink[vertexY]){
                specialVertices.push_back(x);
                isSpecial[x] = 1;
            }
            assert(specialVertices.size() == 10);
            break;
        }
    }

    int onedeg = 0;
    int onedegcnt = 0;
    for(auto &x: specialVertices){
        for(auto &y: glink[x]){
            if(isSpecial[y]){
                specialDegree[x]++;
                specialLink[x].push_back(y);
                specialLink[y].push_back(x);
            }
        }
        if(specialDegree[x] == 1){
            onedeg = max(onedeg, (int)glink[x].size());
            onedegcnt++;
        }
    }
    assert(onedegcnt == 2);

    for(auto &x: specialVertices){
        if(specialDegree[x] == 1 && onedeg == (int)glink[x].size()){
            vertexD[0] = x;
            specialDegree[x] = 0;

            int tmp = x, prv = 0;
            for(int i=1; i<10; i++){
                vertexD[i] = -1;
                for(auto &y: specialLink[tmp]){
                    if(prv == y) continue;
                    prv = tmp;
                    vertexD[i] = tmp = y;
                    specialDegree[y] = i;
                    break;
                }
            }
            break;
        }
    }

    for(int i=0; i<V; i++){
        if(isSpecial[i] || i == vertexX || i == vertexY) continue;

        for(auto &x: glink[i]){
            if(isSpecial[x]) idx[i] += (1 << specialDegree[x]);
        }
        vec.push_back(idx[i]);
    }
    sort(vec.begin(), vec.end());
    for(int i=0; i<n; i++){
        assert(vec[i] == i);
    }

    for(int i=0; i<V; i++){
        if(isSpecial[i] || i == vertexX || i == vertexY) continue;

        for(auto &x: glink[i]){
            if(!isSpecial[x] && x != vertexX && x != vertexY){
                link[idx[i]].push_back(idx[x]);
            }
        }
    }

    for(int i=0; i<n; i++){
        for(auto &x: link[i]){
            if(i < x){
                edge.push_back(make_pair(i, x));
            }
        }
    }

    InitMap(n, (int)edge.size());
    for(auto &x: edge){
        MakeMap(x.first, x.second);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6912 KB Output is correct
2 Correct 6 ms 7168 KB Output is correct
3 Correct 6 ms 6912 KB Output is correct
4 Runtime error 8 ms 6912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 6912 KB Output is correct
2 Correct 6 ms 7168 KB Output is correct
3 Correct 6 ms 6912 KB Output is correct
4 Runtime error 8 ms 6912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 743 ms 39240 KB Output is correct : V - N = 12
2 Correct 539 ms 34684 KB Output is correct : V - N = 12
3 Correct 198 ms 19040 KB Output is correct : V - N = 12
4 Correct 14 ms 7680 KB Output is correct : V - N = 12
5 Correct 133 ms 14008 KB Output is correct : V - N = 12
6 Correct 513 ms 32488 KB Output is correct : V - N = 12
7 Correct 705 ms 39400 KB Output is correct : V - N = 12
8 Correct 649 ms 37016 KB Output is correct : V - N = 12
9 Correct 318 ms 22208 KB Output is correct : V - N = 12
10 Correct 46 ms 9200 KB Output is correct : V - N = 12
11 Correct 75 ms 10704 KB Output is correct : V - N = 12
12 Correct 373 ms 25896 KB Output is correct : V - N = 12
13 Correct 684 ms 37936 KB Output is correct : V - N = 12
14 Correct 656 ms 39112 KB Output is correct : V - N = 12
15 Correct 423 ms 31612 KB Output is correct : V - N = 12
16 Correct 106 ms 12152 KB Output is correct : V - N = 12
17 Correct 24 ms 8448 KB Output is correct : V - N = 12
18 Correct 269 ms 20624 KB Output is correct : V - N = 12
19 Correct 614 ms 35800 KB Output is correct : V - N = 12
20 Correct 739 ms 39576 KB Output is correct : V - N = 12
21 Correct 192 ms 17808 KB Output is correct : V - N = 12
22 Correct 141 ms 14480 KB Output is correct : V - N = 12
23 Correct 67 ms 10464 KB Output is correct : V - N = 12
24 Correct 9 ms 7168 KB Output is correct : V - N = 12
25 Correct 35 ms 9184 KB Output is correct : V - N = 12
26 Correct 124 ms 13752 KB Output is correct : V - N = 12
27 Correct 195 ms 15784 KB Output is correct : V - N = 12
28 Correct 170 ms 15272 KB Output is correct : V - N = 12
29 Correct 90 ms 11528 KB Output is correct : V - N = 12
30 Correct 13 ms 7936 KB Output is correct : V - N = 12
31 Correct 12 ms 7424 KB Output is correct : V - N = 12
32 Correct 12 ms 7424 KB Output is correct : V - N = 12
33 Correct 15 ms 7424 KB Output is correct : V - N = 12
34 Correct 14 ms 7424 KB Output is correct : V - N = 12
35 Correct 12 ms 7424 KB Output is correct : V - N = 12
36 Correct 723 ms 39328 KB Output is correct : V - N = 12
37 Correct 725 ms 39592 KB Output is correct : V - N = 12
38 Correct 715 ms 39456 KB Output is correct : V - N = 12
39 Correct 737 ms 39360 KB Output is correct : V - N = 12
40 Correct 871 ms 39448 KB Output is correct : V - N = 12
41 Correct 135 ms 13664 KB Output is correct : V - N = 12
42 Correct 183 ms 12608 KB Output is correct : V - N = 12
43 Correct 113 ms 13392 KB Output is correct : V - N = 12
44 Correct 13 ms 7680 KB Output is correct : V - N = 12
45 Correct 76 ms 11064 KB Output is correct : V - N = 12
46 Correct 430 ms 19648 KB Output is correct : V - N = 12
47 Correct 126 ms 13664 KB Output is correct : V - N = 12
48 Correct 321 ms 22496 KB Output is correct : V - N = 12
49 Correct 77 ms 10456 KB Output is correct : V - N = 12
50 Correct 24 ms 8448 KB Output is correct : V - N = 12
51 Correct 666 ms 34732 KB Output is correct : V - N = 12
52 Correct 14 ms 7680 KB Output is correct : V - N = 12
53 Correct 788 ms 32440 KB Output is correct : V - N = 12
54 Correct 656 ms 36552 KB Output is correct : V - N = 12
55 Correct 45 ms 9208 KB Output is correct : V - N = 12
56 Correct 589 ms 24936 KB Output is correct : V - N = 12
57 Correct 825 ms 38464 KB Output is correct : V - N = 12
58 Correct 94 ms 12048 KB Output is correct : V - N = 12
59 Correct 445 ms 20424 KB Output is correct : V - N = 12
60 Correct 1222 ms 38552 KB Output is correct : V - N = 12
61 Correct 7 ms 6912 KB Output is correct : V - N = 12
62 Correct 7 ms 6912 KB Output is correct : V - N = 12
63 Correct 7 ms 6912 KB Output is correct : V - N = 12
64 Correct 5 ms 6912 KB Output is correct : V - N = 12
65 Correct 5 ms 6912 KB Output is correct : V - N = 12
66 Correct 6 ms 6912 KB Output is correct : V - N = 12
67 Runtime error 9 ms 6912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
68 Halted 0 ms 0 KB -