# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
230649 | Dilshod_Imomov | Library (JOI18_library) | C++17 | 3092 ms | 2648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
m[j - 1] = 1;
int x = Query(m);
if ( x == 1 ) {
adj[i].push_back( j );
}
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |