제출 #489808

#제출 시각아이디문제언어결과실행 시간메모리
489808ala2Bosses (BOI16_bosses)C++14
0 / 100
13 ms23988 KiB
#include <bits/stdc++.h> #define int long long using namespace std; vector<int>v[1001000]; int vi[5010][5010]; int d[5050][5050]; vector<int>gr[5050]; int dfs(int node,int i) { if(d[i][node]) return d[i][node]; if(gr[node].size()==0) { return d[i][node]=1;; } int sum=0; for(int u=0;u<gr[node].size();u++) { sum+=dfs(gr[node][u],i); } return d[i][node]=sum+1; } signed main() { // memset(gr,0,sizeof gr); int n; cin>>n; for(int i=0;i<n;i++) { int k; cin>>k; for(int j=0;j<k;j++) { int x; cin>>x; v[x].push_back(i+1); } } int mn=100000000000000000; for(int i=1;i<n+1;i++) { //cout<<"_______________________"<<endl; for(int uu=0;uu<=n;uu++) { gr[uu].clear(); } queue<int>q; q.push(i); vi[i][i]=1; while(!q.empty()) { int x=q.front(); q.pop(); for(int j=0;j<v[x].size();j++) { int h=v[x][j]; if(!vi[i][h]) { vi[i][h]=1; q.push(h); // cout<<" "<<i<<" "<<h<<endl; gr[x].push_back(h); } } } int c=dfs(i,i); int yy=0; for(int j=1;j<=n;j++) { // // cout<<" "<<i<<" "<<j<<" "<<d[i][j]<<endl; yy+=d[i][j]; } // cout<<" "<<i<<" "<<yy<<endl; mn=min(mn,yy); } cout<<mn<<endl; }

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

bosses.cpp: In function 'long long int dfs(long long int, long long int)':
bosses.cpp:18:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(int u=0;u<gr[node].size();u++)
      |                 ~^~~~~~~~~~~~~~~~
bosses.cpp: In function 'int main()':
bosses.cpp:56:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |             for(int j=0;j<v[x].size();j++)
      |                         ~^~~~~~~~~~~~
bosses.cpp:70:13: warning: unused variable 'c' [-Wunused-variable]
   70 |         int c=dfs(i,i);
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...