이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "fun.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define N 100100
#define F first
#define S second
#define M ll(1e9 + 7)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define PB push_back
#define sz(x) ll(x.size())
#define pw(x) (1ll << x)
#define pwr(x) ((1ll << x) - 1)
#define _ << " " <<
#define pri(s) cout << s << endl
using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef short int si;
typedef unsigned long long ull;
//typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
vector <int> g[N];
int mx, nm;
bool mk[N];
void dfs(int v, int p, int h)
{
if (h > mx && !mk[v]) {mx = h; nm = v;}
for (auto it : g[v])
{
if (it == p) continue;
dfs(it, v, h + 1);
}
}
vector<int> createFunTour(int n, int q)
{
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (hoursRequired(i, j) == 1) {g[i].PB(j); g[j].PB(i);}
dfs(0, -1, 1);
int root = nm;
mx = -1;
dfs(root, -1, 1);
root = nm;
vector <int> vr; vr.clear();
vr.PB(root);
mk[root] = 1;
while (sz(vr) < n)
{
mx = -1;
dfs(root, -1, 1);
root = nm;
mk[root] = 1;
vr.PB(root);
}
return vr;
}
//int main()
//{
// ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(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... |