제출 #832850

#제출 시각아이디문제언어결과실행 시간메모리
832850amunduzbaev열쇠 (IOI21_keys)C++17
37 / 100
3056 ms27928 KiB
#include "bits/stdc++.h" using namespace std; #define ar array typedef long long ll; //~ #define int ll vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { int n = r.size(); int m = u.size(); vector<vector<ar<int, 2>>> edges(n); for(int i=0;i<m;i++){ edges[u[i]].push_back({v[i], c[i]}); edges[v[i]].push_back({u[i], c[i]}); } int res = n + 1; vector<int> ans; vector<int> used(n), cviz(n); vector<vector<int>> q; int cnt = 0; //~ for(int i=0;i<n;i++){ //~ if(r[i] || edges[i].empty()){ //~ used[i] = 1; //~ res = 0; //~ } //~ } //~ if(!res) return used; for(int i=0;i<n;i++){ fill(used.begin(), used.end(), 0); fill(cviz.begin(), cviz.end(), 0); q.assign(n, vector<int>()); cnt = 0; queue<int> qq; qq.push(i); while(!qq.empty()){ cnt++; int u = qq.front(); qq.pop(); used[u] = 1; if(!cviz[r[u]]){ cviz[r[u]] = 1; for(auto x : q[r[u]]){ if(!used[x]){ used[x] = 1; qq.push(x); } } } for(auto [x, c] : edges[u]){ if(used[x]) continue; if(cviz[c]){ used[x] = 1; qq.push(x); } else { //~ assert(false); q[c].push_back(x); } } } if(res > cnt) res = cnt, ans.clear(); if(res == cnt) ans.push_back(i); } fill(used.begin(), used.end(), 0); for(auto x : ans) used[x] = 1; return used; }
#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...