# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
967895 | 2024-04-23T04:49:20 Z | PM1 | Bosses (BOI16_bosses) | C++17 | 0 ms | 348 KB |
#include <bits/stdc++.h> using namespace std; const int mxn=5e3+5; int n,ans=1e9,mark[mxn]; vector<int>v[mxn]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for(int i=1;i<=n;i++){ int k; cin>>k; while(k--){ int x; cin>>x; v[x].push_back(i); } } for(int i=1;i<=n;i++){ memset(mark,0,sizeof mark); int res=0; queue<int>q; mark[i]=1; q.push(i); while(!q.empty()){ int x=q.front(); q.pop(); res+=mark[x]; for(auto j:v[x]){ if(!mark[j]){ mark[j]=mark[x]+1; q.push(j); } } } for(int j=1;j<=n;j++){ if(mark[j]=0) assert(0); } ans=min(res,ans); } cout<<ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Incorrect | 0 ms | 348 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |