Submission #798261

# Submission time Handle Problem Language Result Execution time Memory
798261 2023-07-30T14:27:08 Z QwertyPi Friend (IOI14_friend) C++14
Compilation error
0 ms 0 KB
#include "friend.h"
#include <bits/stdc++.h>

using namespace std;
struct state{
	int p, q;
};

state st[100011];

state f(int ptc, state s, state t){
	if(ptc == 1) return {s.p + t.q, max(s.q + t.p, s.q + t.q)};
	else if(ptc == 2) return {max(s.p + t.p, max(s.p + t.q, s.q + t.p)), s.q + t.q};
	else return {max(s.p + t.q, s.q + t.p), s.q + t.q};
}

int findSample(int n, int confidence[], int host[], int protocol[]){
	for(int i = 0; i < n; i++) st[i] = {confidence[i], 0};
	for(int i = n - 1; i >= 1; i--){
		st[host[i]] = f(protocol[i], st[i], st[host[i]]);
	}
	return ans;
}

Compilation message

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:22:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |  return ans;
      |         ^~~
      |         abs