제출 #68910

#제출 시각아이디문제언어결과실행 시간메모리
68910MANcityBosses (BOI16_bosses)C++14
100 / 100
996 ms1052 KiB
///GAGO_O #include<iostream> #include<cstdio> #include<fstream> #include<algorithm> #include<cmath> #include<map> #include<queue> #include<set> #include<stack> #include<string> #include<cstring> #include<vector> using namespace std; #define for1(i,n) for(int i=1;i<=(int)n;i++) #define for0(i,n) for(int i=0;i<=(int)n;i++) #define forn(i,n) for(int i=n;i>=1;i--) #define fo(i,x,y) for(int i=x;i<=(int)y;i++) #define fr(i,x,y) for(int i=x;i>=(int)y;i--) #define pb push_back #define mp make_pair #define LL long long const LL Mod=1000*1000*1000+7; int n; int used[5002]; vector<vector<int> > g(5002); int d[5002]; int p[5002]; int bfs(int x) { for1(i,n) { used[i]=0; d[i]=0; p[i]=0; } int X=x; queue<int> q; q.push(x); used[x]=1; p[x]=1; while(!q.empty()) { int x=q.front(); for0(j,g[x].size()-1) { int to=g[x][j]; if(used[to]==0) { p[to]=p[x]+1; used[to]=1; q.push(to); } } q.pop(); } for1(i,n) if(used[i]==0) return (100000000); for1(i,n) d[p[i]]++; int u=0; forn(i,n) { if(d[i]!=0) { u=i; break; } } int ANS=0; ANS+=d[u]; forn(i,u-1) ANS+=(d[i]-1); int f[5002]; for1(i,n) f[i]=0; f[u-1]=d[u]+1; forn(i,u-2) { f[i]=(f[i+1]+d[i+1]); } forn(i,u-1) ANS+=f[i]; return ANS; } int main() { scanf("%d",&n); for1(i,n) { int k; scanf("%d",&k); for1(j,k) { int x; scanf("%d",&x); g[x].push_back(i); } } int ans=100000000; for1(i,n) ans=min(ans,bfs(i)); cout<<ans<<endl; return 0; }

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

bosses.cpp: In function 'int bfs(int)':
bosses.cpp:37:9: warning: unused variable 'X' [-Wunused-variable]
     int X=x;
         ^
bosses.cpp: In function 'int main()':
bosses.cpp:89:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
bosses.cpp:93:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
bosses.cpp:97:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%d",&x);
             ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...