제출 #1264614

#제출 시각아이디문제언어결과실행 시간메모리
1264614tminhSynchronization (JOI13_synchronization)C++20
0 / 100
36 ms2628 KiB
#include "bits/stdc++.h" using namespace std; #define task "" #define ll long long #define endl '\n' #define u first #define v second #define vall(a) (a).begin(), (a).end() #define sze(a) (int)a.size() #define pii pair<int, int> #define pll pair<ll, ll> #define ep emplace_back #define pb push_back #define pf push_front const ll mod = 1e9 + 7; const int N = 1e6 + 5; const ll oo = 1e18; bool START; int n, m, par[N], sz[N], szz[N], q; pii e[N]; bool vis[N]; // so lan doc sol roi moi biet lam : int find(int v) { return (v == par[v] ? v : par[v] = find(par[v])); } void merge(int a, int b) { int A = find(a); int B = find(b); if (A != B) { szz[a] += sz[B]; szz[b] += sz[A]; if (sz[A] < sz[B]) swap(A, B); par[B] = A; sz[A] += sz[B]; } } inline void solve() { for (int i = 1; i <= n; ++i) { sz[i] = szz[i] = 1; par[i] = i; } for (int i = 1; i <= m; ++i) { int x; cin >> x; if (vis[x]) continue; merge(e[x].u, e[x].v); } while(q--) { int x; cin >> x; cout << szz[x] << endl; } } inline void input() { cin >> n >> m >> q; for (int i = 1; i < n; ++i) cin >> e[i].u >> e[i].v; return solve(); } bool END; int main() { if(fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); input(); cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << 's' << endl; cerr << "Memory: " << fabs ((&END - &START)) / 1048576.0 << "MB\n"; return 0; }

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

synchronization.cpp: In function 'int main()':
synchronization.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen(task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
synchronization.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         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...