Submission #1086293

#TimeUsernameProblemLanguageResultExecution timeMemory
1086293RiverFlowHorses (IOI15_horses)C++14
34 / 100
1587 ms12108 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) const int N = (int)5e5 + 7; const int mod = (int)1e9 + 7; int add(int a, int b) { return a + b < mod ? a + b : a + b - mod; } int sub(int a, int b) { return a >= b ? a - b : a - b + mod; } int mul(int a, int b) { return 1LL * a * b % mod; } int n, x[N], y[N]; #define nl "\n" #define ll long long const ll LIM = (int)1e10; int fx() { ll mx = 0; int ans = 0; FOD(i, n - 1, 0) { if (y[i] >= mx) { ans = i; } mx = max(mx, (ll)y[i]); mx = min(LIM, mx * x[i]); } return ans; } int init(int N, int X[], int Y[]) { n = N; FOR(i, 0, n - 1) x[i] = X[i], y[i] = Y[i]; int px = fx(), ans = 1; FOR(i, 0, px) ans = mul(ans, x[i]); return mul(ans, y[px]); } int updateX(int pos, int val) { x[pos] = val; int px = fx(), ans = 1; FOR(i, 0, px) ans = mul(ans, x[i]); return mul(ans, y[px]); } int updateY(int pos, int val) { y[pos] = val; int px = fx(), ans = 1; FOR(i, 0, px) ans = mul(ans, x[i]); return mul(ans, y[px]); }

Compilation message (stderr)

horses.cpp: In function 'int mul(int, int)':
horses.cpp:17:44: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   17 | int mul(int a, int b) { return 1LL * a * b % mod; }
      |                                ~~~~~~~~~~~~^~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:39:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   39 | int init(int N, int X[], int Y[]) {
      |          ~~~~^
horses.cpp:11:11: note: shadowed declaration is here
   11 | const int N = (int)5e5 + 7;
      |           ^
#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...