Submission #437690

#TimeUsernameProblemLanguageResultExecution timeMemory
437690SHZhangKeys (IOI21_keys)C++17
37 / 100
146 ms17220 KiB
#include <vector> #include <queue> #include <algorithm> using namespace std; int n, m; vector<pair<int, int> > graph[2005]; vector<pair<int, int> > key[2005]; bool haskey[2005]; bool access[2005]; int p[2005]; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { vector<int> ans(r.size(), 1); n = r.size(); m = u.size(); int minp = n + 1; for (int i = 0; i < m; i++) { graph[u[i]].push_back(make_pair(v[i], c[i])); graph[v[i]].push_back(make_pair(u[i], c[i])); key[c[i]].push_back(make_pair(u[i], v[i])); } for (int x = 0; x < n; x++) { for (int j = 0; j < n; j++) haskey[j] = access[j] = false; access[x] = true; queue<int> que; que.push(x); while (!que.empty()) { int node = que.front(); que.pop(); p[x]++; if (!haskey[r[node]]) { haskey[r[node]] = true; for (int i = 0; i < key[r[node]].size(); i++) { pair<int, int> edge = key[r[node]][i]; if (access[edge.first] && !access[edge.second]) { access[edge.second] = true; que.push(edge.second); } if (!access[edge.first] && access[edge.second]) { access[edge.first] = true; que.push(edge.first); } } } for (int i = 0; i < graph[node].size(); i++) { pair<int, int> edge = graph[node][i]; if (haskey[edge.second] && !access[edge.first]) { access[edge.first] = true; que.push(edge.first); } } } minp = min(minp, p[x]); } for (int i = 0; i < n; i++) { ans[i] = (p[i] == minp ? 1 : 0); } return ans; }

Compilation message (stderr)

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:33:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |                 for (int i = 0; i < key[r[node]].size(); i++) {
      |                                 ~~^~~~~~~~~~~~~~~~~~~~~
keys.cpp:45:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |             for (int i = 0; i < graph[node].size(); i++) {
      |                             ~~^~~~~~~~~~~~~~~~~~~~
#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...