답안 #955580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
955580 2024-03-31T04:06:24 Z ono_de206 Toxic Gene (NOI23_toxic) C++17
컴파일 오류
0 ms 0 KB
#include "toxic.h"
#include<bits/stdc++.h>
using namespace std;

#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

//#define int long long

typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

void determine_type(int n) {
	vector<int> type(n + 1, -1);
	auto dfs = [&](auto &self, int l, int r) {
		vector<int> ask(r - l + 1);
		iota(all(ask), l);
		if(query_sample(ask) == r - l + 1) return;
		if(l == r) type[l] = 1;
		else {
			int m = (l + r) / 2;
			self(self, l, m);
			self(self, m + 1, r);
		}
	};
	dfs(dfs, 1, n);
	vector<int> non;
	int samp;
	for(int i = 1; i <= n; i++) {
		if(type[i] == -1) non.pb(i);
		else samp = i;
	}
	for(int l = 0, r; l < non.size(); l = r) {
		r = min((int)non.size(), l + 7);
		vector<int> ask{samp};
		for(int j = l; j < r; j++) {
			int cnt = (1 << (j - l));
			ask.in(ask.end(), vector<int>(cnt, non[j]));
		}
		int ans = query_sample(ask);
		for(int j = l; j < r; j++) {
			int cnt = (1 << (j - l));
			if(ans & cnt) type[non[j]] = 0;
			else type[non[j]] = 2;
		}
	}
	string str = "STR";
	for(int i = 1; i <= n; i++) {
		answer_type(i, str[type[i]]);
	}
}

Compilation message

toxic.cpp: In function 'void determine_type(int)':
toxic.cpp:41:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int l = 0, r; l < non.size(); l = r) {
      |                    ~~^~~~~~~~~~~~
toxic.cpp:46:46: error: no matching function for call to 'std::vector<int>::insert(std::vector<int>::iterator, std::vector<int>)'
   46 |    ask.in(ask.end(), vector<int>(cnt, non[j]));
      |                                              ^
In file included from /usr/include/c++/10/vector:72,
                 from toxic.h:1,
                 from toxic.cpp:1:
/usr/include/c++/10/bits/vector.tcc:130:5: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
  130 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:132:57: note:   no known conversion for argument 2 from 'std::vector<int>' to 'const value_type&' {aka 'const int&'}
  132 |     insert(const_iterator __position, const value_type& __x)
      |                                       ~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from toxic.h:1,
                 from toxic.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1293:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::value_type = int]'
 1293 |       insert(const_iterator __position, value_type&& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1293:54: note:   no known conversion for argument 2 from 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1293 |       insert(const_iterator __position, value_type&& __x)
      |                                         ~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1310:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator]'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1310:70: note:   no known conversion for argument 2 from 'std::vector<int>' to 'std::initializer_list<int>'
 1310 |       insert(const_iterator __position, initializer_list<value_type> __l)
      |                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note: candidate: 'std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::size_type, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = std::vector<int>::iterator; std::vector<_Tp, _Alloc>::const_iterator = std::vector<int>::const_iterator; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int]'
 1335 |       insert(const_iterator __position, size_type __n, const value_type& __x)
      |       ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1335:7: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/10/bits/stl_vector.h:1379:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, _InputIterator, _InputIterator) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]'
 1379 |  insert(const_iterator __position, _InputIterator __first,
      |  ^~~~~~
/usr/include/c++/10/bits/stl_vector.h:1379:2: note:   template argument deduction/substitution failed:
toxic.cpp:46:46: note:   candidate expects 3 arguments, 2 provided
   46 |    ask.in(ask.end(), vector<int>(cnt, non[j]));
      |                                              ^