제출 #337886

#제출 시각아이디문제언어결과실행 시간메모리
337886KazamaHoangCities (BOI16_cities)C++14
0 / 100
91 ms9964 KiB
/* -> Written by <- ----------- K_A_Z_A_M_A ___________ _ | | (^_^) | | /( | )\ | |____|_|____| H O A N G */ #include <bits/stdc++.h> #define Task "" #define F first #define S second #define pb push_back #define bit(x, i) ((x >> (i)) & 1) #define inf 1e9 + 7 #define INF 1e18 + 7 #define ll long long #define pii pair <int, int> #define debug(x) cerr << #x << " is " << x << "\n"; using namespace std; const int MOD = 1e9 + 7; const int maxn = 1e5 + 5; int n, k, m; bool dd[maxn]; vector <int> ke[maxn]; struct DATA{ int u, v, w; }e[maxn * 2]; bool comp(DATA p, DATA q){ return p.w < q.w; } int root[maxn]; int Get_Root(int u){ if (root[u] != u) root[u] = Get_Root(root[u]); return root[u]; } void Solve(){ cin >> n >> k >> m; for (int i = 1; i <= k; ++ i){ int x; cin >> x; dd[x] = 1; } for (int i = 1; i <= m; ++ i){ int u, v, w; cin >> u >> v >> w; e[i] = {u, v, w}; } sort(e + 1, e + 1 + m, comp); for (int i = 1; i <= n; ++ i) root[i] = i; int res = 0; for (int i = 1; i <= m; ++ i){ int u = e[i].u; int v = e[i].v; int w = e[i].w; if (!dd[u] && !dd[v]) continue; u = Get_Root(u); v = Get_Root(v); if (u == v) continue; root[u] = v; res += w; } cout << res; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); if(fopen(Task".inp", "r")){ freopen(Task".inp","r",stdin); freopen(Task".out","w",stdout); } int test_case = 1; // cin >> test_case; while (test_case --){ Solve(); } return 0; }

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

cities.cpp: In function 'int main()':
cities.cpp:81:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   81 |         freopen(Task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
cities.cpp:82:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   82 |         freopen(Task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#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...