제출 #823577

#제출 시각아이디문제언어결과실행 시간메모리
823577thimote75친구 (IOI14_friend)C++14
19 / 100
1 ms432 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 compute (int node) { if (types[node] == 0) return computeI(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 u = versions[host[i]]; versions[i] = createVersion(u); int v = versions[i]; } 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:57:7: warning: unused variable 'v' [-Wunused-variable]
   57 |   int v = versions[i];
      |       ^
friend.cpp:61:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |  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...