제출 #290667

#제출 시각아이디문제언어결과실행 시간메모리
290667DymoBosses (BOI16_bosses)C++14
0 / 100
4 ms4992 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define all(n) n.begin(),n.end() #define endl "\n" #define pll pair<ll,ll> #define ff first #define ss second using namespace std; const ll maxn=2e5+500; const ll mod=1e9+7 ; const ll base=500; /// con 17 ngay vector<ll> adj[maxn]; bool dd[maxn]; ll ans=1e15; ll ans1=0; ll sum[maxn]; void dfs(ll u,ll dep) { sum[u]=1; dd[u]=1; for (auto to:adj[u]) { if (!dd[to]) { dfs(to,dep+1); sum[u]+=sum[to]; } } ans1+=sum[u]; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); //freopen("test.txt","r",stdin); if (fopen("Farm.INP","r")) { freopen("Farm.INP","r",stdin); freopen("Farm.OUT","w",stdout); } ll n; cin>>n ; for (int i=1; i<=n; i++) { ll x; cin>>x; while (x--) { ll t; cin>> t; adj[t].pb(i); } } for (int i=1; i<=n; i++) { for (int j=1; j<=n; j++) dd[j]=0; ans1=0; dfs(i,1); bool x=false; for (int j=1; j<=n; j++) { if (!dd[j]) { x=true; break; } } if (!x) { ans=min(ans,ans1); } } cout <<ans; }

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

bosses.cpp: In function 'int main()':
bosses.cpp:62:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   62 |         for (int j=1; j<=n; j++)
      |         ^~~
bosses.cpp:64:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   64 |             ans1=0;
      |             ^~~~
bosses.cpp:44:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   44 |         freopen("Farm.INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bosses.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   45 |         freopen("Farm.OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...