제출 #1040224

#제출 시각아이디문제언어결과실행 시간메모리
1040224Rafi22즐거운 행로 (APIO20_fun)C++14
10 / 100
66 ms17608 KiB
#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 s[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) { s[i]=attractionsBehind(0,i); if(s[i]>=(n+1)/2&&s[i]<mn) { mn=s[i]; C=i; } } vector<pair<int,int>>V; FOR(i,0,n-1) { d[i]=hoursRequired(C,i); if(d[i]==1) { if(s[i]>s[C]) V.pb({i,n-s[C]}); else V.pb({i,s[i]}); } } debug(C,V); vector<int>ans; FOR(i,0,n-1) { if(i==C) continue; if(V[0].st==i||attractionsBehind(i,V[0].st)>=n-V[0].nd+1)id[i]=0; else if(V[1].st==i||attractionsBehind(i,V[1].st)>=n-V[1].nd+1) id[i]=1; else id[i]=2; debug(id[i],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; } } ans.pb(X[f].back().nd); X[f].pop_back(); last=f; } ans.pb(C); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:74:4: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   74 |    if(j==last) continue;
      |    ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...