제출 #103613

#제출 시각아이디문제언어결과실행 시간메모리
103613NnandiBosses (BOI16_bosses)C++14
100 / 100
628 ms888 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 5005; vector<int> graf[maxn]; int tav[maxn]; int n; void ujra() { for(int i=0;i<n;i++) { tav[i] = -1; } return; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n; for(int i=0;i<n;i++) { int k; cin>>k; for(int j=0;j<k;j++) { int from; cin>>from; from--; graf[from].push_back(i); } } ll summa = (ll)n*(n+1); for(int i=0;i<n;i++) { ujra(); vector<int> sor(1,i); tav[i] = 0; int it = 0; ll jel = (ll) n; while(it < sor.size()) { int akt = sor[it]; jel += tav[akt]; for(int s:graf[akt]) { if(tav[s] == -1) { tav[s] = tav[akt] + 1; sor.push_back(s); } } it++; } if(sor.size() == n && summa > jel) { summa = jel; } } cout<<summa<<endl; return 0; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:44:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(it < sor.size()) {
               ~~~^~~~~~~~~~~~
bosses.cpp:55:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(sor.size() == n && summa > jel) {
            ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...