Submission #672321

# Submission time Handle Problem Language Result Execution time Memory
672321 2022-12-15T14:07:54 Z Trisanu_Das Horses (IOI15_horses) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long

int n, x[500001], y[500001];

int solve(){
  ll pref = 1, hrspr = 1, last = 0, ans = 0;
  for(int i = 0; i < n; i++){
    hrspr *= x[i];
    pref = pref * x[i] % MOD;
    if((long double)y[i] * hrspr > last){
      ans = pref * y[i] % MOD; hrspr = 1; last = y[i];
    }
  }
  return ans;
}
 
int init(int N, int X[], int Y[]){
  n = N; x = X; y = Y; return solve;
}
 
int updateX(int pos, int val){
  x[pos] = val; solve();
}
int updateY(int pos, int val){
  y[pos] = val; solve();
}

Compilation message

horses.cpp: In function 'int solve()':
horses.cpp:17:10: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   17 |   return ans;
      |          ^~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:21:12: error: incompatible types in assignment of 'int*' to 'int [500001]'
   21 |   n = N; x = X; y = Y; return solve;
      |          ~~^~~
horses.cpp:21:19: error: incompatible types in assignment of 'int*' to 'int [500001]'
   21 |   n = N; x = X; y = Y; return solve;
      |                 ~~^~~
horses.cpp:21:31: error: invalid conversion from 'int (*)()' to 'int' [-fpermissive]
   21 |   n = N; x = X; y = Y; return solve;
      |                               ^~~~~
      |                               |
      |                               int (*)()
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:26:1: warning: no return statement in function returning non-void [-Wreturn-type]
   26 | }
      | ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:29:1: warning: no return statement in function returning non-void [-Wreturn-type]
   29 | }
      | ^