AtCoder Grand Contest 009

Submission #1591774

Source codeソースコード

#include <bits/stdc++.h>
using namespace std;

#define fill(x,y) memset(x,y,sizeof(x))
#define fi first
#define se second
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pb push_back
#define smp(x,y,z) mp(x,mp(y,z))
#define reads(x) scanf("%s",&x)
#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define read3(x,y,z) scanf("%d%d%d",&x,&y,&z)

typedef long long ll;
typedef string s;
typedef pair<int,int> pii;
typedef pair<int,string> pis;
typedef pair<string,int> psi;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vector<int> > matrix;

const ll oo = 1e9+7;
const int maxSize = 100100;
const int mod = 1e9+7;

const double EPS = (1e-9);

int dcmp(double x, double y){return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;}

map<int,vi> seq;
map<int,priority_queue<pii> > childs;
map<int,int> maxi;
vector<pii> coun;

int dfs(int n){
    vi childss = seq[n] ;
    if(childss.empty())return 1;
    int maxii = 0 ;
    for(int i : childss){
        maxii=max(maxii,dfs(i));
    }
    maxi[n] = maxii;
    return maxii+1;
}

int main(){

    int n  ; cin >> n ;
    for(int i=2 ;i<=n ;i++){
        int num ; cin >> num ;
        if(i!=num)seq[num].pb(i) ;
    }
    dfs(1);
    for(pair<int,vi> i : seq){
        for(int j : i.se){
            childs[i.fi].push({maxi[j],j}) ;
        }
    }
    int res=-1 ;
    coun.pb({1,0});
    while(!coun.empty()){
        pii out = coun.back() ; coun.pop_back() ;
        if(childs[out.fi].size()==0)continue;
        coun.pb({out.fi,out.se+1});
        pii out2 = childs[out.fi].top() ; childs[out.fi].pop() ;
        coun.pb({out2.se,out.se+1});
        res=max(res,out.se+1);
    }
    cout << res ;
}

Submission

Task問題 B - Tournament
User nameユーザ名 vjudge3
Created time投稿日時
Language言語 C++14 (Clang 3.8.0)
Status状態 CE
Score得点 -
Source lengthソースコード長 1843 Byte
File nameファイル名
Exec time実行時間 -
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

./Main.cpp:1:10: fatal error: 'bits/stdc++.h' file not found
#include <bits/stdc++.h>
^
1 error generated.

Test case