답안 #50748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
50748 2018-06-13T06:42:07 Z Just_Solve_The_Problem 친구 (IOI14_friend) C++11
0 / 100
1000 ms 147456 KB
#include <bits/stdc++.h>
#include "friend.h"

using namespace std;

#define pb push_back
#define sz(s) (int)s.size()

const int N = (int)1e5 + 7;
const int smN = (int)1e3 + 7;

vector < int > gr[N];
int has[smN][smN];
int c[N];

void addedge(int a, int b) {
  gr[a].pb(b);
  gr[b].pb(a);
  has[a][b] = has[b][a] = 1;
}

int res = 0;

void dfs(int v, int pr, bool fl) {
  if (fl) {
    res += c[v];
  }
  for (int to : gr[v]) {
    if (to == pr) continue;
    dfs(to, v, fl ^ 1);
  }
}

int findSample(int n, int confidence[], int host[], int protocol[]){
  for (int i = 0; i < n; i++) c[i] = confidence[i];
  int ans = 0;
  for (int i = 1; i < n; i++) {
    if (protocol[i] == 0 || protocol[i] == 2) {
      addedge(host[i], i);
    }
    if (protocol[i] == 1 || protocol[i] == 2) {
      for (int to : gr[host[i]]) {
        addedge(to, i);
      }
    }
  }
  dfs(0, 0, 1);
  ans = max(ans, res);
  res = 0;
  dfs(0, 0, 0);
  ans = max(ans, res);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 2680 KB Output is correct
2 Correct 5 ms 2788 KB Output is correct
3 Correct 4 ms 2788 KB Output is correct
4 Correct 4 ms 2788 KB Output is correct
5 Correct 4 ms 2788 KB Output is correct
6 Correct 4 ms 2788 KB Output is correct
7 Execution timed out 1058 ms 147456 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 147456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 19 ms 147456 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 147456 KB Output is correct
2 Correct 4 ms 147456 KB Output is correct
3 Correct 4 ms 147456 KB Output is correct
4 Correct 4 ms 147456 KB Output is correct
5 Correct 8 ms 147456 KB Output is correct
6 Incorrect 7 ms 147456 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 147456 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 147456 KB Output is correct
2 Correct 4 ms 147456 KB Output is correct
3 Execution timed out 1033 ms 147456 KB Time limit exceeded
4 Halted 0 ms 0 KB -