제출 #726928

#제출 시각아이디문제언어결과실행 시간메모리
726928Yell0말 (IOI15_horses)C++17
54 / 100
1563 ms29488 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,sfx=1,mpfx=1; int mxi,sti=N; for(int i=N;i>0;--i) { sfx*=X[i]; sti=i; if(sfx>=(ll)1e9) break; } mxi=sti; for(int i=sti;i<=N;++i) { pfx*=X[i]; if(pfx/mpfx>Y[mxi]/Y[i]) { mxi=i; mpfx=pfx; } } 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,sfx=1,mpfx=1; int mxi,sti=N; for(int i=N;i>0;--i) { sfx*=X[i]; sti=i; if(sfx>=(ll)1e9) break; } mxi=sti; for(int i=sti;i<=N;++i) { pfx*=X[i]; if(pfx/mpfx>Y[mxi]/Y[i]) { mxi=i; mpfx=pfx; } } return qry(mxi)*Y[mxi]%MOD; } int updateY(int i,int a) { ++i; Y[i]=a; ll pfx=1,sfx=1,mpfx=1; int mxi,sti=N; for(int i=N;i>0;--i) { sfx*=X[i]; sti=i; if(sfx>=(ll)1e9) break; } mxi=sti; for(int i=sti;i<=N;++i) { pfx*=X[i]; if(pfx/mpfx>Y[mxi]/Y[i]) { mxi=i; mpfx=pfx; } } return qry(mxi)*Y[mxi]%MOD; }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:51:25: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   51 |   return qry(mxi)*Y[mxi]%MOD;
      |          ~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:55:23: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   55 |   upd(i,modinv(X[i])*a%MOD);
      |         ~~~~~~~~~~~~~~^~~~
horses.cpp:59:11: warning: declaration of 'int i' shadows a parameter [-Wshadow]
   59 |   for(int i=N;i>0;--i) {
      |           ^
horses.cpp:53:17: note: shadowed declaration is here
   53 | int updateX(int i,int a) {
      |             ~~~~^
horses.cpp:65:11: warning: declaration of 'int i' shadows a parameter [-Wshadow]
   65 |   for(int i=sti;i<=N;++i) {
      |           ^
horses.cpp:53:17: note: shadowed declaration is here
   53 | int updateX(int i,int a) {
      |             ~~~~^
horses.cpp:72:25: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   72 |   return qry(mxi)*Y[mxi]%MOD;
      |          ~~~~~~~~~~~~~~~^~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:79:11: warning: declaration of 'int i' shadows a parameter [-Wshadow]
   79 |   for(int i=N;i>0;--i) {
      |           ^
horses.cpp:74:17: note: shadowed declaration is here
   74 | int updateY(int i,int a) {
      |             ~~~~^
horses.cpp:85:11: warning: declaration of 'int i' shadows a parameter [-Wshadow]
   85 |   for(int i=sti;i<=N;++i) {
      |           ^
horses.cpp:74:17: note: shadowed declaration is here
   74 | int updateY(int i,int a) {
      |             ~~~~^
horses.cpp:92:25: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   92 |   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...