Submission #726891

#TimeUsernameProblemLanguageResultExecution timeMemory
726891Yell0Horses (IOI15_horses)C++17
17 / 100
123 ms27048 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD=1e9+7; ll modinv(ll a) { ll res=1; for(ll i=0;(1LL<<i)<=MOD-2;++i) { if((MOD-2)&(1LL<<i)) res=res*a%MOD; a=a*a%MOD; } return res; } int N; vector<ll> bit,X,Y; void upd(int i,int a) { for(;i<=N;i+=-i&i) bit[i]=bit[i]*a%MOD; } ll qry(int i) { ll res=1; for(;i>0;i-=-i&i) res=res*bit[i]%MOD; return res; } int init(int n,int x[],int y[]) { N=n; bit.resize(N+2,1); X.resize(N+2,1); Y.resize(N+2,1); for(int i=1;i<=N;++i) { upd(i,x[i-1]); X[i]=x[i-1]; Y[i]=y[i-1]; } ll pfx=1,mx=0; int mxi; for(int i=max(1,N-35);i<=N;++i) { pfx*=X[i]; if(pfx*Y[i]>mx) { mxi=i; mx=pfx*Y[i]; } } return qry(mxi)*Y[mxi]%MOD; } int updateX(int i,int a) { ++i; upd(i,modinv(X[i])*a%MOD); X[i]=a; ll pfx=1,mx=0; int mxi; for(int i=max(1,N-35);i<=N;++i) { pfx*=X[i]; if(pfx*Y[i]>mx) { mxi=i; mx=pfx*Y[i]; } } return qry(mxi)*Y[mxi]%MOD; } int updateY(int i,int a) { ++i; Y[i]=a; ll pfx=1,mx=0; int mxi; for(int i=max(1,N-35);i<=N;++i) { pfx*=X[i]; if(pfx*Y[i]>mx) { mxi=i; mx=pfx*Y[i]; } } return qry(mxi)*Y[mxi]%MOD; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:45:25: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   45 |   return qry(mxi)*Y[mxi]%MOD;
      |          ~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:49:23: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   49 |   upd(i,modinv(X[i])*a%MOD);
      |         ~~~~~~~~~~~~~~^~~~
horses.cpp:53:11: warning: declaration of 'int i' shadows a parameter [-Wshadow]
   53 |   for(int i=max(1,N-35);i<=N;++i) {
      |           ^
horses.cpp:47:17: note: shadowed declaration is here
   47 | int updateX(int i,int a) {
      |             ~~~~^
horses.cpp:60:25: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   60 |   return qry(mxi)*Y[mxi]%MOD;
      |          ~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:67:11: warning: declaration of 'int i' shadows a parameter [-Wshadow]
   67 |   for(int i=max(1,N-35);i<=N;++i) {
      |           ^
horses.cpp:62:17: note: shadowed declaration is here
   62 | int updateY(int i,int a) {
      |             ~~~~^
horses.cpp:74:25: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   74 |   return qry(mxi)*Y[mxi]%MOD;
      |          ~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:60:24: warning: 'mxi' may be used uninitialized in this function [-Wmaybe-uninitialized]
   60 |   return qry(mxi)*Y[mxi]%MOD;
      |                        ^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:74:24: warning: 'mxi' may be used uninitialized in this function [-Wmaybe-uninitialized]
   74 |   return qry(mxi)*Y[mxi]%MOD;
      |                        ^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:45:24: warning: 'mxi' may be used uninitialized in this function [-Wmaybe-uninitialized]
   45 |   return qry(mxi)*Y[mxi]%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...