Submission #891401

# Submission time Handle Problem Language Result Execution time Memory
891401 2023-12-22T21:14:28 Z boris_mihov Airline Route Map (JOI18_airline) C++17
37 / 100
439 ms 53116 KB
#include "Alicelib.h"
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>

typedef long long llong;
const int MAXN = 1000 + 10;
const int INF  = 1e9;

std::vector <std::pair <int,int>> newG;

void Alice (int N, int M, int A[], int B[] )
{
    for (int i = 0 ; i < M ; ++i)
    {
        newG.push_back({A[i], B[i]});
    }

    if (N <= 2)
    {
        InitG(N, newG.size());
        for (int i = 0 ; i < newG.size() ; ++i)
        {
            MakeG(i, newG[i].first, newG[i].second);
        }

        return;
    }
    
    int log = 10;
    for (int i = 0 ; i < N ; ++i)
    {
        for (int bit = 0 ; bit < log ; ++bit)
        {
            if (i & (1 << bit))
            {
                newG.push_back({i, N + bit});
            }
        }
    }

    for (int bit = 0 ; bit < log ; ++bit)
    {
        newG.push_back({N + log, N + bit});
    }

    for (int bit = 0 ; bit + 1 < log ; ++bit)
    {
        newG.push_back({N + bit, N + bit + 1});
    }

    newG.push_back({N + log + 1, N});
    for (int i = 0 ; i < N + log ; ++i)
    {
        newG.push_back({N + log + 2, i});
    }

    InitG(N + log + 3, newG.size());
    for (int i = 0 ; i < newG.size() ; ++i)
    {
        MakeG(i, newG[i].first, newG[i].second);
    }

    return;
}

#include "Boblib.h"
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>

typedef long long llong;
const int MAXN = 1012 + 10;
const int INF  = 1e9;

int number[MAXN];
bool inReal[MAXN];
bool connected[MAXN][MAXN];
std::vector <std::pair <int,int>> edges;
std::vector <int> g[MAXN];
std::vector <int> logs;
int realLog[MAXN];
bool isLog[MAXN];
int deg[MAXN];

void dfs(int node, int par)
{
    logs.push_back(node);
    for (const int &u : g[node])
    {
        if (u == par)
        {
            continue;
        }

        if (isLog[u])
        {
            dfs(u, node);
        }
    }
}

void Bob( int V, int U, int C[], int D[] )
{
    if (V <= 2)
    {
        if (U == 0)
        {
            InitMap(V, 0);
        } else
        {
            InitMap(V, 1);
            MakeMap(0, 1);
        }
        
        return;
    }
    
    for (int i = 0 ; i < U ; ++i)
    {
        g[C[i]].push_back(D[i]);
        g[D[i]].push_back(C[i]);
        deg[C[i]]++; deg[D[i]]++;
        connected[C[i]][D[i]] = true;
        connected[D[i]][C[i]] = true;
    }

    for (int i = 0 ; i < U ; ++i)
    {
        inReal[i] = true;
    }

    int log = 10;
    int n = V - log - 3;
    int root = -1;

    for (int i = 0 ; i < V ; ++i)
    {
        if (deg[i] == V - 3)
        {
            root = i;
        }
    }

    assert(root != -1);
    int source = -1;
    int pointing = -1;

    for (int i = 0 ; i < V ; ++i)
    {
        if (i != root && !connected[i][root] && deg[i] == 1)
        {
            while (pointing != -1);
            pointing = i;
        }

        if (i != root && !connected[i][root] && deg[i] == log)
        {
            while (source != -1);
            source = i;
        }
    }

    assert(source != -1);
    assert(pointing != -1);
    for (const int &u : g[source])
    {
        isLog[u] = true;
    }

    dfs(g[pointing][0], -1);
    assert(logs.size() == log);
    for (int i = 0 ; i < log ; ++i)
    {
        inReal[logs[i]] = false;
        realLog[logs[i]] = i;
    }
    
    inReal[root] = false;
    inReal[source] = false;
    inReal[pointing] = false;

    for (int i = 0 ; i < V ; ++i)
    {
        if (!inReal[i])
        {
            continue;
        }

        for (int j = 0 ; j < log ; ++j)
        {
            if (connected[i][logs[j]])
            {
                number[i] |= (1 << j);
            }
        }
    }

    for (int i = 0 ; i < V ; ++i)
    {
        for (int j = i + 1 ; j < V ; ++j)
        {
            if (!inReal[i] || !inReal[j] || !connected[i][j])
            {
                continue;
            }

            edges.push_back({number[i], number[j]});
        }
    }

    InitMap(n, edges.size());
    for (int i = 0 ; i < edges.size() ; ++i)
    {
        MakeMap(edges[i].first, edges[i].second);
    }

    return;
}

Compilation message

Alice.cpp: In function 'void Alice(int, int, int*, int*)':
Alice.cpp:23:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for (int i = 0 ; i < newG.size() ; ++i)
      |                          ~~^~~~~~~~~~~~~
Alice.cpp:60:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for (int i = 0 ; i < newG.size() ; ++i)
      |                      ~~^~~~~~~~~~~~~

In file included from /usr/include/c++/10/cassert:44,
                 from Bob.cpp:4:
Bob.cpp: In function 'void Bob(int, int, int*, int*)':
Bob.cpp:107:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  107 |     assert(logs.size() == log);
      |            ~~~~~~~~~~~~^~~~~~
Bob.cpp:148:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  148 |     for (int i = 0 ; i < edges.size() ; ++i)
      |                      ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 17668 KB Output is correct
2 Correct 2 ms 17664 KB Output is correct
3 Correct 2 ms 17684 KB Output is correct
4 Correct 2 ms 15620 KB Output is correct
5 Correct 2 ms 17668 KB Output is correct
6 Correct 2 ms 17668 KB Output is correct
7 Correct 3 ms 17668 KB Output is correct
8 Correct 2 ms 17668 KB Output is correct
9 Correct 2 ms 17668 KB Output is correct
10 Correct 2 ms 15620 KB Output is correct
11 Correct 2 ms 17668 KB Output is correct
12 Correct 2 ms 17668 KB Output is correct
13 Correct 2 ms 17668 KB Output is correct
14 Correct 2 ms 17844 KB Output is correct
15 Correct 2 ms 17668 KB Output is correct
16 Correct 2 ms 17668 KB Output is correct
17 Correct 2 ms 17668 KB Output is correct
18 Correct 2 ms 17668 KB Output is correct
19 Correct 3 ms 17664 KB Output is correct
20 Correct 2 ms 17668 KB Output is correct
21 Correct 3 ms 17640 KB Output is correct
22 Correct 2 ms 17664 KB Output is correct
23 Correct 3 ms 17668 KB Output is correct
24 Correct 2 ms 15624 KB Output is correct
25 Correct 2 ms 17500 KB Output is correct
26 Correct 2 ms 17668 KB Output is correct
27 Correct 2 ms 17668 KB Output is correct
28 Correct 3 ms 17668 KB Output is correct
29 Correct 3 ms 17668 KB Output is correct
30 Correct 2 ms 15616 KB Output is correct
31 Correct 2 ms 15616 KB Output is correct
32 Correct 2 ms 15620 KB Output is correct
33 Correct 2 ms 15868 KB Output is correct
34 Correct 3 ms 15616 KB Output is correct
35 Correct 2 ms 15624 KB Output is correct
36 Correct 2 ms 17664 KB Output is correct
37 Correct 2 ms 17668 KB Output is correct
38 Correct 3 ms 17668 KB Output is correct
39 Correct 2 ms 17668 KB Output is correct
40 Correct 2 ms 17508 KB Output is correct
41 Correct 3 ms 17668 KB Output is correct
42 Correct 3 ms 17664 KB Output is correct
43 Correct 3 ms 17668 KB Output is correct
44 Correct 2 ms 15616 KB Output is correct
45 Correct 2 ms 15620 KB Output is correct
46 Correct 2 ms 17668 KB Output is correct
47 Correct 2 ms 17664 KB Output is correct
48 Correct 3 ms 17668 KB Output is correct
49 Correct 3 ms 17660 KB Output is correct
50 Correct 2 ms 15620 KB Output is correct
51 Correct 2 ms 11524 KB Output is correct
52 Correct 2 ms 17668 KB Output is correct
53 Correct 2 ms 11520 KB Output is correct
54 Correct 3 ms 17664 KB Output is correct
55 Correct 2 ms 17668 KB Output is correct
56 Correct 2 ms 17664 KB Output is correct
57 Correct 3 ms 17668 KB Output is correct
58 Correct 3 ms 17668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 17668 KB Output is correct
2 Correct 2 ms 17664 KB Output is correct
3 Correct 2 ms 17684 KB Output is correct
4 Correct 2 ms 15620 KB Output is correct
5 Correct 2 ms 17668 KB Output is correct
6 Correct 2 ms 17668 KB Output is correct
7 Correct 3 ms 17668 KB Output is correct
8 Correct 2 ms 17668 KB Output is correct
9 Correct 2 ms 17668 KB Output is correct
10 Correct 2 ms 15620 KB Output is correct
11 Correct 2 ms 17668 KB Output is correct
12 Correct 2 ms 17668 KB Output is correct
13 Correct 2 ms 17668 KB Output is correct
14 Correct 2 ms 17844 KB Output is correct
15 Correct 2 ms 17668 KB Output is correct
16 Correct 2 ms 17668 KB Output is correct
17 Correct 2 ms 17668 KB Output is correct
18 Correct 2 ms 17668 KB Output is correct
19 Correct 3 ms 17664 KB Output is correct
20 Correct 2 ms 17668 KB Output is correct
21 Correct 3 ms 17640 KB Output is correct
22 Correct 2 ms 17664 KB Output is correct
23 Correct 3 ms 17668 KB Output is correct
24 Correct 2 ms 15624 KB Output is correct
25 Correct 2 ms 17500 KB Output is correct
26 Correct 2 ms 17668 KB Output is correct
27 Correct 2 ms 17668 KB Output is correct
28 Correct 3 ms 17668 KB Output is correct
29 Correct 3 ms 17668 KB Output is correct
30 Correct 2 ms 15616 KB Output is correct
31 Correct 2 ms 15616 KB Output is correct
32 Correct 2 ms 15620 KB Output is correct
33 Correct 2 ms 15868 KB Output is correct
34 Correct 3 ms 15616 KB Output is correct
35 Correct 2 ms 15624 KB Output is correct
36 Correct 2 ms 17664 KB Output is correct
37 Correct 2 ms 17668 KB Output is correct
38 Correct 3 ms 17668 KB Output is correct
39 Correct 2 ms 17668 KB Output is correct
40 Correct 2 ms 17508 KB Output is correct
41 Correct 3 ms 17668 KB Output is correct
42 Correct 3 ms 17664 KB Output is correct
43 Correct 3 ms 17668 KB Output is correct
44 Correct 2 ms 15616 KB Output is correct
45 Correct 2 ms 15620 KB Output is correct
46 Correct 2 ms 17668 KB Output is correct
47 Correct 2 ms 17664 KB Output is correct
48 Correct 3 ms 17668 KB Output is correct
49 Correct 3 ms 17660 KB Output is correct
50 Correct 2 ms 15620 KB Output is correct
51 Correct 2 ms 11524 KB Output is correct
52 Correct 2 ms 17668 KB Output is correct
53 Correct 2 ms 11520 KB Output is correct
54 Correct 3 ms 17664 KB Output is correct
55 Correct 2 ms 17668 KB Output is correct
56 Correct 2 ms 17664 KB Output is correct
57 Correct 3 ms 17668 KB Output is correct
58 Correct 3 ms 17668 KB Output is correct
59 Correct 3 ms 17664 KB Output is correct
60 Correct 3 ms 17664 KB Output is correct
61 Correct 3 ms 17668 KB Output is correct
62 Correct 2 ms 17668 KB Output is correct
63 Correct 2 ms 17668 KB Output is correct
64 Correct 3 ms 17668 KB Output is correct
65 Correct 3 ms 17668 KB Output is correct
66 Correct 3 ms 17668 KB Output is correct
67 Correct 2 ms 17668 KB Output is correct
68 Correct 2 ms 17668 KB Output is correct
69 Correct 2 ms 17664 KB Output is correct
70 Correct 3 ms 17668 KB Output is correct
71 Correct 3 ms 17668 KB Output is correct
72 Correct 3 ms 17664 KB Output is correct
73 Correct 3 ms 17668 KB Output is correct
74 Correct 3 ms 17664 KB Output is correct
75 Correct 2 ms 17920 KB Output is correct
76 Correct 3 ms 17668 KB Output is correct
77 Correct 3 ms 17660 KB Output is correct
78 Correct 3 ms 17668 KB Output is correct
79 Correct 2 ms 17668 KB Output is correct
80 Correct 2 ms 17668 KB Output is correct
81 Correct 3 ms 17668 KB Output is correct
82 Correct 2 ms 17672 KB Output is correct
83 Correct 2 ms 17668 KB Output is correct
84 Correct 3 ms 17668 KB Output is correct
85 Correct 3 ms 17668 KB Output is correct
86 Correct 3 ms 17668 KB Output is correct
87 Correct 3 ms 17640 KB Output is correct
88 Correct 2 ms 17660 KB Output is correct
89 Correct 2 ms 15620 KB Output is correct
90 Correct 2 ms 15616 KB Output is correct
91 Correct 2 ms 15620 KB Output is correct
92 Correct 3 ms 15616 KB Output is correct
93 Correct 2 ms 15616 KB Output is correct
94 Correct 3 ms 17664 KB Output is correct
95 Correct 3 ms 17668 KB Output is correct
96 Correct 3 ms 17668 KB Output is correct
97 Correct 3 ms 17668 KB Output is correct
98 Correct 3 ms 17668 KB Output is correct
99 Correct 3 ms 17668 KB Output is correct
100 Correct 3 ms 17664 KB Output is correct
101 Correct 2 ms 17668 KB Output is correct
102 Correct 2 ms 15620 KB Output is correct
103 Correct 3 ms 17664 KB Output is correct
104 Correct 2 ms 17668 KB Output is correct
105 Correct 2 ms 17668 KB Output is correct
106 Correct 3 ms 17916 KB Output is correct
107 Correct 3 ms 17668 KB Output is correct
108 Correct 3 ms 17668 KB Output is correct
109 Correct 3 ms 17668 KB Output is correct
110 Correct 3 ms 17664 KB Output is correct
111 Correct 3 ms 17668 KB Output is correct
112 Correct 2 ms 17668 KB Output is correct
113 Correct 3 ms 17668 KB Output is correct
114 Correct 2 ms 17668 KB Output is correct
115 Correct 3 ms 17668 KB Output is correct
116 Correct 2 ms 17668 KB Output is correct
117 Correct 3 ms 17924 KB Output is correct
118 Correct 3 ms 17668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 439 ms 53116 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -