제출 #447855

#제출 시각아이디문제언어결과실행 시간메모리
447855MilosMilutinovic친구 (IOI14_friend)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define ll long long #define mp make_pair #define fi first #define se second #define pb push_back #define vi vector<int> #define pi pair<int, int> #define mod 1000000007 template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;} template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;} ll ksm(ll a, ll b) {if (b == 0) return 1; ll ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns;} using namespace std; const int maxn = 1050; vi g[maxn]; ll dp[maxn][2]; int a[maxn]; bool was[maxn]; bool sub2(vector<int> a) { for (int x : a) if (x != 1) return false; return true; } bool sub3(vector<int> a) { for (int x : a) if (x != 2) return false; return true; } bool sub4(vector<int> a) { for (int x : a) if (x != 0) return false; return true; } void dfs(int u, int p) { vector<ll> s(2); for (int v : g[u]) { if (v != p) { dfs(v, u); s[0] += max(dp[v][0], dp[v][1]); s[1] += dp[v][0]; } } dp[u][1] = a[u] + s[0]; dp[u][0] = s[1]; } ll findSample(int n, int* confidence, int* host, int* protocol) { if (sub2(protocol)) { ll sum = accumulate(confidence.begin(), confidence.end(), 0); return sum; } if (sub3(protocol)) { return *max_element(confidence.begin(), confidence.end()); } if (sub4(protocol)) { for (int i = 1; i < n; i++) g[host[i]].pb(i); for (int i = 0; i < n; i++) a[i] = confidence[i]; ll res = 0; for (int i = 0; i < n; i++) { if (!was[i]) { dfs(i, i); res += max(dp[i][0], dp[i][1]); } } return res; } return 0LL; }

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

friend.cpp: In function 'long long int findSample(int, int*, int*, int*)':
friend.cpp:49:14: error: could not convert 'protocol' from 'int*' to 'std::vector<int>'
   49 |     if (sub2(protocol)) {
      |              ^~~~~~~~
      |              |
      |              int*
friend.cpp:50:40: error: request for member 'begin' in 'confidence', which is of non-class type 'int*'
   50 |         ll sum = accumulate(confidence.begin(), confidence.end(), 0);
      |                                        ^~~~~
friend.cpp:50:60: error: request for member 'end' in 'confidence', which is of non-class type 'int*'
   50 |         ll sum = accumulate(confidence.begin(), confidence.end(), 0);
      |                                                            ^~~
friend.cpp:53:14: error: could not convert 'protocol' from 'int*' to 'std::vector<int>'
   53 |     if (sub3(protocol)) {
      |              ^~~~~~~~
      |              |
      |              int*
friend.cpp:54:40: error: request for member 'begin' in 'confidence', which is of non-class type 'int*'
   54 |         return *max_element(confidence.begin(), confidence.end());
      |                                        ^~~~~
friend.cpp:54:60: error: request for member 'end' in 'confidence', which is of non-class type 'int*'
   54 |         return *max_element(confidence.begin(), confidence.end());
      |                                                            ^~~
friend.cpp:56:14: error: could not convert 'protocol' from 'int*' to 'std::vector<int>'
   56 |     if (sub4(protocol)) {
      |              ^~~~~~~~
      |              |
      |              int*