답안 #168142

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168142 2019-12-11T13:51:22 Z dimash241 도서관 (JOI18_library) C++17
0 / 100
582 ms 262148 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);	
	}
}

void go (int i, vector < vector < int > > &g, vector < int > & ans, int pr = 0) {
	ans.pb(i + 1);
	for (auto to : g[i]) if (to != i) {
		go(to, g, ans, i);
	}
}

void Solve(int n) {
	if (n > 200) exit(0);
	vector <int> m(n, 0);
	vector < vector < int > > g;
	g.resize(n);

	for(int i = 0; i < n; i ++) {
		m[i] = 1;
		for (int j = i + 1; j < n; j ++) {
			m[j] = 1;
			if (ask(m) == 1) {
				g[i].pb(j);
				g[j].pb(i);
			}
			m[j] = 0;
		}
		m[i] = 0;
	}

	vector < int > ans;
	for (int i = 0; i < n; i ++) if(g[i].size() == 1) {
		go(i, g, ans);
		break;
	}

	assert(ans.size() == n);
	
	print(ans);
}

// B...a

Compilation message

In file included from /usr/include/c++/7/cassert:44:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:33,
                 from library.cpp:3:
library.cpp: In function 'void Solve(int)':
library.cpp:77:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  assert(ans.size() == n);
         ~~~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 530 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 464 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 582 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 556 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 525 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 517 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 545 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 531 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 534 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 347 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 231 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 235 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 231 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 231 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 235 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 530 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 464 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 582 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 556 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 525 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 517 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 545 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 531 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 534 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 347 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 231 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 235 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 231 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 231 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 235 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Incorrect 2 ms 248 KB Unexpected end of file - token expected
18 Incorrect 2 ms 248 KB Unexpected end of file - token expected
19 Incorrect 2 ms 248 KB Unexpected end of file - token expected
20 Incorrect 2 ms 376 KB Unexpected end of file - token expected
21 Incorrect 2 ms 248 KB Unexpected end of file - token expected
22 Incorrect 2 ms 248 KB Unexpected end of file - token expected
23 Incorrect 2 ms 248 KB Unexpected end of file - token expected
24 Incorrect 2 ms 376 KB Unexpected end of file - token expected
25 Incorrect 2 ms 248 KB Unexpected end of file - token expected
26 Incorrect 2 ms 376 KB Unexpected end of file - token expected
27 Incorrect 2 ms 376 KB Unexpected end of file - token expected
28 Incorrect 2 ms 248 KB Unexpected end of file - token expected
29 Incorrect 2 ms 248 KB Unexpected end of file - token expected
30 Incorrect 2 ms 380 KB Unexpected end of file - token expected