제출 #671191

#제출 시각아이디문제언어결과실행 시간메모리
671191Ronin13친구 (IOI14_friend)C++14
100 / 100
23 ms3408 KiB
#include "friend.h" #include <bits/stdc++.h> #define ll long long #define pll pair<ll,ll> #define pb push_back #define epb emplace_back #define ull unsigned ll #define f first #define s second #define pii pair<int,int> using namespace std; // Find out best sample const int nmax = 1e5 + 1; int dp[nmax][2]; int findSample(int n,int confidence[],int host[],int protocol[]){ int ans = 0; for(int i = 0; i < n; i++){ dp[i][0] = confidence[i]; dp[i][1] = 0; } for(int i= n - 1; i > 0; i--){ int p = host[i]; if(protocol[i] == 0){ dp[p][1] = max(dp[i][0], dp[i][1]) + dp[p][1]; dp[p][0] = dp[p][0] + dp[i][1]; } if(protocol[i] == 1){ dp[p][0] = max({dp[p][0] + dp[i][1], dp[p][1] + dp[i][0], dp[i][0] + dp[p][0]}); dp[p][1] = dp[p][1] + dp[i][1]; } if(protocol[i] == 2){ dp[p][0] = max({dp[p][0] + dp[i][1], dp[p][1] + dp[i][0]}); dp[p][1] = dp[p][1] + dp[i][1]; } } return max(dp[0][0], dp[0][1]); }

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

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:16:9: warning: unused variable 'ans' [-Wunused-variable]
   16 |     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...