# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
21906 | 2017-04-26T20:54:33 Z | iletavcioski | Bosses (BOI16_bosses) | C++ | 0 ms | 2188 KB |
#include<iostream> #include<vector> #include<queue> using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); int n; cin>>n; vector<vector<int> > v; vector<int> vec; v.insert(v.begin(),n+1,vec); for(int i=0;i<n;i++) { int k; cin>>k; for(int j=0;j<k;j++) { int a; cin>>a; a--; v[a].push_back(i); } } ll maxi=1e18; for(int i=0;i<n;i++) { vector<int> vi(n+1,false); vi[i]=true; queue<int> qi; qi.push(i); queue<int> qs; qs.push(1); ll brojac=0; int broj=1; vi[i]=true; while(!qi.empty()) { int topi=qi.front(); qi.pop(); int tops=qs.front(); qs.pop(); brojac+=(ll)tops; for(int j=0;j<v[topi].size();j++) { if(!vi[v[topi][j]]) { vi[v[topi][j]]=true; broj++; qi.push(v[topi][j]); qs.push(tops+1); } } } maxi=min(maxi,brojac); } cout<<maxi<<endl; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2188 KB | Output is correct |
2 | Correct | 0 ms | 2188 KB | Output is correct |
3 | Incorrect | 0 ms | 2188 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2188 KB | Output is correct |
2 | Correct | 0 ms | 2188 KB | Output is correct |
3 | Incorrect | 0 ms | 2188 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2188 KB | Output is correct |
2 | Correct | 0 ms | 2188 KB | Output is correct |
3 | Incorrect | 0 ms | 2188 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |