답안 #372438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
372438 2021-02-28T07:59:58 Z Lam_lai_cuoc_doi 항공 노선도 (JOI18_airline) C++17
컴파일 오류
0 ms 0 KB
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);
}
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:1:26: error: 'vector' has not been declared
    1 | void Alice(int n, int m, vector<int> a, vector<int> b)
      |                          ^~~~~~
Alice.cpp:1:32: error: expected ',' or '...' before '<' token
    1 | void Alice(int n, int m, vector<int> a, vector<int> b)
      |                                ^
Alice.cpp: In function 'void Alice(int, int, int)':
Alice.cpp:3:5: error: 'vector' was not declared in this scope
    3 |     vector<pair<int, int>> s;
      |     ^~~~~~
Alice.cpp:3:12: error: 'pair' was not declared in this scope
    3 |     vector<pair<int, int>> s;
      |            ^~~~
Alice.cpp:3:17: error: expected primary-expression before 'int'
    3 |     vector<pair<int, int>> s;
      |                 ^~~
Alice.cpp:5:9: error: 's' was not declared in this scope
    5 |         s.emplace_back(a[i], b[i]);
      |         ^
Alice.cpp:5:24: error: 'a' was not declared in this scope
    5 |         s.emplace_back(a[i], b[i]);
      |                        ^
Alice.cpp:5:30: error: 'b' was not declared in this scope
    5 |         s.emplace_back(a[i], b[i]);
      |                              ^
Alice.cpp:9:17: error: 'bit' was not declared in this scope
    9 |             if (bit(j, i))
      |                 ^~~
Alice.cpp:10:17: error: 's' was not declared in this scope
   10 |                 s.emplace_back(n + j, i);
      |                 ^
Alice.cpp:12:13: error: 's' was not declared in this scope
   12 |             s.emplace_back(j, j + 1);
      |             ^
Alice.cpp:15:9: error: 's' was not declared in this scope
   15 |         s.emplace_back(n + 10, i);
      |         ^
Alice.cpp:17:9: error: 's' was not declared in this scope
   17 |         s.emplace_back(n + 11, i);
      |         ^
Alice.cpp:18:19: error: 's' was not declared in this scope
   18 |     InitG(n + 12, s.size());
      |                   ^
Alice.cpp:18:5: error: 'InitG' was not declared in this scope
   18 |     InitG(n + 12, s.size());
      |     ^~~~~
Alice.cpp:20:9: error: 'MakeG' was not declared in this scope
   20 |         MakeG(i.first, i.second);
      |         ^~~~~

Bob.cpp:1:24: error: 'vector' has not been declared
    1 | void Bob(int n, int m, vector<int> a, vector<int> b)
      |                        ^~~~~~
Bob.cpp:1:30: error: expected ',' or '...' before '<' token
    1 | void Bob(int n, int m, vector<int> a, vector<int> b)
      |                              ^
Bob.cpp: In function 'void Bob(int, int, int)':
Bob.cpp:4:5: error: 'vector' was not declared in this scope
    4 |     vector<vector<bool>> adj(n, vector<bool>(n));
      |     ^~~~~~
Bob.cpp:4:19: error: expected primary-expression before 'bool'
    4 |     vector<vector<bool>> adj(n, vector<bool>(n));
      |                   ^~~~
Bob.cpp:5:12: error: 'pair' was not declared in this scope
    5 |     vector<pair<int, int>> s;
      |            ^~~~
Bob.cpp:5:17: error: expected primary-expression before 'int'
    5 |     vector<pair<int, int>> s;
      |                 ^~~
Bob.cpp:6:12: error: expected primary-expression before 'int'
    6 |     vector<int> cnt(n), real(n), son(n), obit, dep(n), pos(10), tmp;
      |            ^~~
Bob.cpp:9:9: error: 'adj' was not declared in this scope
    9 |         adj[a[i]][b[i]] = 1;
      |         ^~~
Bob.cpp:9:13: error: 'a' was not declared in this scope
    9 |         adj[a[i]][b[i]] = 1;
      |             ^
Bob.cpp:9:19: error: 'b' was not declared in this scope
    9 |         adj[a[i]][b[i]] = 1;
      |                   ^
Bob.cpp:10:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
   10 |         ++cnt[a[i]];
      |           ^~~
      |           int
Bob.cpp:16:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   16 |         if (cnt[i] == n - 1)
      |             ^~~
      |             int
Bob.cpp:19:32: error: 'adj' was not declared in this scope
   19 |                 if (i != j && !adj[i][j] && cnt[j] == n - 12)
      |                                ^~~
Bob.cpp: In lambda function:
Bob.cpp:30:14: error: 'dep' was not declared in this scope
   30 |         fill(dep.begin(), dep.end(), 0);
      |              ^~~
Bob.cpp:30:9: error: 'fill' was not declared in this scope
   30 |         fill(dep.begin(), dep.end(), 0);
      |         ^~~~
Bob.cpp:32:9: error: 'queue' was not declared in this scope
   32 |         queue<int> q;
      |         ^~~~~
Bob.cpp:32:15: error: expected primary-expression before 'int'
   32 |         queue<int> q;
      |               ^~~
Bob.cpp:33:9: error: 'q' was not declared in this scope
   33 |         q.emplace(v);
      |         ^
Bob.cpp:38:13: error: 'pos' was not declared in this scope
   38 |             pos[dep[c] - 1] = c;
      |             ^~~
Bob.cpp:39:27: error: 'obit' was not declared in this scope
   39 |             for (auto i : obit)
      |                           ^~~~
Bob.cpp:40:32: error: 'adj' was not declared in this scope
   40 |                 if (!dep[i] && adj[c][i])
      |                                ^~~
Bob.cpp:42:23: error: 'son' was not declared in this scope
   42 |                     ++son[c];
      |                       ^~~
Bob.cpp: In function 'void Bob(int, int, int)':
Bob.cpp:48:26: error: 'adj' was not declared in this scope
   48 |         if (i != elv && !adj[ten][i])
      |                          ^~~
Bob.cpp:49:13: error: 'obit' was not declared in this scope
   49 |             obit.emplace_back(i);
      |             ^~~~
Bob.cpp:50:9: error: 'obit' was not declared in this scope
   50 |     bfs(obit[0]);
      |         ^~~~
Bob.cpp:52:13: error: 'son' was not declared in this scope
   52 |         if (son[i] == 0)
      |             ^~~
Bob.cpp:53:13: error: 'tmp' was not declared in this scope
   53 |             tmp.emplace_back(i);
      |             ^~~
Bob.cpp:54:9: error: 'tmp' was not declared in this scope
   54 |     if (tmp.size() == 1)
      |         ^~~
Bob.cpp:55:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   55 |         bfs(cnt[tmp.back()] > cnt[obit[0]] ? tmp.back() : obit[0]);
      |             ^~~
      |             int
Bob.cpp:57:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
   57 |         bfs(cnt[tmp[0]] > cnt[tmp[1]] ? tmp[0] : tmp[1]);
      |             ^~~
      |             int
Bob.cpp:60:17: error: 'adj' was not declared in this scope
   60 |             if (adj[pos[i]][j])
      |                 ^~~
Bob.cpp:60:21: error: 'pos' was not declared in this scope
   60 |             if (adj[pos[i]][j])
      |                     ^~~
Bob.cpp:61:17: error: 'real' was not declared in this scope
   61 |                 real[j] |= 1 << i;
      |                 ^~~~
Bob.cpp:63:13: error: 'adj' was not declared in this scope
   63 |         if (adj[ten][i])
      |             ^~~
Bob.cpp:66:21: error: 's' was not declared in this scope
   66 |                     s.emplace_back(real[i], real[j]);
      |                     ^
Bob.cpp:66:36: error: 'real' was not declared in this scope
   66 |                     s.emplace_back(real[i], real[j]);
      |                                    ^~~~
Bob.cpp:67:19: error: 's' was not declared in this scope
   67 |     InitG(n - 12, s.size());
      |                   ^
Bob.cpp:67:5: error: 'InitG' was not declared in this scope
   67 |     InitG(n - 12, s.size());
      |     ^~~~~
Bob.cpp:69:9: error: 'MakeG' was not declared in this scope
   69 |         MakeG(i.first, i.second);
      |         ^~~~~
Bob.cpp:3:27: warning: unused variable 'nin' [-Wunused-variable]
    3 |     int ten(-1), elv(-1), nin(-1), zer(-1);
      |                           ^~~
Bob.cpp:3:36: warning: unused variable 'zer' [-Wunused-variable]
    3 |     int ten(-1), elv(-1), nin(-1), zer(-1);
      |                                    ^~~