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 "fun.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500 + 3;
/*
int hoursRequired(int i, int j) {
cout << i << ' ' << j << endl;
cin >> i;
return i;
}*/
int dis[MAXN], n;
bitset<MAXN> mark, mirk;
vector<int> g[MAXN];
int door(int v) {
mirk.reset();
memset(dis, 31, sizeof dis);
dis[v] = 0;
queue<int> q;
q.push(v);
while(!q.empty()) {
int x = q.front();
q.pop();
if (mirk[x]) continue;
mirk[x] = true;
for (auto i : g[x]) if (!mark[i] && dis[i] > dis[x] + 1) {
dis[i] = dis[x] + 1;
q.push(i);
}
}
for (int i = 0; i < n; i++) if (mark[i]) dis[i] = -1;
return max_element(dis, dis + n) - dis;
}
vector<int> createFunTour(int N, int q) {
n = N;
if (n >= MAXN) return {};
vector<int> v;
for (int i = 0; i < n; i++) for (int j = i + 1; j < n; j++) if (hoursRequired(i, j) == 1) g[i].push_back(j), g[j].push_back(i);
int x = door(0);
for (int i = 0; i < n; i++) {
int y = door(x);
mark[x] = true;
v.push_back(x);
x = y;
}
return v;
}
/*
int main() {
for (auto i : createFunTour(7, 10)) cout << i << endl;
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |