제출 #832215

#제출 시각아이디문제언어결과실행 시간메모리
832215tranxuanbachSplit the Attractions (IOI19_split)C++17
컴파일 에러
0 ms0 KiB
#include "split.h"

#include <bits/stdc++.h>
using namespace std;

#define isz(a) ((signed)a.size())

const int N = 1e5 + 5, M = 2e5 + 5;

int n, m;
vector <pair <int, int>> vcolor;
vector <int> adj[N];

vector <int> ans;

namespace subtask12{
	bool check(){
		for (auto &[cnt, col]: vcolor){
			if (col == 1 and cnt == 1){
				return true;
			}
		}
		for (int u = 0; u < n; u++){
			if (isz(adj[u]) > 2){
				return false;
			}
		}
		return true;
	}

	vector <bool> chosen;

	void dfs(int u){
		chosen[u] = true;
		ans[u] = vcolor.back().second;
		vcolor.back().first--;
		if (vcolor.back().first == 0){
			vcolor.pop_back();
		}
		for (auto v: adj[u]){
			if (chosen[v]){
				continue;
			}
			dfs(v);
		}
	}

	vector <int> solve(){
		chosen.assign(n, false);

		int s = 0;
		for (int u = 1; u < n; u++){
			if (isz(adj[u]) == 1){
				s = u;
				break;
			}
		}
		dfs(s);
		return ans;
	}
}

vector <int> find_split(int _n, int _a, int _b, int _c, vector <int> _u, vector <int> _v){
	n = _n; m = isz(_u);
	vcolor = {{a, 1}, {b, 2}, {c, 3}};
	sort(vcolor.begin(), vcolor.end());
	for (int i = 0; i < m; i++){
		int u = _u[i], v = _v[i];
		adj[u].emplace_back(v);
		adj[v].emplace_back(u);
	}
	ans.assign(n, 0);

	if (subtask12::check()){
		return subtask12::solve();
	}
}

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

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:65:13: error: 'a' was not declared in this scope; did you mean '_a'?
   65 |  vcolor = {{a, 1}, {b, 2}, {c, 3}};
      |             ^
      |             _a
split.cpp:65:21: error: 'b' was not declared in this scope; did you mean '_b'?
   65 |  vcolor = {{a, 1}, {b, 2}, {c, 3}};
      |                     ^
      |                     _b
split.cpp:65:29: error: 'c' was not declared in this scope; did you mean '_c'?
   65 |  vcolor = {{a, 1}, {b, 2}, {c, 3}};
      |                             ^
      |                             _c
split.cpp:65:34: error: no match for 'operator=' (operand types are 'std::vector<std::pair<int, int> >' and '<brace-enclosed initializer list>')
   65 |  vcolor = {{a, 1}, {b, 2}, {c, 3}};
      |                                  ^
In file included from /usr/include/c++/10/vector:72,
                 from split.h:5,
                 from split.cpp:1:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from split.h:5,
                 from split.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::initializer_list<std::pair<int, int> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
split.cpp:77:1: warning: control reaches end of non-void function [-Wreturn-type]
   77 | }
      | ^