제출 #791081

#제출 시각아이디문제언어결과실행 시간메모리
791081AndiRBosses (BOI16_bosses)C++14
100 / 100
964 ms652 KiB
#include <iostream> #include <fstream> #include <vector> #include <queue> using namespace std; ifstream fin ("bos.in"); ofstream fout ("bos.out"); typedef long long ll; const int Nmax=5000; int n; bool vis[Nmax]; vector <pair<int, bool>> ad[Nmax]; queue <int> q; ll sol, mn=(ll)99999999999999999; int dfs(int nod){ int s=1; for (int i=0; i<ad[nod].size(); i++){ if (ad[nod][i].second==1){ ad[nod][i].second=0; s+=dfs(ad[nod][i].first); } } sol+=s; return s; } int main() { cin>>n; int m, a; for (int i=0; i<n; i++){ cin>>m; for (int j=0; j<m; j++){ cin>>a; a--; ad[a].push_back({i, 0}); } } for (int i=0; i<n; i++){ sol=0; vis[i]=1; q.push(i); while (!q.empty()){ for (int j=0; j<ad[q.front()].size(); j++){ if (vis[ad[q.front()][j].first]==0){ q.push(ad[q.front()][j].first); vis[ad[q.front()][j].first]=1; ad[q.front()][j].second=1; } } q.pop(); } bool ok=1; for (int i=0; i<n; i++){ if (vis[i]==0) ok=0; vis[i]=0; } dfs(i); if (sol<mn && ok) mn=sol; } cout<<mn; return 0; }

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

bosses.cpp: In function 'int dfs(int)':
bosses.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i=0; i<ad[nod].size(); i++){
      |                   ~^~~~~~~~~~~~~~~
bosses.cpp: In function 'int main()':
bosses.cpp:44:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, bool> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for (int j=0; j<ad[q.front()].size(); j++){
      |                           ~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...