제출 #706441

#제출 시각아이디문제언어결과실행 시간메모리
706441Alihan_8악어의 지하 도시 (IOI11_crocodile)C++17
46 / 100
3 ms520 KiB
#include <bits/stdc++.h> #include "crocodile.h" // include <ext/pb_ds/assoc_container.hpp> // include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; using namespace std; #define all(x) x.begin(), x.end() #define pb push_back // define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> #define mpr make_pair #define ln '\n' void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);} //#define int long long typedef long long ll; int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){ int n = N, m = M, k = K; vector <pair<int,int>> g[n]; vector <int> used(n), vis(n); for ( int i = 0; i < k; i++ ) used[P[i]] = true; for ( int i = 0; i < m; i++ ){ auto [x, y] = R[i]; g[x].pb({L[i], y}); g[y].pb({L[i], x}); } const ll inf = 1e17+1; function <ll(int,int,ll)> dfs = [&](int x, int par, ll depth){ if ( vis[x] ) return inf; if ( used[x] ) return depth; vector <ll> res; vis[x] = true; for ( auto [w, to]: g[x] ){ if ( to == par ) continue; res.pb(dfs(to, x, depth+w)); } sort(all(res)); if ( (int)res.size() <= 1 ) return inf; return res[1]; }; return dfs(0, -1, 0); } #if false signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, k; cin >> n >> m >> k; int R[m][2], L[m], p[k]; for ( int i = 0; i < m; i++ ){ cin >> R[i][0] >> R[i][1]; } for ( int i = 0; i < m; i++ ) cin >> L[i]; for ( int i = 0; i < k; i++ ) cin >> p[i]; cout << travel_plan(n, m, R, L, k, p); cout << '\n'; /* 5 4 3 0 1 0 2 3 2 2 4 2 3 1 4 1 3 4 answer: 7 5 7 2 0 2 0 3 3 2 2 1 0 1 0 4 3 4 4 3 2 10 100 7 9 1 3 answer: 14 */ } #endif

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

crocodile.cpp: In function 'void IO(std::string)':
crocodile.cpp:12:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:12:70: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 | void IO(string name){freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout);}
      |                                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...