Submission #805605

#TimeUsernameProblemLanguageResultExecution timeMemory
805605raysh07Keys (IOI21_keys)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define INF (int)1e9 int n, m; const int N = 3e5 + 69; vector <int> adj[N], pend[N]; bool have[N], vis[N]; //do i have this colour? int cnt[N], a[N], b[N]; 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++){ adj[u[i]].push_back(v[i]); adj[v[i]].push_back(u[i]); } for (int i = 0; i < n; i++){ a[i] = r[i]; b[i] = c[i]; } int mn = INF; for (int i = 0; i < n; i++){ for (int j = 0; j < n; j++){ have[j] = false; pend[j].clear(); } queue <int> q; q.push(i); while (!q.empty()){ cnt[i]++; int u = q.front(); q.pop(); have[r[u]] = true; for (auto x : pend[r[u]]){ vis[x] = true; q.push(x); } pend[r[u]].clear(); for (int v : adj[u]){ if (vis[v]) continue; if (have[c[v]]){ vis[v] = true; q.push(v); } else { pend[c[v]].push_back(v); } } } mn = min(mn, cnt[i]); } int ans = 0; for (int i = 0; i < n; i++){ if (mn == cnt[i]) ans++; } 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:67:12: error: could not convert 'ans' from 'int' to 'std::vector<int>'
   67 |     return ans;
      |            ^~~
      |            |
      |            int