답안 #140056

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
140056 2019-08-02T00:57:55 Z mahmoudbadawy 도서관 (JOI18_library) C++17
0 / 100
2000 ms 262148 KB
#include <cstdio>
#include <iostream>
#include <vector>
#include "library.h"
using namespace std;

// Query()
// Answer()
int n;

int query(vector<int> v)
{
	vector<int> m(n,0);
	for(int i:v) m[i]=1;
	return Query(m);
}

int get(int x,vector<int> v)
{
	if(v.size()==1)
	{
		v.push_back(x);
		if(query(v)==2)
			return -1;
		return v[0];
	}
	vector<int> mm;
	for(int i=0;i<v.size()/2;i++)
		mm.push_back(v[i]);
	int cur=query(mm);
	mm.push_back(x);
	if(query(mm)<=cur)
	{
		mm.pop_back();
		return get(x,mm);
	}
	mm.clear();
	for(int i=v.size()/2;i<v.size();i++)
		mm.push_back(v[i]);
	return get(x,mm);
}

vector<int> adj[1005];
vector<int> ans;

void build(int x,int pa)
{
	ans.push_back(x+1);
	for(int i:adj[x])
		if(i!=pa) build(i,x);
}

void Solve(int N)
{
	n=N;
	for(int i=0;i<N;i++)
	{
		vector<int> ss;
		for(int j=0;j<N;j++)
		{
			bool ok=1;
			for(int k:adj[i])
				ok&=(k!=j);
			ok&=(i!=j);
			if(ok) ss.push_back(j);
		}
		int x=get(i,ss);
		if(x!=-1) {adj[i].push_back(x); adj[x].push_back(i);}
	}
	/*for(int i=0;i<n;i++)
	{
		for(int j:adj[i]) cout << j << " ";
		cout << endl;
	}*/
	for(int i=0;i<n;i++)
	{
		if(adj[i].size()==1)
		{
			build(i,-1); break;
		}
	}
	Answer(ans);
}

Compilation message

library.cpp: In function 'int get(int, std::vector<int>)':
library.cpp:28:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<v.size()/2;i++)
              ~^~~~~~~~~~~
library.cpp:38:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=v.size()/2;i<v.size();i++)
                       ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 344 KB Wrong Answer [4]
2 Incorrect 55 ms 376 KB Wrong Answer [4]
3 Incorrect 42 ms 344 KB Wrong Answer [4]
4 Incorrect 52 ms 376 KB Wrong Answer [4]
5 Incorrect 54 ms 380 KB Wrong Answer [4]
6 Incorrect 67 ms 344 KB Wrong Answer [4]
7 Incorrect 61 ms 252 KB Wrong Answer [4]
8 Incorrect 50 ms 344 KB Wrong Answer [4]
9 Incorrect 57 ms 380 KB Wrong Answer [4]
10 Incorrect 25 ms 448 KB Wrong Answer [4]
11 Execution timed out 3029 ms 210748 KB Time limit exceeded
12 Execution timed out 3102 ms 207868 KB Time limit exceeded
13 Correct 2 ms 248 KB # of queries: 7
14 Correct 2 ms 248 KB # of queries: 16
15 Correct 3 ms 248 KB # of queries: 133
16 Incorrect 7 ms 376 KB Wrong Answer [4]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 344 KB Wrong Answer [4]
2 Incorrect 55 ms 376 KB Wrong Answer [4]
3 Incorrect 42 ms 344 KB Wrong Answer [4]
4 Incorrect 52 ms 376 KB Wrong Answer [4]
5 Incorrect 54 ms 380 KB Wrong Answer [4]
6 Incorrect 67 ms 344 KB Wrong Answer [4]
7 Incorrect 61 ms 252 KB Wrong Answer [4]
8 Incorrect 50 ms 344 KB Wrong Answer [4]
9 Incorrect 57 ms 380 KB Wrong Answer [4]
10 Incorrect 25 ms 448 KB Wrong Answer [4]
11 Execution timed out 3029 ms 210748 KB Time limit exceeded
12 Execution timed out 3102 ms 207868 KB Time limit exceeded
13 Correct 2 ms 248 KB # of queries: 7
14 Correct 2 ms 248 KB # of queries: 16
15 Correct 3 ms 248 KB # of queries: 133
16 Incorrect 7 ms 376 KB Wrong Answer [4]
17 Incorrect 605 ms 628 KB Wrong Answer [3]
18 Incorrect 569 ms 432 KB Wrong Answer [3]
19 Incorrect 605 ms 620 KB Wrong Answer [3]
20 Incorrect 529 ms 424 KB Wrong Answer [4]
21 Incorrect 453 ms 560 KB Wrong Answer [4]
22 Incorrect 566 ms 492 KB Wrong Answer [3]
23 Incorrect 580 ms 376 KB Wrong Answer [3]
24 Incorrect 215 ms 376 KB Wrong Answer [4]
25 Incorrect 539 ms 376 KB Wrong Answer [3]
26 Incorrect 488 ms 376 KB Wrong Answer [4]
27 Incorrect 218 ms 436 KB Wrong Answer [4]
28 Runtime error 859 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Runtime error 1389 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
30 Runtime error 839 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)