Submission #238044

#TimeUsernameProblemLanguageResultExecution timeMemory
238044KubinHorses (IOI15_horses)C++17
0 / 100
67 ms9208 KiB
#include <bits/stdc++.h> using namespace std; size_t n; uint X[1 << 19], Y[1 << 19]; uint64_t product = 1; const uint MOD = 1e9 + 7; uint power(uint a, uint b) { uint r = 1; while(b) { if(b) r = (uint64_t) r * a % MOD; a = (uint64_t) a * a % MOD; b /= 2; } return r; } uint inverse(uint x) { return power(x, MOD - 2); } uint compute() { uint64_t j = n-1, li = 1, lj = 1; for(size_t i = n; i --> 1 and li < UINT_MAX; ) { if(Y[j] * li < Y[i-1] * lj) j = i-1, lj = li; li *= X[i]; // prod * inverse(l) % MOD * Y[i] % MOD; } return product * inverse(lj) % MOD * Y[j-1] % MOD; } int init(int _n, int x[], int y[]) { n = _n; copy(x, x + n, X); copy(y, y + n, Y); for(size_t i = 0; i < n; i++) product = (product * X[i]) % MOD; return compute(); } int updateX(int pos, int val) { product = product * inverse(X[pos]) % MOD * val % MOD; X[pos] = val; return compute(); } int updateY(int pos, int val) { Y[pos] = val; return compute(); }

Compilation message (stderr)

horses.cpp: In function 'uint power(uint, uint)':
horses.cpp:15:36: warning: conversion to 'uint {aka unsigned int}' from 'uint64_t {aka long unsigned int}' may alter its value [-Wconversion]
         if(b) r = (uint64_t) r * a % MOD;
                   ~~~~~~~~~~~~~~~~~^~~~~
horses.cpp:16:30: warning: conversion to 'uint {aka unsigned int}' from 'uint64_t {aka long unsigned int}' may alter its value [-Wconversion]
         a = (uint64_t) a * a % MOD;
             ~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In function 'uint compute()':
horses.cpp:33:32: warning: conversion to 'uint {aka unsigned int}' from 'uint64_t {aka long unsigned int}' may alter its value [-Wconversion]
     return product * inverse(lj) % MOD * Y[j-1] % MOD;
                                ^
horses.cpp:33:49: warning: conversion to 'uint {aka unsigned int}' from 'uint64_t {aka long unsigned int}' may alter its value [-Wconversion]
     return product * inverse(lj) % MOD * Y[j-1] % 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...