Submission #921663

# Submission time Handle Problem Language Result Execution time Memory
921663 2024-02-04T08:53:01 Z coding_snorlax Horses (IOI15_horses) C++14
Compilation error
0 ms 0 KB
#include "horses.h"
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int init(int N, int X[], int Y[]) {
    n=N;
    for(ll i=0;i<N;i++){
      x[i]=X[i];
      y[i]=Y[i];
    }
    ll answer = 1,tmp=1,i=-1;
    for(ll I=N-1;I>=0;I--){
        if(tmp*X[I]>2000000000) {i=I;break;}
        tmp *= X[I];
    }
    if(i==-1) i=0;
    ll place = i;
    ll Max=1,tmp2=1;
    for(ll j=i;j<N;j++){
        tmp2*=X[j];
        tmp2*=Y[j];
        if(tmp2>Max){
            Max = tmp2;
            place = j;
        }
        tmp2/=Y[j];
    }
    for(ll j=0;j<=place;j++){
        answer*=X[j];
        answer %= (1000000007);
    }
    answer*=Y[place];
    answer %= 1000000007;
    return answer;
}

int updateX(int pos, int val) {
    x[pos]=val;
    return init(n,x,y);
}
int updateY(int pos, int val) {
    y[pos]=val;
    return init(n,x,y);
}

Compilation message

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:6:5: error: 'n' was not declared in this scope
    6 |     n=N;
      |     ^
horses.cpp:8:7: error: 'x' was not declared in this scope
    8 |       x[i]=X[i];
      |       ^
horses.cpp:9:7: error: 'y' was not declared in this scope
    9 |       y[i]=Y[i];
      |       ^
horses.cpp:34:12: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   34 |     return answer;
      |            ^~~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:38:5: error: 'x' was not declared in this scope
   38 |     x[pos]=val;
      |     ^
horses.cpp:39:17: error: 'n' was not declared in this scope; did you mean 'yn'?
   39 |     return init(n,x,y);
      |                 ^
      |                 yn
horses.cpp:39:21: error: 'y' was not declared in this scope; did you mean 'yn'?
   39 |     return init(n,x,y);
      |                     ^
      |                     yn
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:42:5: error: 'y' was not declared in this scope; did you mean 'yn'?
   42 |     y[pos]=val;
      |     ^
      |     yn
horses.cpp:43:17: error: 'n' was not declared in this scope; did you mean 'yn'?
   43 |     return init(n,x,y);
      |                 ^
      |                 yn
horses.cpp:43:19: error: 'x' was not declared in this scope
   43 |     return init(n,x,y);
      |                   ^