제출 #329294

#제출 시각아이디문제언어결과실행 시간메모리
329294NicolaAbusaad2014Bosses (BOI16_bosses)C++14
0 / 100
1 ms364 KiB
/** * Prof.Nicola **/ #include <bits/stdc++.h> using namespace std; vector<vector<long> >edges; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); long n,x,z; cin>>n; edges.resize(n+1); for(long i=0;i<n;i++){ cin>>x; for(long j=0;j<x;j++){ cin>>z; edges[z].push_back(i+1); } } long long ans=1e9; for(long i=1;i<=n;i++){ priority_queue<pair<long long,long> >pq; bool vis[n+1]={}; vector<long long>best(n+1,-1e9); long long cost=0; pq.push(make_pair(0,i)); while(!pq.empty()){ z=pq.top().first; x=pq.top().second; pq.pop(); if(!vis[x]){ cost+=-z+1; vis[x]=true; for(long j=0;j<edges[x].size();j++){ if(z-1>best[edges[x][j]]){ best[edges[x][j]]=z-1; pq.push(make_pair(z-1,edges[x][j])); } } } } ans=min(ans,cost); } cout<<ans<<endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bosses.cpp: In function 'int main()':
bosses.cpp:36:31: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |                 for(long j=0;j<edges[x].size();j++){
      |                              ~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...