제출 #835445

#제출 시각아이디문제언어결과실행 시간메모리
835445Baytoro열쇠 (IOI21_keys)C++17
37 / 100
94 ms25612 KiB
#include "keys.h" //#include "grader.cpp" #include <bits/stdc++.h> using namespace std; #define pb push_back #define all(x) x.begin(), x.end() vector<pair<int,int>> g[2005]; vector<int> find_reachable(vector<int> r, vector<int> u, vector<int> v, vector<int> c) { int n=r.size(); int res=1e9; vector<vector<int>> q(n); for(int i=0;i<(int)u.size();i++){ g[u[i]].pb({v[i],c[i]}); g[v[i]].pb({u[i],c[i]}); } vector<int> a(n),vec; for(int i=0;i<n;i++){ int c=0; vector<int> used(n); vector<int> vis(n); q.assign(n,vector<int>()); queue<int> dq; dq.push(i); used[i]=1; while(!dq.empty()){ c++; int a=dq.front();dq.pop(); if(!vis[r[a]]){ vis[r[a]]=1; for(auto it: q[r[a]]){ if(used[it]) continue; used[it]=1; dq.push(it); } } for(auto [it,cc]: g[a]){ if(used[it]) continue; if(vis[cc]){ used[it]=1; dq.push(it); } else{ q[cc].pb(it); } } } if(res>c) res=c,vec.clear(); if(res==c) vec.pb(i); } for(auto it: vec) a[it]=1; return a; }
#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...