제출 #609760

#제출 시각아이디문제언어결과실행 시간메모리
609760StrawHatWess열쇠 (IOI21_keys)C++17
0 / 100
3149 ms1690788 KiB
#include "keys.h" #include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=a; i<b; i++) typedef vector<int>vi; #define pb push_back #define sz(x) (int)x.size() #define all(x) begin(x),end(x) typedef pair<int,int>pi; #define fi first #define se second typedef vector<pi>vpi; #define eb emplace_back bool ckmin(int &x, int y){ int f=x>y; x=min(x,y); return f; } //------- const int MX=3e5+10; int N,M; vpi adj[MX]; vi find_reachable(vi a, vi U, vi V, vi C){ N=sz(a); M=sz(U); FOR(i,0,M){ int u=U[i], v=V[i]; adj[u].eb(v,C[i]); adj[v].eb(u,C[i]); } vi ans; int mn=2e9; FOR(s,0,N){ vi vis(N,0); vi vist(N,0); queue<int>q; q.push(s); int n=0; vi vec; while(sz(q)){ int u=q.front(); q.pop(); vis[u]=1; vec.pb(u); vist[a[u]]=1; n++; if(n>mn) break; for(int u: vec) for(auto it: adj[u]){ int v=it.fi, t=it.se; if(vist[t] && !vis[v]){ q.push(v); } } } if(ckmin(mn,sz(vec))) ans={s}; else if(mn==sz(vec)) ans.pb(s); } vi res(N,0); for(int x: ans) res[x]=1; return res; }
#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...