Submission #83095

# Submission time Handle Problem Language Result Execution time Memory
83095 2018-11-05T08:25:56 Z osmanorhan Bosses (BOI16_bosses) C++17
0 / 100
238 ms 263168 KB
#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 = 10520;
const int maxx = 10500;
const int MOd = 998244353;

int a;
int dad[maxn];
long long cur;
int used[maxn];
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++)
		if( dad[ w[n][i] ] == n ) 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 );
		}
	}
	long long int ans = 0;
	for(int i=1;i<=a;i++) {
		memset( dad, 0, sizeof( dad ) );
		memset( used, 0, sizeof( used ) );
		cur = 0;dfs( i );
		umax( ans, cur );
	}
	cout << ans << endl;
	return 0;
}

Compilation message

bosses.cpp: In function 'int dfs(int)':
bosses.cpp:44:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<w[n].size();i++)
              ~^~~~~~~~~~~~
bosses.cpp:47:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<w[n].size();i++)
              ~^~~~~~~~~~~~
bosses.cpp: In function 'int main()':
bosses.cpp:55:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&a);
  ~~~~~^~~~~~~~~
bosses.cpp:57:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&k);
   ~~~~~^~~~~~~~~
bosses.cpp:59:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d",&t);
    ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 238 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 238 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 238 ms 263168 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -