답안 #253227

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
253227 2020-07-27T13:53:16 Z aZvezda 친구 (IOI14_friend) C++14
컴파일 오류
0 ms 0 KB
#include "friend.h"
#include <bits/stdc++.h>
using namespace std;
//T+N
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}
#define out(x) cout << __LINE__ << ": " << (#x) << " = " << (x) << endl

// Find out best sample

const int MAX_N = 1e6 + 10;
int dp[MAX_N];

int findSample(int n, int confidence[], int host[], int protocol[]){
    for(int i = 0; i < n; i ++) {
        dp[i] = confidence[i];
    }
    for(int i = n - 1; i > 0; i --) {
        if(protocol[i] == 1) {
            dp[host[i]] -= min(dp[i], dp[host[i]])
            ans += dp[i];
        } else if(protocol[i] == 2) {
            dp[host[i]] += dp[i];
        } else {
            chkmin(dp[host[i]], dp[i]);
        }
    }
	return ans + dp[0];
}

Compilation message

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:29:13: error: expected ';' before 'ans'
             ans += dp[i];
             ^~~
friend.cpp:36:9: error: 'ans' was not declared in this scope
  return ans + dp[0];
         ^~~
friend.cpp:36:9: note: suggested alternative: 'abs'
  return ans + dp[0];
         ^~~
         abs