제출 #497848

#제출 시각아이디문제언어결과실행 시간메모리
497848aSSSdBosses (BOI16_bosses)C++14
100 / 100
650 ms716 KiB
//#pragma GCC optimize("O2,unroll-loops") //#pragma GCC target("avx,avx2") #include <bits/stdc++.h> using namespace std; #define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;}) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l,int r) { return l+rng()%(r-l+1); } #define fasty ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define forinc(x,a,b) for(int x=a;x<=b;x++) #define fordec(x,a,b) for(int x=a;x>=b;x--) #define forv(a,b) for(auto&a:b) #define fi first #define se second #define pb push_back #define ii pair<long long,long long> #define getbit(x,i) ((x>>(i))&1) #define batbit(x,i) (x|(1ll<<(i))) #define tatbit(x,i) (x&~(1<<(i))) #define gg exit(0); #define all(a) a.begin() , a.end() #define int long long const int N = 5010; int n; vector<int> ke[N]; //f[x] = sum(f[v]) +1; int dd[N]; int F(int x) { int ret=0; memset(dd, 0 , sizeof dd); queue<int> q; dd[x] = 1; q.push(x); while(!q.empty()) { int u = q.front(); q.pop(); ret+=dd[u]; for(auto v : ke[u]) { if(dd[v]) continue; dd[v] = dd[u] + 1; q.push(v); } } forinc(i,1,n) if(!dd[i]) ret = 1e15; return ret; } main() { fasty; cin >> n; forinc(i,1,n) { int num; cin >> num; while(num--) { int x; cin >> x; ke[x].pb(i); } } int res = 1e15; forinc(i,1,n) { res = min(res , F(i)); } cout << res; }

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

bosses.cpp:55:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   55 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...