제출 #1032781

#제출 시각아이디문제언어결과실행 시간메모리
1032781hotboy2703열쇠 (IOI21_keys)C++17
20 / 100
3057 ms13340 KiB
#include<bits/stdc++.h> using ll = long long; using namespace std; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define MASK(i) (1LL<<(i)) #define BIT(mask,i) (((mask) >> (i))&1) // namespace brute{ const ll MAXN = 3e5+100; bool in[MAXN]; bool keys[MAXN]; ll n; std::vector<int> find_reachable(std::vector<int> r, std::vector<int> u, std::vector<int> v, std::vector<int> c) { n = sz(r); ll m = sz(u); std::vector<int> ans(n); vector <ll> cnt(n); ll res = n; for (ll i = 0;i < n;i ++){ for (ll j = 0;j < n;j ++)in[j] = 0,keys[j] = 0; in[i] = 1; keys[r[i]] = 1; cnt[i] = 1; while (true){ ll pre = cnt[i]; for (ll j = 0;j < m;j ++){ if (in[u[j]] && keys[c[j]] && !in[v[j]])cnt[i]++,in[v[j]] = 1,keys[r[v[j]]] = 1; if (in[v[j]] && keys[c[j]] && !in[u[j]])cnt[i]++,in[u[j]] = 1,keys[r[u[j]]] = 1; } if (cnt[i]==pre)break; } res = min(res,cnt[i]); } for (ll i = 0;i < n;i ++)if (cnt[i] == res)ans[i] = 1; return ans; } // }
#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...