Submission #712203

#TimeUsernameProblemLanguageResultExecution timeMemory
712203raysh07Horses (IOI15_horses)C++17
Compilation error
0 ms0 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; #define ll long long int n; const int N = 5e5 + 69; const int mod = 1e9 + 7; ll x[N], y[N]; int init(int N, int X[], int Y[]) { n = N; for (int i=1; i<=n; i++) x[i] = X[i-1]; for (int i=1; i<=n; i++) y[i] = Y[i-1]; ll best = 0; int pos = -1; ll mult = 1; for (int i=n; i>=1; i--){ if (best * mult <= y[i]){ mult = 1; best = y[i]; pos = i; } mult *= x[i-1]; if (mult >= 1e9) break; } assert(pos != -1); ll ans = 0; for (int i=1; i<=pos; i++) ans = (ans * x[i]) % mod; ans *= y[pos]; ans %= mod; return ans; } int updateX(int pos, int val) { pos++; x[pos] = val; ll best = 0; int pos = -1; ll mult = 1; for (int i=n; i>=1; i--){ if (best * mult <= y[i]){ mult = 1; best = y[i]; pos = i; } mult *= x[i-1]; if (mult >= 1e9) break; } assert(pos != -1); ll ans = 0; for (int i=1; i<=pos; i++) ans = (ans * x[i]) % mod; ans *= y[pos]; ans %= mod; return ans; } int updateY(int pos, int val) { pos++; y[pos] = val; ll best = 0; int pos = -1; ll mult = 1; for (int i=n; i>=1; i--){ if (best * mult <= y[i]){ mult = 1; best = y[i]; pos = i; } mult *= x[i-1]; if (mult >= 1e9) break; } assert(pos != -1); ll ans = 0; for (int i=1; i<=pos; i++) ans = (ans * x[i]) % mod; ans *= y[pos]; ans %= mod; return ans; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:10:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   10 | int init(int N, int X[], int Y[]) {
      |          ~~~~^
horses.cpp:6:11: note: shadowed declaration is here
    6 | const int N = 5e5 + 69;
      |           ^
horses.cpp:27:13: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   27 |         if (mult >= 1e9) break;
      |             ^~~~
horses.cpp:37:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:44:9: error: declaration of 'int pos' shadows a parameter
   44 |     int pos = -1;
      |         ^~~
horses.cpp:40:17: note: 'int pos' previously declared here
   40 | int updateX(int pos, int val) {
      |             ~~~~^~~
horses.cpp:53:13: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   53 |         if (mult >= 1e9) break;
      |             ^~~~
horses.cpp:63:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   63 |  return ans;
      |         ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:71:9: error: declaration of 'int pos' shadows a parameter
   71 |     int pos = -1;
      |         ^~~
horses.cpp:66:17: note: 'int pos' previously declared here
   66 | int updateY(int pos, int val) {
      |             ~~~~^~~
horses.cpp:80:13: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   80 |         if (mult >= 1e9) break;
      |             ^~~~
horses.cpp:90:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   90 |  return ans;
      |         ^~~