hiho Week 11 register

Ended

Participants:433

Verdict:Accepted
Score:100 / 100
Submitted:2014-09-15 05:10:57

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
pair<int, int> solve(int loc, vector<int>* data[]) {
    vector<pair<int, int> > subproblems;
    pair<int, int> result;
    int maxSolo = 0;
    int maxDuo = 0;
    for (int i = 0; i < data[loc]->size(); i++) {
        subproblems.push_back(solve(data[loc]->at(i), data));
    }
    for (int i = 0; i < subproblems.size(); i++) {
        if (subproblems.at(i).first > maxDuo) {
            maxDuo = subproblems.at(i).first;
        }
        if (subproblems.at(i).second + 1 > maxSolo) {
            maxSolo = subproblems.at(i).second + 1;
        }
        for (int j = i + 1; j < subproblems.size(); j++) {
            if (subproblems.at(i).second + subproblems.at(j).second + 2 > maxDuo) {
                maxDuo = subproblems.at(i).second + subproblems.at(j).second + 2;
            }
        }
    }
    return pair<int, int>(maxDuo, maxSolo);
}
int main(int argc, const char * argv[]) {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX