이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fun.h"
#include <bits/stdc++.h>
#pragma GCC target("sse,sse2,sse4,avx2")
#pragma GCC optimize("unroll-loops,O2")
#define rep(i,l,r) for (int i = l; i < r; i++)
#define repr(i,r,l) for (int i = r; i >= l; i--)
#define X first
#define Y second
#define all(x) (x).begin() , (x).end()
#define pb push_back
#define endl '\n'
#define debug(x) cerr << #x << " : " << x << endl;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pll;
constexpr int N = 2e5+20,mod = 998244353,inf = 1e9+10;
inline int mkay(int a,int b){
if (a+b >= mod) return a+b-mod;
// if (a+b < 0) return a+b+mod;
return a+b;
}
vector<int> adj[N];
int n,h[N],vis[N];
void dfs(int v,int p){
for (int u : adj[v]){
if (u != p){
h[u] = h[v]+1;
dfs(u,v);
}
}
}
vector<int> createFunTour(int N, int Q){
n = N;
rep(i,0,n){
rep(j,i+1,n)
if (hoursRequired(i,j) == 1){
adj[i].pb(j);
adj[j].pb(i);
}
}
vector<int> ans;
ans.resize(n);
int cur = 1;
rep(i,0,n){
h[cur] = 0;
dfs(cur,-1);
int mx = 0,ind = -1;
rep(j,0,n){
if (!vis[j] && h[j] > mx){
ind = j;
mx = h[j];
}
}
vis[ind] = 1;
ans[i] = ind;
cur = ind;
}
return ans;
}
# | 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... |