제출 #797699

#제출 시각아이디문제언어결과실행 시간메모리
797699XJP12수천개의 섬 (IOI22_islands)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
vector<vector<pair<int,int>>> g;
vector<int> recorrido;
vector<int> vis;
bool ya=false;
void dfs(int u, int pist){
	vis[u]=true;
	for(auto vv: g[u]){
		if(!vis[vv.first]){
			if(ya==true) recorrido.push_back(vv.second);
			if(vv.second=pist){
				ya=true;
			}
			dfs(vv.first,pist);
			if(ya==true) recorrido.pop_back();
		}
	}
}
variant<bool,vector<int>> find_journey(int n, int m, vector<int> u, vector<int> v){
	vi check(1001);
	vector<pair<int,int>> p;
	g.assign(n+1,p);
	vis.assign(n+1,0);
	bool ban=false;
	int pistacho=-1;
	for(int i=0; i<m; i++){
		check[u[i]]++;
		if(check[u[i]]>=3){
			ban=true;
			pistacho=min(pistacho,u[i]);
		}
	}
	if(ban==false){
		return false;
	}

	for(int i=0; i<m; i++){
		g[u[i]].push_back({v[i],i});
	}
	if(pistacho!=0){
		dfs(0,pistacho);
	}
	int a=-1,b=-1,c=-1,d=-1;
	int peanut1=-1, peanut2=-1;
	for(int i=0; i<m; i++){
		if(u[i]==pistacho){
			if(peanut1==-1){
				a=i;
				peanut1=v[i];
			}else{
				b=i;
				peanut2=v[i];
				break;
			}
		}
	}
	for(int i=0; i<m; i++){
		if(u[i]==peanut1){
			if(v[i]==0){
				c=i;
				break;
			}
		}
	}
	for(int i=0; i<m; i++){
		if(u[i]==peanut2){
			if(v[i]==0){
				d=i;
				break;
			}
		}
	}
	vector<int> x(8);
	x={a,c,b,d,c,a,d,b};
	recorrido.push_back(x);
	return recorrido;
	
}

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

islands.cpp: In function 'void dfs(int, int)':
islands.cpp:15:16: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   15 |    if(vv.second=pist){
      |       ~~~~~~~~~^~~~~
islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:79:23: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
   79 |  recorrido.push_back(x);
      |                       ^
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from islands.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~