# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83092 | osmanorhan | Bosses (BOI16_bosses) | C++17 | 255 ms | 263168 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <climits>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cassert>
#include <vector>
#define all(x) x.begin() , x.end()
#define fi first
#define se second
#define pb push_back
#define umax( x , y ) x = max( x , (y) )
#define umin( x , y ) x = min( x , (y) )
#define null NULL
#define ort (b+s)/2
using namespace std;
typedef long long Lint;
typedef long double db;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef pair<db,db> dd;
typedef pair<int,string> is;
const int maxn = 1500020;
const int maxx = 1500000;
const int MOd = 998244353;
int a;
int dad[maxn], cur;
vector<int> w[maxn];
int dfs( int n ) {
for(int i=0;i<w[n].size();i++)
if( dad[ w[n][i] ] ) dad[ w[n][i] ] = n;
int ret = 1;
for(int i=0;i<w[n].size();i++)
ret += dfs( w[n][i] );
cur += ret;
return ret;
}
int main( ) {
scanf("%d",&a);
for(int i=1,k;i<=a;i++) {
scanf("%d",&k);
for(int j=0,t;j<k;j++) {
scanf("%d",&t);
w[t].pb( i );
}
}
int ans = 0;
for(int i=1;i<=a;i++) {
memset( dad, 0, sizeof( dad ) );
cur = 0;dfs( i );
umax( ans, cur );
}
cout << ans << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |