답안 #1028277

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1028277 2024-07-19T15:46:11 Z serifefedartar CEOI16_icc (CEOI16_icc) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "icc.h"
using namespace std;

#define fast ios::sync_with_stdio(0);cin.tie(0);
mt19937 mt(chrono::system_clock::now().time_since_epoch().count());
typedef long long ll;
#define f first
#define s second
#define LOGN 20
const ll MOD = 1e9 + 7;
const ll MAXN = 105;

int par[MAXN], sz[MAXN], temp1[MAXN], temp2[MAXN];
int find(int node) {
    if (node == par[node])
        return node;
    return par[node] = find(par[node]);
}

void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if (a == b)
        return ;
    if (sz[b] > sz[a])
        swap(a, b);
    sz[a] += sz[b];
    par[b] = a;
}

int qry(int sz1, int sz2, vector<int> A, vector<int> B) {
    for (int i = 0; i < sz1; i++)
        temp1[i] = A[i];
    for (int i = 0; i < sz2; i++)
        temp2[i] = B[i];
    return query(sz1, sz2, temp1, temp2);
}

void match(vector<vector<int>> arr) {
    while (true) {
        random_shuffle(arr.begin(), arr.end(), mt);

        vector<int> A, B;
        for (int i = 0; i < arr.size() / 2; i++) {
            for (auto u : arr[i])
                A.push_back(u);
        }
        for (int i = arr.size() / 2; i < arr.size(); i++) {
            for (auto u : arr[i])
                B.push_back(u);
        }

        if (qry(A.size(), B.size(), A, B)) {
            while ((int)B.size() > 1) {
                vector<int> X, Y;
                for (int i = 0; i < (int)B.size() / 2; i++)
                    X.push_back(B[i]);
                for (int i = (int)B.size() / 2; i < (int)B.size(); i++)
                    Y.push_back(B[i]);

                if (qry(A.size(), X.size(), A, X))
                    B = X;
                else
                    B = Y;
            }

            while ((int)A.size() > 1) {
                vector<int> X, Y;
                for (int i = 0; i < (int)A.size() / 2; i++)
                    X.push_back(A[i]);
                for (int i = (int)A.size() / 2; i < (int)A.size(); i++)
                    Y.push_back(A[i]);

                if (qry(X.size(), 1, X, B))
                    A = X;
                else
                    A = Y;
            }

            setRoad(B[0], A[0]);
            unite(B[0], A[0]);

            return ;
        }
    }
}

int n;
void solve() {
    map<int, vector<int>> mp;
    for (int i = 1; i <= n; i++)
        mp[find(i)].push_back(i);

    vector<vector<int>> temp;
    for (auto u : mp)
        temp.push_back(u.s);

    match(temp);
}

void run(int N) {
    n = N;
    for (int i = 1; i <= N; i++)
        sz[i] = 1, par[i] = i;
    for (int i = 1; i < N; i++)
        solve();
}

Compilation message

icc.cpp: In function 'void match(std::vector<std::vector<int> >)':
icc.cpp:45:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for (int i = 0; i < arr.size() / 2; i++) {
      |                         ~~^~~~~~~~~~~~~~~~
icc.cpp:49:40: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (int i = arr.size() / 2; i < arr.size(); i++) {
      |                                      ~~^~~~~~~~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from icc.cpp:1:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::random_shuffle(_RAIter, _RAIter, _Generator&&) [with _RAIter = __gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >; _Generator = std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>&]':
icc.cpp:42:50:   required from here
/usr/include/c++/10/bits/stl_algo.h:4636:48: error: no match for call to '(std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>) (__gnu_cxx::__normal_iterator<std::vector<int>*, std::vector<std::vector<int> > >::difference_type)'
 4636 |    _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/random:49,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:108,
                 from icc.cpp:1:
/usr/include/c++/10/bits/random.h:563:7: note: candidate: 'std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::operator()() [with _UIntType = long unsigned int; long unsigned int __w = 32; long unsigned int __n = 624; long unsigned int __m = 397; long unsigned int __r = 31; _UIntType __a = 2567483615; long unsigned int __u = 11; _UIntType __d = 4294967295; long unsigned int __s = 7; _UIntType __b = 2636928640; long unsigned int __t = 15; _UIntType __c = 4022730752; long unsigned int __l = 18; _UIntType __f = 1812433253; std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::result_type = long unsigned int]'
  563 |       operator()();
      |       ^~~~~~~~
/usr/include/c++/10/bits/random.h:563:7: note:   candidate expects 0 arguments, 1 provided