Submission #929054

#TimeUsernameProblemLanguageResultExecution timeMemory
929054OAleksaHorses (IOI15_horses)C++14
17 / 100
1520 ms10424 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 5e5 + 69; int n, a[N], b[N]; int mul(int a, int b) { long long r = 1ll * a * b; if (r >= mod) r %= mod; return r; } int init(int N, int X[], int Y[]) { n = N; for (int i = 0;i < n;i++) a[i] = X[i], b[i] = Y[i]; long long ans = 0, x = 1; for (int i = 0;i < n;i++) { x *= a[i]; ans = max(ans, x * b[i]); } return ans % mod; } int updateX(int pos, int val) { a[pos] = val; long long ans = 0, x = 1; for (int i = 0;i < n;i++) { x *= a[i]; ans = max(ans, x * b[i]); } return ans % mod; } int updateY(int pos, int val) { b[pos] = val; long long ans = 0, x = 1; for (int i = 0;i < n;i++) { x *= a[i]; ans = max(ans, x * b[i]); } return ans % mod; }

Compilation message (stderr)

horses.cpp: In function 'int mul(int, int)':
horses.cpp:7:20: warning: declaration of 'b' shadows a global declaration [-Wshadow]
    7 | int mul(int a, int b) {
      |                ~~~~^
horses.cpp:6:14: note: shadowed declaration is here
    6 | int n, a[N], b[N];
      |              ^
horses.cpp:7:13: warning: declaration of 'a' shadows a global declaration [-Wshadow]
    7 | int mul(int a, int b) {
      |         ~~~~^
horses.cpp:6:8: note: shadowed declaration is here
    6 | int n, a[N], b[N];
      |        ^
horses.cpp:11:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   11 |    return r;
      |           ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:13:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   13 | int init(int N, int X[], int Y[]) {
      |          ~~~~^
horses.cpp:5:11: note: shadowed declaration is here
    5 | const int N = 5e5 + 69;
      |           ^
horses.cpp:22:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   22 |    return ans % mod;
      |           ~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:32:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   32 |    return ans % mod;
      |           ~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:42:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   42 |    return ans % mod;
      |           ~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...