답안 #29650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
29650 2017-07-20T09:51:42 Z cki86201 친구 (IOI14_friend) C++11
100 / 100
53 ms 4364 KB
#include "friend.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> Pll;
typedef long double ldouble;

int par[100010];
int D[100010][2];

int findSample(int n,int confidence[],int host[],int protocol[]){
    rep(i, n) D[i][0] = 0, D[i][1] = confidence[i];
    for(int i=n-1;i;i--) {
        int h = host[i], c = protocol[i];
        if(c == 0) D[h][0] += max(D[i][0], D[i][1]), D[h][1] += D[i][0];
        else if(c == 1) {
            D[h][1] = max(D[h][1] + max(D[i][0], D[i][1]), D[h][0] + D[i][1]);
            D[h][0] += D[i][0];
        }
        else if(c == 2) {
            D[h][1] = max(D[h][0] + D[i][1], D[h][1] + D[i][0]);
            D[h][0] += D[i][0];
        }
    }
    
    return max(D[0][0], D[0][1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 0 ms 4364 KB Output is correct
5 Correct 0 ms 4364 KB Output is correct
6 Correct 0 ms 4364 KB Output is correct
7 Correct 0 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 0 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
11 Correct 0 ms 4364 KB Output is correct
12 Correct 0 ms 4364 KB Output is correct
13 Correct 0 ms 4364 KB Output is correct
14 Correct 0 ms 4364 KB Output is correct
15 Correct 0 ms 4364 KB Output is correct
16 Correct 0 ms 4364 KB Output is correct
17 Correct 0 ms 4364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 0 ms 4364 KB Output is correct
5 Correct 0 ms 4364 KB Output is correct
6 Correct 0 ms 4364 KB Output is correct
7 Correct 0 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 0 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 0 ms 4364 KB Output is correct
5 Correct 0 ms 4364 KB Output is correct
6 Correct 0 ms 4364 KB Output is correct
7 Correct 0 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 0 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 0 ms 4364 KB Output is correct
5 Correct 0 ms 4364 KB Output is correct
6 Correct 0 ms 4364 KB Output is correct
7 Correct 0 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 0 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
11 Correct 0 ms 4364 KB Output is correct
12 Correct 0 ms 4364 KB Output is correct
13 Correct 0 ms 4364 KB Output is correct
14 Correct 0 ms 4364 KB Output is correct
15 Correct 0 ms 4364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 0 ms 4364 KB Output is correct
5 Correct 0 ms 4364 KB Output is correct
6 Correct 0 ms 4364 KB Output is correct
7 Correct 0 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 0 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
11 Correct 0 ms 4364 KB Output is correct
12 Correct 0 ms 4364 KB Output is correct
13 Correct 0 ms 4364 KB Output is correct
14 Correct 0 ms 4364 KB Output is correct
15 Correct 0 ms 4364 KB Output is correct
16 Correct 0 ms 4364 KB Output is correct
17 Correct 0 ms 4364 KB Output is correct
18 Correct 0 ms 4364 KB Output is correct
19 Correct 0 ms 4364 KB Output is correct
20 Correct 0 ms 4364 KB Output is correct
21 Correct 0 ms 4364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4364 KB Output is correct
2 Correct 0 ms 4364 KB Output is correct
3 Correct 0 ms 4364 KB Output is correct
4 Correct 0 ms 4364 KB Output is correct
5 Correct 0 ms 4364 KB Output is correct
6 Correct 0 ms 4364 KB Output is correct
7 Correct 0 ms 4364 KB Output is correct
8 Correct 0 ms 4364 KB Output is correct
9 Correct 0 ms 4364 KB Output is correct
10 Correct 0 ms 4364 KB Output is correct
11 Correct 0 ms 4364 KB Output is correct
12 Correct 53 ms 4364 KB Output is correct
13 Correct 23 ms 4364 KB Output is correct
14 Correct 43 ms 4364 KB Output is correct
15 Correct 36 ms 4364 KB Output is correct