이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fun.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
const int N=100007;
int d[N];
int id[N];
vector<pair<int,int>>X[3];
vector<int>createFunTour(int n,int q)
{
int C=-1,mn=inf;
FOR(i,0,n-1)
{
int s=attractionsBehind(0,i);
if(s>=n/2&&s<mn)
{
mn=s;
C=i;
}
}
vector<int>V;
FOR(i,0,n-1)
{
d[i]=hoursRequired(C,i);
if(d[i]==1) V.pb(i);
}
debug(V);
vector<int>ans;
debug(C);
FOR(i,0,n-1)
{
if(i==C) continue;
if(V[0]==i||attractionsBehind(i,V[0])>=(n+1)/2)id[i]=0;
else if(V[1]==i||attractionsBehind(i,V[1])>=(n+1)/2) id[i]=1;
else id[i]=2;
debug(i,id[i]);
X[id[i]].pb({d[i],i});
}
FOR(i,0,2) sort(all(X[i]));
int last=-1;
FOR(i,1,n-1)
{
int mx=-1,f;
FOR(j,0,2)
{
if(j==last) continue;
if(sz(X[j])>0&&X[j].back().st>mx)
{
mx=X[j].back().st;
f=j;
}
}
debug(i,mx);
ans.pb(X[f].back().nd);
X[f].pop_back();
last=f;
}
debug(ans);
ans.pb(C);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:70:4: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
70 | if(j==last) continue;
| ^~
# | 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... |