제출 #865944

#제출 시각아이디문제언어결과실행 시간메모리
865944ReLiceBosses (BOI16_bosses)C++14
100 / 100
417 ms792 KiB
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define sz size() #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define bc back() using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e18+7; const ll mod=998244353; const ll N=5e3+7; const ld eps=1e-9; ll d[N]; ll i,n; vector <vector <ll>> g(N); ll go(ll v){ for(i=1;i<=n;i++) d[i]=0; queue<ll> q; q.push(v); d[v]=1; while(q.sz){ ll x=q.front(); q.pop(); for(auto i : g[x]){ if(d[i]>0)continue; d[i]=d[x]+1; q.push(i); } } ll c=0; bool flag=true; for(i=1;i<=n;i++){ if(d[i]==0) {flag=false;break;} c+=d[i]; } if(flag) return c; else return inf; } void solve(){ ll i,j; ll b,m; cin>>n; ll ans=inf; for(i=1;i<=n;i++){ cin>>m; for(j=0;j<m;j++){ cin>>b; g[b].pb(i); } } for(i=1;i<=n;i++){ ans=min(ans,go(i)); } cout<<ans<<endl; } signed main(){ start(); //freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout); ll t=1; //cin>>t; while(t--) solve(); } /* */

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

bosses.cpp: In function 'void fre(std::string)':
bosses.cpp:24:27: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bosses.cpp:24:64: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 | void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
      |                                                         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...