Submission #1121827

#TimeUsernameProblemLanguageResultExecution timeMemory
1121827SalihSahinHorses (IOI15_horses)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; #include "horses.h" const long long mod = 1e9 + 7; vector<array<long long, 2> > arr; long long init(int N, int X[], int Y[]) { arr.resize(N); for(int i = 0; i < N; i++){ arr[i] = {X[i], Y[i]}; } long long vl = 1; int ind = 0; for(int i = N-1; i >= 0; i--){ vl *= arr[i][0]; if(vl > mod){ ind = i; break; } } vl = 1; long long precarp = 1; for(int i = 0; i < ind; i++){ precarp = (precarp * arr[i][0])%mod; } long long ans = 0; for(int i = ind; i < N; i++){ vl *= arr[i][0]; ans = max(ans, vl * arr[i][1]); } ans %= mod; ans *= precarp; ans %= mod; return ans; } long long updateX(int pos, int val) { int N = arr.size(); arr[pos][0] = val; long long vl = 1; int ind = 0; for(int i = N-1; i >= 0; i--){ vl *= arr[i][0]; if(vl > mod){ ind = i; break; } } vl = 1; long long precarp = 1; for(int i = 0; i < ind; i++){ precarp = (precarp * arr[i][0])%mod; } long long ans = 0; for(int i = ind; i < N; i++){ vl *= arr[i][0]; ans = max(ans, vl * arr[i][1]); }1 ans %= mod; ans *= precarp; ans %= mod; return ans; } long long updateY(int pos, int val){ int N = arr.size(); arr[pos][1] = val; long long vl = 1; int ind = 0; for(int i = N-1; i >= 0; i--){ vl *= arr[i][0]; if(vl > mod){ ind = i; break; } } vl = 1; long long precarp = 1; for(int i = 0; i < ind; i++){ precarp = (precarp * arr[i][0])%mod; } long long ans = 0; for(int i = ind; i < N; i++){ vl *= arr[i][0]; ans = max(ans, vl * arr[i][1]); } ans %= mod; ans *= precarp; ans %= mod; return ans; }

Compilation message (stderr)

horses.cpp:10:11: error: ambiguating new declaration of 'long long int init(int, int*, int*)'
   10 | long long init(int N, int X[], int Y[]) {
      |           ^~~~
In file included from horses.cpp:4:
horses.h:4:5: note: old declaration 'int init(int, int*, int*)'
    4 | int init(int N, int X[], int Y[]);
      |     ^~~~
horses.cpp:42:11: error: ambiguating new declaration of 'long long int updateX(int, int)'
   42 | long long updateX(int pos, int val) {
      |           ^~~~~~~
In file included from horses.cpp:4:
horses.h:5:5: note: old declaration 'int updateX(int, int)'
    5 | int updateX(int pos, int val);
      |     ^~~~~~~
horses.cpp: In function 'long long int updateX(int, int)':
horses.cpp:43:21: warning: conversion from 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   43 |     int N = arr.size();
      |             ~~~~~~~~^~
horses.cpp:64:7: error: expected ';' before 'ans'
   64 |     }1
      |       ^
      |       ;
   65 |     ans %= mod;
      |     ~~~
horses.cpp:64:6: warning: statement has no effect [-Wunused-value]
   64 |     }1
      |      ^
horses.cpp: At global scope:
horses.cpp:71:11: error: ambiguating new declaration of 'long long int updateY(int, int)'
   71 | long long updateY(int pos, int val){
      |           ^~~~~~~
In file included from horses.cpp:4:
horses.h:6:5: note: old declaration 'int updateY(int, int)'
    6 | int updateY(int pos, int val);
      |     ^~~~~~~
horses.cpp: In function 'long long int updateY(int, int)':
horses.cpp:72:21: warning: conversion from 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   72 |     int N = arr.size();
      |             ~~~~~~~~^~