Submission #133692

# Submission time Handle Problem Language Result Execution time Memory
133692 2019-07-21T08:39:54 Z antimirage Friend (IOI14_friend) C++14
Compilation error
0 ms 0 KB
#include "friend.h"
#include <bits/stdc++.h>

using namespace std;

int findSample(int n,int c[],int p[],int t[]){
	int ans = 0;
	
	for (int i = n - 1'; i >= 0; i--) {
		if (t[i] == 0) {
			c[p[i]] = max(0, c[p[i]] - c[i]);
			ans += c[i];
		} else if (t[i] == 1) {
			c[p[i]] += c[i];
		} else {
			c[p[i]] = max( c[p[i]], c[i] );
		}
	}
	return ans + c[0];
}

Compilation message

friend.cpp:9:20: warning: missing terminating ' character
  for (int i = n - 1'; i >= 0; i--) {
                    ^
friend.cpp:9:20: error: missing terminating ' character
  for (int i = n - 1'; i >= 0; i--) {
                    ^~~~~~~~~~~~~~~~~
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:10:3: error: expected ';' before 'if'
   if (t[i] == 0) {
   ^~
friend.cpp:10:3: error: expected primary-expression before 'if'
friend.cpp:10:3: error: expected ';' before 'if'
friend.cpp:10:3: error: expected primary-expression before 'if'
friend.cpp:10:3: error: expected ')' before 'if'
friend.cpp:18:2: warning: no return statement in function returning non-void [-Wreturn-type]
  }
  ^
friend.cpp: At global scope:
friend.cpp:19:2: error: expected unqualified-id before 'return'
  return ans + c[0];
  ^~~~~~
friend.cpp:20:1: error: expected declaration before '}' token
 }
 ^