Submission #1013630

#TimeUsernameProblemLanguageResultExecution timeMemory
1013630MardonbekhazratovHorses (IOI15_horses)C++17
17 / 100
1594 ms18364 KiB
#include "horses.h" #include<algorithm> #include<vector> #include<iostream> const __int128_t INFLL=1e18; const int INF=1e9; const int MOD=1e9+7; using namespace std; int n; vector<int>x,y; int inv(int x){ return x>1 ? MOD-(long long)(MOD/x)*inv(MOD%x)%MOD : x; } long long pref; int get(){ vector<__int128_t>suff(n+2); suff[n]=1; for(int i=n-1;i>=0;i--){ suff[i]=max(suff[i+1]*x[i],suff[n]*x[i]*y[i]); pref=pref*inv(x[i])%MOD; if(suff[i]>=INFLL){ long long ans=suff[i]%MOD; pref; return ans; } } return suff[0]%MOD; } int init(int N, int X[], int Y[]) { n=N; pref=1; x.resize(n); y.resize(n); for(int i=0;i<n;i++) x[i]=X[i],y[i]=Y[i],pref=pref*x[i]%MOD; return get(); } int updateX(int pos, int val) { pref=pref*inv(x[pos])%MOD*val%MOD; x[pos]=val; return get(); } int updateY(int pos, int val) { y[pos]=val; return get(); }

Compilation message (stderr)

horses.cpp: In function 'int inv(int)':
horses.cpp:14:13: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   14 | int inv(int x){
      |         ~~~~^
horses.cpp:12:12: note: shadowed declaration is here
   12 | vector<int>x,y;
      |            ^
horses.cpp:15:13: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   15 |  return x>1 ? MOD-(long long)(MOD/x)*inv(MOD%x)%MOD : x;
      |         ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp: In function 'int get()':
horses.cpp:27:25: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'long long int' may change value [-Wconversion]
   27 |    long long ans=suff[i]%MOD;
horses.cpp:28:4: warning: statement has no effect [-Wunused-value]
   28 |    pref;
      |    ^~~~
horses.cpp:29:11: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   29 |    return ans;
      |           ^~~
horses.cpp:32:16: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<__int128>, __int128>::value_type' {aka '__int128'} to 'int' may change value [-Wconversion]
   32 |  return suff[0]%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...