제출 #887181

#제출 시각아이디문제언어결과실행 시간메모리
887181CaubethieunangBosses (BOI16_bosses)C++14
100 / 100
799 ms50124 KiB
#include <bits/stdc++.h> #define ll long long #define LOG 19 #define MASK(i) (1LL<<(i)) #define BIT(x,i) (((x)>>(i))&1) #define FIRST_BIT(mask) __builtin_ctz((mask)&(-mask)) #define ERASE_BIT(mask) (mask)^((mask)&(-mask)) #define left _left #define right _right #define task "t" using namespace std; const ll INF=1e18; const int iat=1e6+9; const int mod=1e9+7; void fast_IO() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if(fopen(task".inp","r")) { freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } } int n; bool visited[iat]; vector <int> g[iat],store[iat]; ll sum,salary[iat]; void dfs(int u) { salary[u]=1; for(int v : g[u])dfs(v),salary[u]+=salary[v]; sum+=salary[u]; } void bfs(int s) { for(int i=1; i<=n; i++) { visited[i]=false; g[i].clear(); } queue <int> q; q.push(s); visited[s]=true; while(!q.empty()) { int u=q.front(); q.pop(); for(int v : store[u]) { if(!visited[v]) { visited[v]=true; g[u].push_back(v); q.push(v); } } } for(int i=1; i<=n; i++) { if(!visited[i]) { sum=LLONG_MAX; return; } } dfs(s); } signed main() { fast_IO(); cin>>n; for(int i=1; i<=n; i++) { int k; cin>>k; for(int j=1; j<=k; j++) { int x; cin>>x; store[x].push_back(i); } } ll ans=LLONG_MAX; for(int i=1; i<=n; i++) { sum=0; bfs(i); ans=min(ans,sum); } cout<<ans; }

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

bosses.cpp: In function 'void fast_IO()':
bosses.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bosses.cpp:23:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         freopen(task".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...