제출 #388248

#제출 시각아이디문제언어결과실행 시간메모리
388248cpp219Bosses (BOI16_bosses)C++14
100 / 100
753 ms672 KiB
#pragma GCC optimization "Ofast" #pragma GCC optimization "unroll-loop" #pragma GCC target ("avx2") #include <bits/stdc++.h> #define ll long long #define ld long double #define fs first #define sc second using namespace std; const ll N = 5000 + 6; const ll lim = 3e5 + 6; const ll inf = 1e16 + 7; typedef pair<ll,ll> LL; vector<ll> g[N]; ll n,k,x,d[N],was[N],ans = inf; ll oper(ll root){ ll res = 1,cnt = 1; memset(was,0,sizeof(was)); was[root] = 1; queue<ll> q; d[root] = 1; q.push(root); while(!q.empty()){ ll u = q.front(); q.pop(); for (auto i : g[u]){ if (!was[i]){ was[i] = 1; d[i] = d[u] + 1; res += d[i]; q.push(i); cnt++; } } } //cout<<cnt; exit(0); if (cnt == n) return res; return inf; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); #define task "test" if (fopen(task".inp", "r")){ freopen(task".inp", "r", stdin); //freopen(task".out", "w", stdout); } cin>>n; for (ll i = 1;i <= n;i++){ cin>>k; while(k--) cin>>x,g[x].push_back(i); } //cout<<oper(4); return 0; for (ll i = 1;i <= n;i++) ans = min(ans,oper(i)); cout<<ans; }

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

bosses.cpp:1: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    1 | #pragma GCC optimization "Ofast"
      | 
bosses.cpp:2: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    2 | #pragma GCC optimization "unroll-loop"
      | 
bosses.cpp: In function 'int main()':
bosses.cpp:41:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   41 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...