제출 #574260

#제출 시각아이디문제언어결과실행 시간메모리
574260wjajjsasqq열쇠 (IOI21_keys)C++17
9 / 100
3066 ms32336 KiB
#include "keys.h" #include <cassert> #include <algorithm> const int N = 300000; int n, res[N]; bool u[N], vis[N]; std::vector<int> unlock[N]; std::vector<std::pair<int, int> > g[N]; std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) { n = r.size(); for (int i = 0; i < (int)u.size(); ++i) { g[u[i]].push_back(std::make_pair(v[i], c[i])); g[v[i]].push_back(std::make_pair(u[i], c[i])); } for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) { u[i] = 0; vis[i] = 0; unlock[i].clear(); } std::vector<int> vec; vec.push_back(i); vis[i] = 1; while (!vec.empty()) { int v = vec.back(); if (vec.size() > n) { while (true); } vec.pop_back(); ++res[i]; int c = r[v]; if (!u[c]) { u[c] = 1; for (int i = 0; i < (int)unlock[c].size(); ++i) if (!vis[unlock[c][i]]) { vis[unlock[c][i]] = 1; vec.push_back(unlock[c][i]); } } for (int i = 0; i < (int)g[v].size(); ++i) if (!vis[g[v][i].first]) { if (u[g[v][i].second]) { vis[g[v][i].first] = 1; vec.push_back(g[v][i].first); } else unlock[g[v][i].second].push_back(g[v][i].first); } } } int mn = *std::min_element(res, res + n); std::vector<int> ans(n); for (int i = 0; i < n; ++i) ans[i] = mn == res[i]; 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:28:19: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |    if (vec.size() > n) {
      |        ~~~~~~~~~~~^~~
#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...