답안 #344035

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
344035 2021-01-05T04:56:48 Z tengiz05 도서관 (JOI18_library) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "library.h"
#include "grader.cpp"
using namespace std;
void Solve(int n){
	if(n == 1){
		vector<int> ans = {1};
		Answer(ans);
		return;
	}
	vector<vector<int>> v(n);
	for(int i=0;i<n;i++){
		if(v[i].size() == 2)continue;
		vector<int> ask(n, 0);
		ask[i] = 1;
		for(int j=i+1;j<n;j++){
			if(v[j].size() == 2)continue;
			ask[j] = 1;
			if(Query(ask) == 1)v[i].push_back(j), v[j].push_back(i);
			ask[j] = 0;
		}
	}
	//~ for(int i=0;i<n;i++){for(auto x : v[i])cout << x << ' ';cout << '\n';}
	vector<bool> used(n);
	vector<int> ans;
	int u=-1;
	for(int i=0;i<n;i++){
		if(v[i].size() == 1){
			u = i;break;
		}
	}
	assert(u != -1);
	while(true){
		bool ch = false;
		used[u] = true;
		ans.push_back(u+1);
		for(auto to : v[u]){
			if(!used[to]){
				ch=true;
				u=to;
			}
		}if(!ch)break;
	}
	Answer(ans);
	return;
}

/*

5
4 2 5 3 1

*/

Compilation message

/tmp/ccYPgAgf.o: In function `Query(std::vector<int, std::allocator<int> > const&)':
library.cpp:(.text+0x0): multiple definition of `Query(std::vector<int, std::allocator<int> > const&)'
/tmp/ccnzUGUU.o:grader.cpp:(.text+0x0): first defined here
/tmp/ccYPgAgf.o:(.bss+0x0): multiple definition of `__my_judge_::judge'
/tmp/ccnzUGUU.o:(.bss+0x0): first defined here
/tmp/ccYPgAgf.o: In function `Answer(std::vector<int, std::allocator<int> > const&)':
library.cpp:(.text+0x10): multiple definition of `Answer(std::vector<int, std::allocator<int> > const&)'
/tmp/ccnzUGUU.o:grader.cpp:(.text+0x390): first defined here
/tmp/ccYPgAgf.o: In function `main':
library.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccnzUGUU.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status