# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
533844 | 2022-03-07T12:07:18 Z | groshi | Bosses (BOI16_bosses) | C++17 | 776 ms | 716 KB |
#include<iostream> #include<vector> #include<queue> #include<utility> using namespace std; struct wi{ vector<int> Q; int odw=0; }*w; long long wynik=1e18; int kiedy=0; int ile=0; long long mam=0; void bfs(int x) { queue<pair<int,long long> > kolejka; w[x].odw=x; kolejka.push({x,1}); while(!kolejka.empty()) { pair<int,long long> para=kolejka.front(); kolejka.pop(); ile++; mam+=para.second; for(int i=0;i<w[para.first].Q.size();i++) { int pom=w[para.first].Q[i]; if(w[pom].odw==x) continue; w[pom].odw=x; kolejka.push({pom,para.second+1}); } } } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); int n,s,x; cin>>n; w=new wi[n+3]; for(int i=1;i<=n;i++) { cin>>s; for(int j=0;j<s;j++) { cin>>x; w[x].Q.push_back(i); } } for(int i=1;i<=n;i++) { kiedy=i; ile=0; mam=0; bfs(i); if(ile!=n) continue; wynik=min(wynik,mam); } cout<<wynik; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 312 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 1 ms | 204 KB | Output is correct |
4 | Correct | 1 ms | 316 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 0 ms | 312 KB | Output is correct |
8 | Correct | 1 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 1 ms | 204 KB | Output is correct |
11 | Correct | 1 ms | 204 KB | Output is correct |
12 | Correct | 5 ms | 324 KB | Output is correct |
13 | Correct | 4 ms | 444 KB | Output is correct |
14 | Correct | 175 ms | 588 KB | Output is correct |
15 | Correct | 3 ms | 588 KB | Output is correct |
16 | Correct | 648 ms | 588 KB | Output is correct |
17 | Correct | 735 ms | 716 KB | Output is correct |
18 | Correct | 776 ms | 708 KB | Output is correct |