Submission #230650

# Submission time Handle Problem Language Result Execution time Memory
230650 2020-05-10T19:36:07 Z Dilshod_Imomov Library (JOI18_library) C++17
19 / 100
2000 ms 4448 KB
#include <bits/stdc++.h>
#include "library.h"
using namespace std;
 
const int N = 1e3 + 7;

vector < int > adj[N], res;
int used[N], cnt[N][N];
 
void dfs( int v, int ind ) {
	// cout << v << ' ' << ind << endl;
	res[ind] = v;
	used[v] = 1;
	for ( auto u: adj[v] ) {
		if ( !used[u] ) {
			dfs( u, ind + 1 );
		}
	}
}

void Solve(int n)
{
	vector < int > m(n);
	res.assign(n, 0);
	if ( n == 1 ) {
		res[0] = 1;
		Answer(res);
		return;
	}
	for ( int i = 1; i <= n; i++ ) {
		m[i - 1] = 1;
		for ( int j = 1; j <= n; j++ ) {
			if ( i == j || cnt[i][j] ) {
				continue;
			}
			cnt[i][j] = 1;
			cnt[j][i] = 1;
			m[j - 1] = 1;
			int x = Query(m);
			if ( x == 1 ) {
				adj[i].push_back( j );
				adj[j].push_back( i );
			}
			m[j - 1] = 0;
		}
		m[i - 1] = 0;
	}
	int start;
	for ( int i = 1; i <= n; i++ ) {
		// cout << i << ' ' << adj[i].size() << '\n';
		if ( (int)adj[i].size() == 1 ) {
			start = i;
			break;
		}
	}
	dfs( start, 0 );
	Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:56:5: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
  dfs( start, 0 );
  ~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 275 ms 1272 KB # of queries: 18336
2 Correct 256 ms 1276 KB # of queries: 18145
3 Correct 270 ms 1272 KB # of queries: 19900
4 Correct 337 ms 1272 KB # of queries: 19900
5 Correct 289 ms 1152 KB # of queries: 19900
6 Correct 332 ms 1152 KB # of queries: 19900
7 Correct 306 ms 1400 KB # of queries: 19900
8 Correct 262 ms 1272 KB # of queries: 18528
9 Correct 279 ms 1272 KB # of queries: 19701
10 Correct 111 ms 896 KB # of queries: 8256
11 Correct 4 ms 384 KB # of queries: 0
12 Correct 4 ms 412 KB # of queries: 1
13 Correct 5 ms 384 KB # of queries: 3
14 Correct 5 ms 384 KB # of queries: 6
15 Correct 6 ms 384 KB # of queries: 105
16 Correct 10 ms 512 KB # of queries: 351
# Verdict Execution time Memory Grader output
1 Correct 275 ms 1272 KB # of queries: 18336
2 Correct 256 ms 1276 KB # of queries: 18145
3 Correct 270 ms 1272 KB # of queries: 19900
4 Correct 337 ms 1272 KB # of queries: 19900
5 Correct 289 ms 1152 KB # of queries: 19900
6 Correct 332 ms 1152 KB # of queries: 19900
7 Correct 306 ms 1400 KB # of queries: 19900
8 Correct 262 ms 1272 KB # of queries: 18528
9 Correct 279 ms 1272 KB # of queries: 19701
10 Correct 111 ms 896 KB # of queries: 8256
11 Correct 4 ms 384 KB # of queries: 0
12 Correct 4 ms 412 KB # of queries: 1
13 Correct 5 ms 384 KB # of queries: 3
14 Correct 5 ms 384 KB # of queries: 6
15 Correct 6 ms 384 KB # of queries: 105
16 Correct 10 ms 512 KB # of queries: 351
17 Execution timed out 3065 ms 4384 KB Time limit exceeded
18 Execution timed out 3062 ms 4216 KB Time limit exceeded
19 Execution timed out 3009 ms 4216 KB Time limit exceeded
20 Execution timed out 3090 ms 4088 KB Time limit exceeded
21 Execution timed out 3010 ms 3832 KB Time limit exceeded
22 Execution timed out 3094 ms 4448 KB Time limit exceeded
23 Execution timed out 3045 ms 4392 KB Time limit exceeded
24 Incorrect 1071 ms 2424 KB Wrong Answer [3]
25 Execution timed out 3021 ms 4216 KB Time limit exceeded
26 Execution timed out 3073 ms 3960 KB Time limit exceeded
27 Incorrect 1051 ms 2424 KB Wrong Answer [3]
28 Execution timed out 3058 ms 4248 KB Time limit exceeded
29 Execution timed out 3082 ms 4216 KB Time limit exceeded
30 Execution timed out 3037 ms 4216 KB Time limit exceeded