제출 #469120

#제출 시각아이디문제언어결과실행 시간메모리
469120kevinxiehk열쇠 (IOI21_keys)C++17
9 / 100
357 ms91488 KiB
#include <bits/stdc++.h> #define mp make_pair #define pb emplace_back #define fi first #define se second using namespace std; set<int> conn[300005]; set<int> conn2[300005]; stack<int> rec; pair<int, int> val[300005]; bool instack[300005]; int scc[300005]; int sz[300005]; vector<int> component[300005]; int cnt = 0; int n, m, t, tt, k = 1; void dfs(int now) { val[now] = mp(k, k); k++; rec.push(now); instack[now] = true; for(auto x: conn[now]) { if(val[x].fi == 0) { dfs(x); } if(instack[x]) { val[now].se = min(val[now].se, val[x].se); } } if(val[now].se == val[now].fi) { cnt++; while(rec.top() != now) { instack[rec.top()] = false; scc[rec.top()] = cnt; component[cnt].pb(rec.top()); rec.pop(); } instack[rec.top()] = false; scc[rec.top()] = cnt; component[cnt].pb(rec.top()); rec.pop(); } } vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { n = r.size(); m = u.size(); for(int i = 0; i < m; i++) { if(r[u[i]] == c[i]) conn[u[i]].insert(v[i]); if(r[v[i]] == c[i]) conn[v[i]].insert(u[i]); } for(int i = 0; i < n; i++) if(val[i].fi == 0) dfs(i); for(int i = 0; i < n; i++) { for(auto x: conn[i]) { if(scc[i] != scc[x]) conn2[scc[i]].insert(scc[x]); } } int mi = n + 5; for(int i = 1; i <= cnt; i++) if(conn2[i].size() == 0) mi = min(mi, (int)(component[i].size())); vector<int> ans(r.size(), 0); for(int i = 1; i <= cnt; i++) { if(conn2[i].size() == 0 && component[i].size() == mi) { for(auto x: component[i]) ans[x] = true; } } return ans; }

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

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:61:56: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |         if(conn2[i].size() == 0 && component[i].size() == mi) {
      |                                    ~~~~~~~~~~~~~~~~~~~~^~~~~
#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...