제출 #672818

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

void exploreCave(int n){
	vector<int> pos(n,0);
	vector<int> switched(n,0);
	vector<bool> vis(n,0);
	for(int i = 0;i<n;i++){
		for(int j = 0;j<n;j++){
			if(!vis[j])
				switched[j] = 0;
		}
		int l = 0;
		int r = n-1;
		int x = tryCombination(switched);
		int mid = 0;
		bool flag = 1;
		if(x == i){
			flag = 0;
		}
		while(l<r){
			mid = (l+r) >> 1;
			for(int h = l;h<=mid;h++){
				if(!vis[h])
					switched[h] = flag;
			}
			for(int h = 0;h<l;h++){
				if(!vis[h])
					switched[h] = !flag;
			}
			for(int h = mid+1;h<n;h++){
				if(!vis[h])
					switched[h] = !flag;
			}
			x = tryCombination(switched);
			if(x == i)
				l = mid;
			else r = mid;
		}
		vis[r] = 1;
		pos[r] = i;
		switched[i] = flag; 
	}
	answer(switched,pos);
}

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:16:26: error: cannot convert 'std::vector<int>' to 'int*'
   16 |   int x = tryCombination(switched);
      |                          ^~~~~~~~
      |                          |
      |                          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:36:23: error: cannot convert 'std::vector<int>' to 'int*'
   36 |    x = tryCombination(switched);
      |                       ^~~~~~~~
      |                       |
      |                       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:45:9: error: cannot convert 'std::vector<int>' to 'int*'
   45 |  answer(switched,pos);
      |         ^~~~~~~~
      |         |
      |         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[]);
      |             ~~~~^~~