제출 #1052921

#제출 시각아이디문제언어결과실행 시간메모리
1052921aykhn열쇠 (IOI21_keys)C++17
37 / 100
3023 ms39376 KiB
#include <bits/stdc++.h> #include "keys.h" using namespace std; const int MXN = 3e5 + 5; int n; vector<array<int, 2>> adj[MXN]; vector<int> r, c; int arr[MXN], used[MXN]; set<int> skey; map<int, vector<int>> snode; void addnode(int x, int &node); void addkey(int x, int &node) { skey.insert(x); if (snode[x].empty()) return; vector<int> &v = snode[x]; while (!v.empty()) { int x = v.back(); v.pop_back(); addnode(x, node); } } void addnode(int x, int &node) { if (used[x]) return; // cout << x << ' '; if (!used[x]) arr[node]++; used[x] = 1; addkey(r[x], node); for (array<int, 2> &v : adj[x]) { if (skey.find(v[1]) != skey.end()) addnode(v[0], node); else snode[v[1]].push_back(v[0]); } } void process(int x) { fill(used, used + n, 0); snode.clear(), skey.clear(); // cout << x << ": "; addnode(x, x); // cout << '\n'; } vector<int> find_reachable(vector<int> R, vector<int> u, vector<int> v, vector<int> C) { n = R.size(), r = R, c = C; for (int i = 0; i < u.size(); i++) { adj[u[i]].push_back({v[i], c[i]}); adj[v[i]].push_back({u[i], c[i]}); } for (int i = 0; i < n; i++) { process(i); } int mn = *min_element(arr, arr + n); vector<int> res(n, 0); for (int i = 0; i < n; i++) res[i] = (arr[i] == mn); return res; }

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

keys.cpp: In function 'std::vector<int> find_reachable(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
keys.cpp:56:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for (int i = 0; i < u.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...