Submission #372440

# Submission time Handle Problem Language Result Execution time Memory
372440 2021-02-28T08:01:47 Z Lam_lai_cuoc_doi Airline Route Map (JOI18_airline) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define bit(i, x) (((x) >> (i)) & 1)
void Alice(int n, int m, vector<int> a, vector<int> b)
{
    vector<pair<int, int>> s;
    for (int i = 0; i < m; ++i)
        s.emplace_back(a[i], b[i]);
    for (int j = 0; j < 10; ++j)
    {
        for (int i = 0; i < n; ++i)
            if (bit(j, i))
                s.emplace_back(n + j, i);
        if (j + 1 < 10)
            s.emplace_back(j, j + 1);
    }
    for (int i = 0; i < n; ++i)
        s.emplace_back(n + 10, i);
    for (int i = 0; i < n + 10; ++i)
        s.emplace_back(n + 11, i);
    InitG(n + 12, s.size());
    for (auto i : s)
        MakeG(i.first, i.second);
}
#include <bits/stdc++.h>
using namespace std;
#define bit(i, x) (((x) >> (i)) & 1)
void Bob(int n, int m, vector<int> a, vector<int> b)
{
    int ten(-1), elv(-1), nin(-1), zer(-1);
    vector<vector<bool>> adj(n, vector<bool>(n));
    vector<pair<int, int>> s;
    vector<int> cnt(n), real(n), son(n), obit, dep(n), pos(10), tmp;
    for (int i = 0; i < m; ++i)
    {
        adj[a[i]][b[i]] = 1;
        ++cnt[a[i]];
        adj[b[i]][a[i]] = 1;
        ++cnt[b[i]];
    }
    /// Find elevent and ten
    for (int i = 0; i < n; ++i)
        if (cnt[i] == n - 1)
        {
            for (int j = 0; j < n; ++j)
                if (i != j && !adj[i][j] && cnt[j] == n - 12)
                {
                    ten = j;
                    elv = i;
                    break;
                }
            if (ten != -1)
                break;
        }
    /// find bit
    auto bfs = [&](int v) {
        fill(dep.begin(), dep.end(), 0);
        dep[v] = 1;
        queue<int> q;
        q.emplace(v);
        while (q.size())
        {
            int c = q.front();
            q.pop();
            pos[dep[c] - 1] = c;
            for (auto i : obit)
                if (!dep[i] && adj[c][i])
                {
                    ++son[c];
                    dep[i] = dep[v] + 1;
                }
        }
    };
    for (int i = 0; i < n; ++i)
        if (i != elv && !adj[ten][i])
            obit.emplace_back(i);
    bfs(obit[0]);
    for (auto i : obit)
        if (son[i] == 0)
            tmp.emplace_back(i);
    if (tmp.size() == 1)
        bfs(cnt[tmp.back()] > cnt[obit[0]] ? tmp.back() : obit[0]);
    else
        bfs(cnt[tmp[0]] > cnt[tmp[1]] ? tmp[0] : tmp[1]);
    for (int i = 0; i < 10; ++i)
        for (int j = 0; j < n; ++j)
            if (adj[pos[i]][j])
                real[j] |= 1 << i;
    for (int i = 0; i < n; ++i)
        if (adj[ten][i])
            for (int j = i + 1; j < n; ++j)
                if (adj[ten][j])
                    s.emplace_back(real[i], real[j]);
    InitG(n - 12, s.size());
    for (auto i : s)
        MakeG(i.first, i.second);
}

Compilation message

Alice.cpp: In function 'void Alice(int, int, std::vector<int>, std::vector<int>)':
Alice.cpp:21:5: error: 'InitG' was not declared in this scope
   21 |     InitG(n + 12, s.size());
      |     ^~~~~
Alice.cpp:23:9: error: 'MakeG' was not declared in this scope
   23 |         MakeG(i.first, i.second);
      |         ^~~~~

Bob.cpp: In function 'void Bob(int, int, std::vector<int>, std::vector<int>)':
Bob.cpp:70:5: error: 'InitG' was not declared in this scope
   70 |     InitG(n - 12, s.size());
      |     ^~~~~
Bob.cpp:72:9: error: 'MakeG' was not declared in this scope
   72 |         MakeG(i.first, i.second);
      |         ^~~~~
Bob.cpp:6:27: warning: unused variable 'nin' [-Wunused-variable]
    6 |     int ten(-1), elv(-1), nin(-1), zer(-1);
      |                           ^~~
Bob.cpp:6:36: warning: unused variable 'zer' [-Wunused-variable]
    6 |     int ten(-1), elv(-1), nin(-1), zer(-1);
      |                                    ^~~