Submission #1004386

#TimeUsernameProblemLanguageResultExecution timeMemory
1004386vjudge1Horses (IOI15_horses)C++17
17 / 100
1584 ms14336 KiB
#include "horses.h" #include <bits/stdc++.h> #define ll long long #define mod 1000000007 using namespace std; int n; vector<ll> x, y; ll calc(){ ll ma = 0; ll prmult = 1, prmod = -1, nmod = 0; for (int i = 0; i < n; i++){ prmult *= x[i]; if (prmult >= mod){ prmult %= mod; prmod = nmod; nmod = 0; } ll res; if (prmod != -1){ ll res = 1ll * (mod + prmult) * y[i]; nmod = max(nmod, res); } else{ ll res = 1ll * prmult * y[i]; nmod = max(nmod, res); } } return max(prmod, nmod) % mod; } int init(int N, int X[], int Y[]) { n = N; x.resize(N), y.resize(N); for (int i = 0; i < N; i++){ x[i] = X[i]; y[i] = Y[i]; } return calc(); } int updateX(int pos, int val){ x[pos] = val; return calc(); } int updateY(int pos, int val) { y[pos] = val; return calc(); }

Compilation message (stderr)

horses.cpp: In function 'long long int calc()':
horses.cpp:20:7: warning: declaration of 'res' shadows a previous local [-Wshadow]
   20 |    ll res = 1ll * (mod + prmult) * y[i];
      |       ^~~
horses.cpp:18:6: note: shadowed declaration is here
   18 |   ll res;
      |      ^~~
horses.cpp:24:7: warning: declaration of 'res' shadows a previous local [-Wshadow]
   24 |    ll res = 1ll * prmult * y[i];
      |       ^~~
horses.cpp:18:6: note: shadowed declaration is here
   18 |   ll res;
      |      ^~~
horses.cpp:18:6: warning: unused variable 'res' [-Wunused-variable]
horses.cpp:9:5: warning: unused variable 'ma' [-Wunused-variable]
    9 |  ll ma = 0;
      |     ^~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:38:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   38 |  return calc();
      |         ~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:43:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   43 |  return calc();
      |         ~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:48:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   48 |  return calc();
      |         ~~~~^~
#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...