Submission #336138

#TimeUsernameProblemLanguageResultExecution timeMemory
336138super_j6자동 인형 (IOI18_doll)C++14
Compilation error
0 ms0 KiB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
#define vi vector<int>

const int mxn = 1 << 19;
int n, k, t;
bool b[mxn];
vi f, u(mxn), v(mxn);

int bld(int l, int r){
	if(l == r) return 0;
	if(r < k - n - (n & 1)) return -1;
	int it = t++, mid = (l + r) / 2;
	u[it] = bld(l, mid), v[it] = bld(mid + 1, r);
	return -it - 1;
}

void add(int x, int y){
	int &z = b[-x - 1] ? u[-x - 1] : v[-x - 1];
	b[-x - 1] ^= 1;
	if(!z) z = y;
	else add(z, y);
}

void answer(vi f, vi u, vi v){
	for(int i = 0; i < f.size(); i++){
		cout << i << ": " << f[i] << endl;
	}
	for(int i = 0; i < u.size(); i++){
		cout << (-i - 1) << ": " << u[i] << " " << v[i] << endl;
	} 
}

void create_circuit(int m, vi a){
	n = a.size(), k = 1 << (__lg(n - 1) + 1);
	bld(0, k - 1);
	
	for(int i = 1; i < n; i++) add(-1, a[i]);
	add(-1, 0);
	
	f.assign(m + 1, -1), u.resize(t), v.resize(t);
	f[0] = a[0];
	
	answer(f, u, v);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	
	vi a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	create_circuit(m, a);

	return 0;
}

Compilation message (stderr)

doll.cpp: In function 'void answer(std::vector<int>, std::vector<int>, std::vector<int>)':
doll.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |  for(int i = 0; i < f.size(); i++){
      |                 ~~^~~~~~~~~~
doll.cpp:37:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |  for(int i = 0; i < u.size(); i++){
      |                 ~~^~~~~~~~~~
/usr/bin/ld: /tmp/ccud4fr2.o: in function `answer(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x1f0): multiple definition of `answer(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'; /tmp/cc1pa5i1.o:doll.cpp:(.text+0xf0): first defined here
/usr/bin/ld: /tmp/ccud4fr2.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc1pa5i1.o:doll.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status