제출 #823580

#제출 시각아이디문제언어결과실행 시간메모리
823580thimote75친구 (IOI14_friend)C++14
50 / 100
28 ms11220 KiB
#include "friend.h" #include <bits/stdc++.h> using namespace std; using idata = vector<int>; using igrid = vector<idata>; using di = pair<int, int>; idata parents; idata types; idata A, B; idata coeff; igrid roads; int createVersion (int parent) { parents.push_back(parent); types .push_back(0); coeff .push_back(0); A .push_back(-1); B .push_back(-1); return parents.size() - 1; } di compute(int node); di computeI (int node) { int dp0 = 0; int dp1 = coeff[node]; for (int next : roads[node]) { const auto data = compute(next); dp0 += max(data.first, data.second); dp1 += data.first; } return { dp0, dp1 }; } di computeM (int node) { const auto AD = compute(A[node]); const auto BD = compute(B[node]); int dp0 = AD.first + BD.first; int dp1 = max(AD.first, AD.second) + max(BD.first, BD.second); for (int next : roads[node]) { const auto data = compute(next); dp0 += max(data.first, data.second); dp1 += data.first; } return { dp0, dp1 }; } di compute (int node) { if (types[node] == 0) return computeI(node); if (types[node] == 1) return computeM(node); return {0, 0}; } // Find out best sample int findSample(int n,int confidence[],int host[],int protocol[]){ idata versions(n, -1); versions[0] = createVersion(-1); for (int i = 1; i < n; i ++) { int p = versions[host[i]]; versions[i] = createVersion(p); int v = versions[i]; if (protocol[i] != 0) { types[p] = protocol[i]; versions[host[i]] = createVersion(p); int u = versions[host[i]]; A[p] = u; B[p] = v; parents[u] = -1; parents[v] = -1; } } roads.resize(parents.size()); for (int i = 0; i < parents.size(); i ++) if (parents[i] != -1) roads[parents[i]].push_back(i); for (int i = 0; i < n; i ++) coeff[versions[i]] = confidence[i]; const auto data = compute(0); return max(data.first, data.second); }

컴파일 시 표준 에러 (stderr) 메시지

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:87:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |  for (int i = 0; i < parents.size(); i ++)
      |                  ~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...