Submission #712204

#TimeUsernameProblemLanguageResultExecution timeMemory
712204raysh07Horses (IOI15_horses)C++17
0 / 100
53 ms16004 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; #define ll long long int n; const int N = 5e5 + 69; const int mod = 1e9 + 7; ll x[N], y[N]; int init(int N, int X[], int Y[]) { n = N; for (int i=1; i<=n; i++) x[i] = X[i-1]; for (int i=1; i<=n; i++) y[i] = Y[i-1]; ll best = 0; int pos = -1; ll mult = 1; for (int i=n; i>=1; i--){ if (best * mult <= y[i]){ mult = 1; best = y[i]; pos = i; } mult *= x[i-1]; if (mult >= (ll)1e9) break; } assert(pos != -1); ll ans = 0; for (int i=1; i<=pos; i++) ans = (ans * x[i]) % mod; ans *= y[pos]; ans %= mod; int rans = ans; return rans; } int updateX(int pos, int val) { pos++; x[pos] = val; ll best = 0; pos = -1; ll mult = 1; for (int i=n; i>=1; i--){ if (best * mult <= y[i]){ mult = 1; best = y[i]; pos = i; } mult *= x[i-1]; if (mult >= (ll)1e9) break; } assert(pos != -1); ll ans = 0; for (int i=1; i<=pos; i++) ans = (ans * x[i]) % mod; ans *= y[pos]; ans %= mod; int rans = ans; return rans; } int updateY(int pos, int val) { pos++; y[pos] = val; ll best = 0; pos = -1; ll mult = 1; for (int i=n; i>=1; i--){ if (best * mult <= y[i]){ mult = 1; best = y[i]; pos = i; } mult *= x[i-1]; if (mult >= (ll)1e9) break; } assert(pos != -1); ll ans = 0; for (int i=1; i<=pos; i++) ans = (ans * x[i]) % mod; ans *= y[pos]; ans %= mod; int rans = ans; return rans; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:10:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   10 | int init(int N, int X[], int Y[]) {
      |          ~~~~^
horses.cpp:6:11: note: shadowed declaration is here
    6 | const int N = 5e5 + 69;
      |           ^
horses.cpp:37:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |     int rans = ans;
      |                ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:64:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   64 |      int rans = ans;
      |                 ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:92:14: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   92 |   int rans = ans;
      |              ^~~
#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...