답안 #372451

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
372451 2021-02-28T08:39:09 Z KoD 카멜레온의 사랑 (JOI20_chameleon) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "chameleon.h"

template <class T>
using Vec = std::vector<T>;

void Solve(int N) {
    Vec<Vec<int>> graph(2 * N + 1);
    if (N <= 50) {
        for (int u = 1; u <= 2 * N; ++u) {
            for (int v = u + 1; v <= 2 * N; ++v) {
                const auto kinds = Query({ u, v });
                if (kinds == 1) {
                    graph[u].push_back(v);
                    graph[v].push_back(u);
                }
            }
        }
    }
    else {
        std::random_device dev;
        std::default_random_engine gen(dev() ^ std::clock());
        for (int u = 1; u <= N; ++u) {
            const auto dif = [&](Vec<int> vec) {
                vec.push_back(u);
                return (int) vec.size() - Query(vec);
            };
            std::queue<std::pair<Vec<int>, int>> que;
            {
                Vec<int> cand(N);
                std::iota(cand.begin(), cand.end(), N + 1);
                que.emplace(cand, dif(cand));
            }
            while (!que.empty()) {
                auto [vec, d] = que.front();
                que.pop();
                if (vec.size() == 1) {
                    const auto v = vec.front();
                    graph[u].push_back(v);
                    graph[v].push_back(u);
                    continue;
                }
                std::shuffle(left.begin(), left.end(), gen);
                Vec<int> left(vec.begin(), vec.begin() + vec.size() / 2);
                Vec<int> right(vec.begin() + vec.size() / 2, vec.end());
                const auto l = dif(left);
                if (l == 0) {
                    que.emplace(right, d);
                }
                else {
                    que.emplace(left, l);
                    if (r != 0) {
                        que.emplace(right, r);
                    }
                }
            }
        }
    }
    Vec<Vec<int>> prob(2 * N + 1, Vec<int>(2 * N + 1));
    for (int u = 1; u <= 2 * N; ++u) {
        if (graph[u].size() == 1) {
            prob[u][graph[u].front()] = true;
        }
        else {
            assert(graph[u].size() == 3);
            for (int ignore = 0; ignore < 3; ++ignore) {
                if (prob[graph[u][ignore]][u] == 2) {
                    continue;
                }
                Vec<int> ask;
                ask.push_back(u);
                for (int k = 0; k < 3; ++k) {
                    if (ignore != k) {
                        ask.push_back(graph[u][k]);
                    }
                }
                if (Query(ask) == 2) {
                    prob[u][graph[u][ignore]] = 1;
                }
                else {
                    prob[u][graph[u][ignore]] = 2;
                }
            }
        }
    }
    for (int u = 1; u <= 2 * N; ++u) {
        for (int v = u + 1; v <= 2 * N; ++v) {
            if (prob[u][v] == 1 && prob[v][u] == 1) {
                Answer(u, v);
            }
        }
    }
}

Compilation message

chameleon.cpp: In function 'void Solve(int)':
chameleon.cpp:43:30: error: 'left' was not declared in this scope; did you mean 'std::left'?
   43 |                 std::shuffle(left.begin(), left.end(), gen);
      |                              ^~~~
      |                              std::left
In file included from /usr/include/c++/9/ios:42,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from chameleon.cpp:1:
/usr/include/c++/9/bits/ios_base.h:1006:3: note: 'std::left' declared here
 1006 |   left(ios_base& __base)
      |   ^~~~
chameleon.cpp:52:25: error: 'r' was not declared in this scope
   52 |                     if (r != 0) {
      |                         ^