제출 #441788

#제출 시각아이디문제언어결과실행 시간메모리
441788alan8585열쇠 (IOI21_keys)C++17
9 / 100
268 ms51868 KiB
#include <vector> #include <stack> using namespace std; const int MAXN = 300100; int T, in[MAXN], low[MAXN], instack[MAXN], bs[MAXN]; vector<int> e[MAXN]; stack<int> st; vector<vector<int>> SCC; vector<int> flags; void dfs(int a) { instack[a] = 1; st.push(a); in[a] = low[a] = ++T; for(int i : e[a]) { if(!in[i]) { dfs(i); low[a] = min(low[a], low[i]); } else if(instack[i]) { low[a] = min(low[a], in[i]); } } if(in[a] == low[a]) { int now = -1; SCC.push_back(vector<int>(0)); do { now = st.top(); st.pop(); SCC.back().push_back(now); bs[now] = SCC.size(); instack[now] = 0; } while(now != a); } } std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) { std::vector<int> ans(r.size(), 0); int n = r.size(), m = u.size(); for(int i = 0; i < m; i++) { if(r[u[i]] == c[i]) e[u[i]].push_back(v[i]); if(r[v[i]] == c[i]) e[v[i]].push_back(u[i]); } for(int i = 0; i < n; i++) { if(!in[i]) { dfs(i); } } int nmin = MAXN; for(int i = 0; i < (int)SCC.size(); i++) { int flag = 1; for(int j : SCC[i]) { for(int k : e[j]) { if(bs[k] != i + 1) flag = 0; } } flags.push_back(flag); if(flag) { nmin = min(nmin, (int)SCC[i].size()); } } for(int i = 0; i < (int)SCC.size(); i++) { if(flags[i] && SCC[i].size() == nmin) { for(int j : SCC[i]) ans[j] = 1; } } 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:66:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   66 |         if(flags[i] && SCC[i].size() == nmin) {
      |                        ~~~~~~~~~~~~~~^~~~~~~
#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...