제출 #1310661

#제출 시각아이디문제언어결과실행 시간메모리
1310661nikoloz-ch동굴 (IOI13_cave)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;

vector<int> s;

void exploreCave(int N){
    s.resize(N);
    for(int i = 0; i < N; i++) s[i] = -1;
    for(int i = 0; i < N; i++){
        auto p = s; bool tr = true;
        for(int j = 0; j < N; j++)
            if(s[j] == -1) s[j] = 1;
        int t = tryCombination(p);
        if(t >= i+1) tr = !tr;
        int l = 0, r = 0, ans = 0;
        while(l < r){
            int m = (l+r)/2; auto pt = s;
            for(int j = 0; j < m; j++)
                if(pt[j] == -1) pt[j] = (tr ? 1 : 0);
            int d = tryCombination(pt);
            if(d >= i+1) l = m;
            else r = m;
            if(l == r-1){
                ans = m;
                break;
            }
        }
        s[ans] = (tr ? 1 : 0);
    }
}

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:14:32: error: cannot convert 'std::vector<int>' to 'int*'
   14 |         int t = tryCombination(p);
      |                                ^
      |                                |
      |                                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:21:36: error: cannot convert 'std::vector<int>' to 'int*'
   21 |             int d = tryCombination(pt);
      |                                    ^~
      |                                    |
      |                                    std::vector<int>
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~