제출 #927455

#제출 시각아이디문제언어결과실행 시간메모리
927455Gilwall친구 (IOI14_friend)C++14
27 / 100
19 ms3520 KiB
#include "friend.h" #include <vector> using namespace std; // Find out best sample int findSample(int n, int confidence[], int host[], int protocol[]){ int ans = 0; vector<int> M(n), NM(n); for(int i = 0; i < n; i++) { M[i] = confidence[i]; NM[i] = 0; } for(int i = n-1; i > 0; i--) { // i is person being added int x = host[i]; int y = i; if (protocol[i] == 0) { NM[x] += M[y]; M[x] += NM[y]; } else if (protocol[i] == 1) { int mx = max(NM[x], M[x]) + max(NM[y], M[y]); int nmx = NM[x] + NM[y]; M[x] = mx; NM[x] = nmx; } else if (protocol[i] == 2) { int mx = max(NM[x] + M[y], NM[y] + M[x]); int nmx = NM[x] + NM[y]; M[x] = mx; NM[x] = nmx; } } return max(M[0], NM[0]); }

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

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:8:13: warning: unused variable 'ans' [-Wunused-variable]
    8 |         int ans = 0;
      |             ^~~
#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...