Submission #367251

# Submission time Handle Problem Language Result Execution time Memory
367251 2021-02-16T16:58:56 Z mihai145 ICC (CEOI16_icc) C++14
Compilation error
0 ms 0 KB
//
// Created by mihai145 on 16.02.2021.
//

#include <vector>
#include <cmath>
#include "icc.h"

using namespace std;

const int NMAX = 100;
int comp[NMAX + 2];

void run(int N) {
    for(int i = 1; i <= N; i++) {
        comp[i] = i - 1;
    }

    for(int c = N; c > 1; c--) {
        int log = log2(c);

        vector<int> A, B;

        for(int bit = 0; bit <= log; bit++) {
            vector<int> a, b;
            for(int i = 1; i <= N; i++) {
                if (comp[i] & (1 << bit))
                    a.push_back(i);
                else
                    b.push_back(i);
            }

            int q = query((int)a.size(), (int)b.size(), a, b);
            if(q) {
                A = a;
                B = b;
                break;
            }
        }

        for(int step = 1; step <= 2; step++) {
            while((int)A.size() > 1) {
                vector<int> A1, A2;
                for(int i = 0; i < (int)A.size(); i++) {
                    if(i % 2 == 0) {
                        A1.push_back(A[i]);
                    } else {
                        A2.push_back(A[i]);
                    }
                }

                int q = query((int)A1.size(), (int)B.size(), A1, B);

                if(q) {
                    A = A1;
                } else {
                    A = A2;
                }
            }

            swap(A, B);
        }

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

        int cA = comp[A[0]], cB = comp[B[0]];

        for(int i = 1; i <= N; i++)
            if(comp[i] == cA) {
                comp[i] = cB;
            }
    }
}

Compilation message

icc.cpp: In function 'void run(int)':
icc.cpp:33:57: error: cannot convert 'std::vector<int>' to 'int*'
   33 |             int q = query((int)a.size(), (int)b.size(), a, b);
      |                                                         ^
      |                                                         |
      |                                                         std::vector<int>
In file included from icc.cpp:7:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^
icc.cpp:52:62: error: cannot convert 'std::vector<int>' to 'int*'
   52 |                 int q = query((int)A1.size(), (int)B.size(), A1, B);
      |                                                              ^~
      |                                                              |
      |                                                              std::vector<int>
In file included from icc.cpp:7:
icc.h:10:30: note:   initializing argument 3 of 'int query(int, int, int*, int*)'
   10 | int query(int a, int b, int *A, int *B);
      |                         ~~~~~^