제출 #878080

#제출 시각아이디문제언어결과실행 시간메모리
878080vjudge1Genetics (BOI18_genetics)C++17
0 / 100
87 ms16984 KiB
/// I'm only brave when I have to be #include <bits/stdc++.h> #define F first #define S second #define pb push_back #define ppb pop_back #define fast_io ios::sync_with_stdio(false);cin.tie(NULL); #define file_io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); #define FOR(i,k,n) for(int i = k; i < n; ++ i) #define debf cout<<"(0-0)\n"; #define all(x) x.begin(), x.end() #define dec(x) cout << fixed << setprecision(x); #define pf push_front #define ppf pop_front #define dash " ------- " #define what(x) cerr << #x << " is " << x << endl; #define eb emplace_back //#define int short int //#define int long long #define sz(s) (int) (s.size()) #define fl cout.flush() using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <int, pii> pip; typedef pair <pii, int> ppi; typedef pair <ll, ll> pll; typedef unsigned long long ull; typedef long double ld; template <class T> using max_heap = priority_queue <T, vector <T>, less <T> >; template <class T> using min_heap = priority_queue <T, vector <T>, greater <T> >; constexpr int MOD = 1e9 + 7, N = 1e5 + 8, M = 1e9, SQ = 300, INF = 1e9 + 8, LGN = 22, mod = 998244353, P = 131113; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m, k, sz[N]; vector <int> ans; vector <pii> v[N]; set <pii> s[N]; void dfs (int u, int par = -1, int e = -1){ for (pii i : v[u]){ if (i.F != par){ dfs (i.F, u, i.S); if (s[i.F].size() > s[u].size()){ s[i.F].swap(s[u]); } for (pii p : s[i.F]){ auto p2 = s[u].lower_bound({p.F, -1}); if (p2 == s[u].end() || p2->F != p.F){ s[u].insert(p); continue; } s[u].erase(p2); pii p3 = p; p3.S += p2->S; if (p3.S != sz[p.F]){ s[u].insert(p3); } } } } if (s[u].size() >= k){ ans.pb(e); } return; } int32_t main(){ fast_io; cin >> n >> m >> k; for (int i = 0; i < n - 1; ++ i){ int aa, bb; cin >> aa >> bb; v[--aa].pb({--bb, i}); v[bb].pb({aa, i}); } FOR (i, 0, m){ int ss, aa; cin >> ss; sz[i] = ss; for (int j = 0; j < ss; ++ j){ cin >> aa; if (ss != 1){ s[--aa].insert({i, 1}); } } } dfs (0); sort (all(ans)); cout << ans.size() << '\n'; for (int i : ans){ cout << i + 1 << " "; } return 0; } // Yesterday is history // Tomorrow is a mystery // but today is a gift // That is why it is called the present

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

genetics.cpp: In function 'void dfs(int, int, int)':
genetics.cpp:67:19: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   67 |   if (s[u].size() >= k){
      |       ~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...