Submission #242776

# Submission time Handle Problem Language Result Execution time Memory
242776 2020-06-29T09:57:10 Z osaaateiasavtnl Airline Route Map (JOI18_airline) C++17
22 / 100
903 ms 30784 KB
#include<bits/stdc++.h>
#include "Alicelib.h"
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
void Alice( int N, int M, int A[], int B[] ){   
    /*
    InitG( 3, 2 );
    MakeG( 1, 2 );
    MakeG( 1, 3 );
    */

    vector <ii> ans;
    for (int i = 0; i < M; ++i)
        ans.app(mp(A[i], B[i]));

    // N ... N + 9 - bits
    for (int i = N; i < N + 9; ++i)
        ans.app(mp(i, i + 1));

    // N + 10, N + 11 - centers
    ans.app(mp(N+10, N+11));
    for (int i = 0; i < N; ++i) {
        ans.app(mp(i, N + 10));
        ans.app(mp(i, N + 11));
    }       

    for (int i = N+1; i < N + 10; i += 2)
        ans.app(mp(i, N + 10));
    for (int i = N+2; i < N + 10; i += 2)
        ans.app(mp(i, N + 11));

    for (int u = 0; u < N; ++u)
        for (int bit = 0; bit < 10; ++bit)
            if ((u >> bit) & 1)
                ans.app(mp(u, N+bit));

    vector <int> pw(N+12);
    for (auto e : ans) {
        ++pw[e.f];
        ++pw[e.s];
    }   

    for (int i = N; i < N + 10; ++i) {
        if (pw[i] >= min(pw[N+10], pw[N+11])) {
            cout << "LMAO bit " << i - N << ' ' << pw[i] << endl;
            exit(1);
        }   
    }   

    InitG(N + 12, ans.size());
    int ptr = 0;
    for (auto e : ans) {
        MakeG(ptr++, e.f, e.s);
        //cout << e.f << ' ' << e.s << endl;
    }
}

#include<bits/stdc++.h>
#include "Boblib.h"
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int N = 2007;
bool g[N][N];

void Bob( int V, int E, int C[], int D[] ){
    int n = V - 12;
    vector <int> pw(V);
    for (int i = 0; i < E; ++i) {
        ++pw[C[i]];
        ++pw[D[i]];
        g[C[i]][D[i]] = g[D[i]][C[i]] = 1;
    }
    
    vector <int> ord;
    for (int i = 0; i < V; ++i)
        ord.app(i);
    auto comp = [&](int u, int v) {
        return pw[u] < pw[v];
    };
    sort(all(ord), comp);

    vector <int> cen = {ord[V - 2], ord[V - 1]};
    vector <int> bit;
    for (int i = 0; i < V; ++i) {
        int tocen = 0;
        for (auto e : cen) {
            tocen += g[i][e];
            if (e == i)
                tocen += 100;
        }
        if (tocen < 2) {
            bit.app(i);
        }   
    }   

    for (int i = 0; i < bit.size(); ++i) {
        int tocen = 0;
        for (auto e : cen) {
            tocen += g[bit[i]][e];
            if (e == bit[i])
                tocen += 100;
        }
        if (tocen == 0) {
            swap(bit[0], bit[i]);
            break;
        }
    }   

    for (int i = 1; i < bit.size(); ++i) {
        int prv = bit[i-1];
        for (int j = i; j < bit.size(); ++j) {
            if (g[prv][bit[j]]) {
                swap(bit[i], bit[j]);
                break;
            }   
        }   
    }   

    vector <int> real;
    for (int i = 0; i < V; ++i) {
        if (!g[i][cen[0]] || !g[i][cen[1]])
            continue;
        real.app(i);
    }   

    vector <int> num;
    for (auto e : real) {
        int x = 0;
        for (int i = 0; i < 10; ++i)
            if (g[e][bit[i]])
                x += 1 << i;
        num.app(x);
    }   

    /*
    InitMap( 3, 2 );
    MakeMap( 1, 2 );
    MakeMap( 1, 3 );
    */

    vector <ii> ans;
    for (int i = 0; i < real.size(); ++i)   
        for (int j = i+1; j < real.size(); ++j)
            if (g[real[i]][real[j]]) {

                //cout << "add " << num[i] << ' ' << num[j] << endl;

                ans.app(mp(num[i], num[j]));
            }
    InitMap(n, ans.size());
    for (auto e : ans)
        MakeMap(e.f, e.s);
}

Compilation message

Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:48:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < bit.size(); ++i) {
                     ~~^~~~~~~~~~~~
Bob.cpp:61:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1; i < bit.size(); ++i) {
                     ~~^~~~~~~~~~~~
Bob.cpp:63:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i; j < bit.size(); ++j) {
                         ~~^~~~~~~~~~~~
Bob.cpp:94:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < real.size(); ++i)   
                     ~~^~~~~~~~~~~~~
Bob.cpp:95:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = i+1; j < real.size(); ++j)
                           ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 13 ms 6912 KB Output is correct
2 Correct 13 ms 6912 KB Output is correct
3 Correct 13 ms 6912 KB Output is correct
4 Correct 13 ms 6656 KB Output is correct
5 Correct 13 ms 6912 KB Output is correct
6 Correct 13 ms 6912 KB Output is correct
7 Correct 13 ms 6912 KB Output is correct
8 Correct 13 ms 6912 KB Output is correct
9 Correct 13 ms 6912 KB Output is correct
10 Correct 14 ms 6912 KB Output is correct
11 Correct 13 ms 6912 KB Output is correct
12 Correct 13 ms 6912 KB Output is correct
13 Correct 13 ms 6912 KB Output is correct
14 Correct 13 ms 6912 KB Output is correct
15 Correct 13 ms 6912 KB Output is correct
16 Correct 14 ms 6912 KB Output is correct
17 Correct 13 ms 6912 KB Output is correct
18 Correct 13 ms 6912 KB Output is correct
19 Correct 13 ms 6912 KB Output is correct
20 Correct 13 ms 6912 KB Output is correct
21 Correct 14 ms 6912 KB Output is correct
22 Correct 13 ms 6912 KB Output is correct
23 Correct 13 ms 6912 KB Output is correct
24 Correct 14 ms 6912 KB Output is correct
25 Correct 14 ms 6912 KB Output is correct
26 Correct 13 ms 6912 KB Output is correct
27 Correct 13 ms 6912 KB Output is correct
28 Correct 13 ms 6912 KB Output is correct
29 Correct 13 ms 6912 KB Output is correct
30 Correct 13 ms 6912 KB Output is correct
31 Correct 13 ms 6912 KB Output is correct
32 Correct 13 ms 6912 KB Output is correct
33 Correct 13 ms 6656 KB Output is correct
34 Correct 13 ms 6912 KB Output is correct
35 Correct 13 ms 6912 KB Output is correct
36 Correct 13 ms 6912 KB Output is correct
37 Correct 13 ms 6912 KB Output is correct
38 Correct 14 ms 6912 KB Output is correct
39 Correct 13 ms 6912 KB Output is correct
40 Correct 13 ms 6912 KB Output is correct
41 Correct 13 ms 6912 KB Output is correct
42 Correct 13 ms 6912 KB Output is correct
43 Correct 14 ms 6912 KB Output is correct
44 Correct 13 ms 6656 KB Output is correct
45 Correct 13 ms 6912 KB Output is correct
46 Correct 13 ms 6912 KB Output is correct
47 Correct 13 ms 6912 KB Output is correct
48 Correct 14 ms 6912 KB Output is correct
49 Correct 13 ms 6912 KB Output is correct
50 Correct 13 ms 6912 KB Output is correct
51 Correct 13 ms 6912 KB Output is correct
52 Correct 13 ms 6912 KB Output is correct
53 Correct 13 ms 6912 KB Output is correct
54 Correct 14 ms 6912 KB Output is correct
55 Correct 13 ms 6912 KB Output is correct
56 Correct 13 ms 7168 KB Output is correct
57 Correct 13 ms 6912 KB Output is correct
58 Correct 13 ms 6912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 6912 KB Output is correct
2 Correct 13 ms 6912 KB Output is correct
3 Correct 13 ms 6912 KB Output is correct
4 Correct 13 ms 6656 KB Output is correct
5 Correct 13 ms 6912 KB Output is correct
6 Correct 13 ms 6912 KB Output is correct
7 Correct 13 ms 6912 KB Output is correct
8 Correct 13 ms 6912 KB Output is correct
9 Correct 13 ms 6912 KB Output is correct
10 Correct 14 ms 6912 KB Output is correct
11 Correct 13 ms 6912 KB Output is correct
12 Correct 13 ms 6912 KB Output is correct
13 Correct 13 ms 6912 KB Output is correct
14 Correct 13 ms 6912 KB Output is correct
15 Correct 13 ms 6912 KB Output is correct
16 Correct 14 ms 6912 KB Output is correct
17 Correct 13 ms 6912 KB Output is correct
18 Correct 13 ms 6912 KB Output is correct
19 Correct 13 ms 6912 KB Output is correct
20 Correct 13 ms 6912 KB Output is correct
21 Correct 14 ms 6912 KB Output is correct
22 Correct 13 ms 6912 KB Output is correct
23 Correct 13 ms 6912 KB Output is correct
24 Correct 14 ms 6912 KB Output is correct
25 Correct 14 ms 6912 KB Output is correct
26 Correct 13 ms 6912 KB Output is correct
27 Correct 13 ms 6912 KB Output is correct
28 Correct 13 ms 6912 KB Output is correct
29 Correct 13 ms 6912 KB Output is correct
30 Correct 13 ms 6912 KB Output is correct
31 Correct 13 ms 6912 KB Output is correct
32 Correct 13 ms 6912 KB Output is correct
33 Correct 13 ms 6656 KB Output is correct
34 Correct 13 ms 6912 KB Output is correct
35 Correct 13 ms 6912 KB Output is correct
36 Correct 13 ms 6912 KB Output is correct
37 Correct 13 ms 6912 KB Output is correct
38 Correct 14 ms 6912 KB Output is correct
39 Correct 13 ms 6912 KB Output is correct
40 Correct 13 ms 6912 KB Output is correct
41 Correct 13 ms 6912 KB Output is correct
42 Correct 13 ms 6912 KB Output is correct
43 Correct 14 ms 6912 KB Output is correct
44 Correct 13 ms 6656 KB Output is correct
45 Correct 13 ms 6912 KB Output is correct
46 Correct 13 ms 6912 KB Output is correct
47 Correct 13 ms 6912 KB Output is correct
48 Correct 14 ms 6912 KB Output is correct
49 Correct 13 ms 6912 KB Output is correct
50 Correct 13 ms 6912 KB Output is correct
51 Correct 13 ms 6912 KB Output is correct
52 Correct 13 ms 6912 KB Output is correct
53 Correct 13 ms 6912 KB Output is correct
54 Correct 14 ms 6912 KB Output is correct
55 Correct 13 ms 6912 KB Output is correct
56 Correct 13 ms 7168 KB Output is correct
57 Correct 13 ms 6912 KB Output is correct
58 Correct 13 ms 6912 KB Output is correct
59 Incorrect 13 ms 6912 KB Wrong Answer [11]
60 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 903 ms 30784 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -