제출 #695158

#제출 시각아이디문제언어결과실행 시간메모리
695158Mr_PhBosses (BOI16_bosses)C++14
0 / 100
2 ms340 KiB
///Never gonna give you up. #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> typedef long long ll; typedef long long int lli; typedef unsigned long long ull; using namespace std; using namespace __gnu_pbds; template<class x> using ordered_set = tree<x, null_type,less<x>, rb_tree_tag,tree_order_statistics_node_update>; const ll mod=(ll)1e9+7; const ll mod1=998244353; ///the defines :) #define endl '\n' #define vi vector<int> #define vll vector<ll> #define ent(arr) for(int i=0;i<arr.size();i++)cin>>arr[i]; #define all(arr) arr.begin(),arr.end() #define allr(arr) arr.rbegin(),arr.rend() #define sz size() #define int long long ///the end of the defines ;) void bla() { #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("notsus.txt","w",stdout); #endif } int n; vector<vector<int>>padj; vector<vector<int>>adj; vector<bool>vs; map<int,int>val; vector<bool>vs1; map<int,int>val1; vector<vector<int>>build(int node) { vector<vector<int>>yay(n+1); map<int,int>mp; queue<int>q; q.push(node); map<int,int>mp1; while(q.sz) { mp1[q.front()]++; mp[q.front()]++; for(auto i:padj[q.front()]) { if(!mp1[i]) { yay[q.front()].push_back(i); mp[i]++; q.push(i); mp1[i]++; } } q.pop(); } return yay; } int hello=0; void dfs(int node) { vs[node]=true; val[node]=1; for(auto i:adj[node]) { if(!vs[i])dfs(i); val[node]+=val[i]; } } void preprocess(){} void solve() { cin>>n; padj.resize(n+1); vs.resize(n+1); vs1.resize(n+1); adj.resize(n+1); for(int i=0;i<n;i++) { int x; cin>>x; for(int j=0;j<x;j++) { int a; cin>>a; padj[a].push_back(i+1); } } int ans=1e18; for(int i=1;i<=n;i++) { vs=vs1; val=val1; adj=build(i); hello=0; dfs(i); for(auto i:val) { hello+=i.second; } ans=min(ans,hello); } cout<<ans<<endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); preprocess(); bla(); int t=1; //cin>>t; while(t--) solve(); }

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

bosses.cpp: In function 'void bla()':
bosses.cpp:28:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     freopen("input.txt","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
bosses.cpp:29:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     freopen("notsus.txt","w",stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...