Submission #253228

# Submission time Handle Problem Language Result Execution time Memory
253228 2020-07-27T13:53:37 Z aZvezda Friend (IOI14_friend) C++14
Compilation error
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[]){
    int ans = 0;
    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:30:13: error: expected ';' before 'ans'
             ans += dp[i];
             ^~~