제출 #568571

#제출 시각아이디문제언어결과실행 시간메모리
568571stevancvCave (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "cave.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 2e5 + 2;
const int M = 5e5 + 2;
int mod = 1000000007;
void exploreCave(int n) {
    vector<int> ans(n, -1);
    vector<int> sw(n, -1);
    for (int i = 0; i < n; i++) {
        vector<int> tmp(n);
        for (int j = 0; j < n; j++) {
            if (sw[j] == -1) tmp[j] = 0;
            else tmp[j] = sw[j];
        }
        int x = (tryCombination(tmp) == i);
        int l = 0, r = n - 1;
        while (l < r) {
            int mid = l + r >> 1;
            for (int j = 0; j <= mid; j++) {
                if (sw[j] == -1) tmp[j] = 1;
            }
            int y = (tryCombination(tmp) == i);
            if (x == y) l = mid + 1;
            else r = mid;
            for (int j = 0; j <= mid; j++) {
                if (sw[j] == -1) tmp[j] = 0;
            }
        }
        sw[l] = x;
        ans[l] = i;
    }
    answer(sw, ans);
}

컴파일 시 표준 에러 (stderr) 메시지

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:22:33: error: cannot convert 'std::vector<int>' to 'int*'
   22 |         int x = (tryCombination(tmp) == i);
      |                                 ^~~
      |                                 |
      |                                 std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:25:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   25 |             int mid = l + r >> 1;
      |                       ~~^~~
cave.cpp:29:37: error: cannot convert 'std::vector<int>' to 'int*'
   29 |             int y = (tryCombination(tmp) == i);
      |                                     ^~~
      |                                     |
      |                                     std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:39:12: error: cannot convert 'std::vector<int>' to 'int*'
   39 |     answer(sw, ans);
      |            ^~
      |            |
      |            std::vector<int>
In file included from cave.cpp:2:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~