답안 #168219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168219 2019-12-12T02:55:57 Z dimash241 도서관 (JOI18_library) C++17
0 / 100
2 ms 408 KB
#include "library.h"

#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back 
using namespace std;

bool SEND = 1;
                                         
//int Query(const std::vector<int>& M);
//void Answer(const std::vector<int>& res);
int n, a[2222];

int ask (const std::vector < int > &m) {
	if (SEND) {
		return Query(m);
	}

	int l = -1, r = -1;
	for (int i = 1; i <= n; i ++) {
		if (m[a[i]-1]) {
			if (r == -1) l = i;
			r = i;
		}
	}
	
	if (r == -1) assert(0);
	return r - l;
}


void print (const std:: vector <int> &res) {
	if (SEND) {
		Answer(res);

	} else {
		for (auto x : res)
			cout << x << ' ';
		cout << '\n';
		exit(0);	
	}
}

int go (int x, vector < int > &vec) {
	vector < int > all;
	for (int i = 0; i < n; i ++) if (vec[i]) {
		all.pb(i);
	}
	if (all.size() == 1) {
		return all.back();
	}

	vector < int > p1(n, 0);
	vector < int > p2(n, 0);

	for (int i = 0; i < all.size(); i ++) 
		if (i < all.size() / 2) p1[all[i]] = 1;
		else p2[all[i]] = 1;
	int was = ask(p1);
	p1[x] = 1;
	if (ask(p1) == was) {
		p1[x] = 0;
		return go(x, p1);
	}

	return go(x, p2);
}

void Solve(int n) {
	if (n == 1) {
		Answer({1});
		return;
	}
	vector < int > m(n, 1);
	int start = -1;
	for (int i = 0; i < n; i ++) {
		m[i] = 0;

		if (ask(m)) {
			start = i;
			break;
			
		}

		m[i] = 1;
	}
	vector < int > ans;
	ans.pb(start);

	for (int i = 1; i < n; i ++) {
		vector < int > vec(n, 1);
		for (auto x : ans) vec[x] = 0;
		ans.pb(go(ans.back(), vec));
	}

	for (auto &to : ans) to++;

	print(ans);
}

// B...a

Compilation message

library.cpp: In function 'int go(int, std::vector<int>&)':
library.cpp:57:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < all.size(); i ++) 
                  ~~^~~~~~~~~~~~
library.cpp:58:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (i < all.size() / 2) p1[all[i]] = 1;
       ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Wrong Answer [1]
2 Incorrect 2 ms 376 KB Wrong Answer [1]
3 Incorrect 2 ms 248 KB Wrong Answer [1]
4 Incorrect 2 ms 376 KB Wrong Answer [1]
5 Incorrect 2 ms 376 KB Wrong Answer [1]
6 Incorrect 2 ms 248 KB Wrong Answer [1]
7 Incorrect 2 ms 248 KB Wrong Answer [1]
8 Incorrect 2 ms 248 KB Wrong Answer [1]
9 Incorrect 2 ms 248 KB Wrong Answer [1]
10 Incorrect 2 ms 248 KB Wrong Answer [1]
11 Correct 2 ms 248 KB # of queries: 0
12 Incorrect 2 ms 248 KB Wrong Answer [1]
13 Incorrect 2 ms 376 KB Wrong Answer [1]
14 Incorrect 2 ms 248 KB Wrong Answer [1]
15 Incorrect 2 ms 248 KB Wrong Answer [1]
16 Incorrect 2 ms 248 KB Wrong Answer [1]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 248 KB Wrong Answer [1]
2 Incorrect 2 ms 376 KB Wrong Answer [1]
3 Incorrect 2 ms 248 KB Wrong Answer [1]
4 Incorrect 2 ms 376 KB Wrong Answer [1]
5 Incorrect 2 ms 376 KB Wrong Answer [1]
6 Incorrect 2 ms 248 KB Wrong Answer [1]
7 Incorrect 2 ms 248 KB Wrong Answer [1]
8 Incorrect 2 ms 248 KB Wrong Answer [1]
9 Incorrect 2 ms 248 KB Wrong Answer [1]
10 Incorrect 2 ms 248 KB Wrong Answer [1]
11 Correct 2 ms 248 KB # of queries: 0
12 Incorrect 2 ms 248 KB Wrong Answer [1]
13 Incorrect 2 ms 376 KB Wrong Answer [1]
14 Incorrect 2 ms 248 KB Wrong Answer [1]
15 Incorrect 2 ms 248 KB Wrong Answer [1]
16 Incorrect 2 ms 248 KB Wrong Answer [1]
17 Incorrect 2 ms 248 KB Wrong Answer [1]
18 Incorrect 2 ms 248 KB Wrong Answer [1]
19 Incorrect 2 ms 248 KB Wrong Answer [1]
20 Incorrect 2 ms 404 KB Wrong Answer [1]
21 Incorrect 2 ms 408 KB Wrong Answer [1]
22 Incorrect 2 ms 408 KB Wrong Answer [1]
23 Incorrect 2 ms 248 KB Wrong Answer [1]
24 Incorrect 2 ms 248 KB Wrong Answer [1]
25 Incorrect 2 ms 248 KB Wrong Answer [1]
26 Incorrect 2 ms 324 KB Wrong Answer [1]
27 Incorrect 2 ms 376 KB Wrong Answer [1]
28 Incorrect 2 ms 376 KB Wrong Answer [1]
29 Incorrect 2 ms 244 KB Wrong Answer [1]
30 Incorrect 2 ms 408 KB Wrong Answer [1]