# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
168142 | dimash241 | Library (JOI18_library) | C++17 | 582 ms | 262148 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 "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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |