Submission #1088298

#TimeUsernameProblemLanguageResultExecution timeMemory
1088298dostsHorses (IOI15_horses)C++17
0 / 100
40 ms34452 KiB
#include "horses.h" #include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define all(cont) cont.begin(),cont.end() #define vi vector<int> const int MOD = 1e9+7,inf = 2e14; const int N = 5e5+50; int add(int x,int y) { return ((x+y) >= MOD ? x+y-MOD : x+y); } int mult(int x,int y) { return ((x%MOD)*(y%MOD))%MOD; } int x[N],y[N],pref[N]; int32_t init(int32_t N, int32_t X[], int32_t Y[]) { for (int i=0;i<N;i++) x[i] = X[i],y[i] = Y[i]; pref[0] = x[0]; for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]); int mm = 1; int p = 0; for (int i=N-1;i>=0;i--) { mm*=x[i]; if (mm >= 1e10) { p = i; break; } } int mx = 0,ans = 0; mm = 1; for (int i=p-(N-p);i<N;i++) { mm*=x[i]; if (mm*y[i] > mx) { mx = mm*y[i]; ans = mult(pref[i],y[i]); } } return ans; } int32_t updateX(int32_t pos, int32_t val) { x[pos] = val; pref[0] = x[0]; for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]); int mm = 1; int p = 0; for (int i=N-1;i>=0;i--) { mm*=x[i]; if (mm >= 1e10) { p = i; break; } } int mx = 0,ans = 0; mm = 1; for (int i=p-(N-p);i<N;i++) { mm*=x[i]; if (mm*y[i] > mx) { mx = mm*y[i]; ans = mult(pref[i],y[i]); } } return ans; } int32_t updateY(int32_t pos, int32_t val) { y[pos] = val; pref[0] = x[0]; for (int i=1;i<N;i++) pref[i] = mult(pref[i-1],x[i]); int mm = 1; int p = 0; for (int i=N-1;i>=0;i--) { mm*=x[i]; if (mm >= 1e10) { p = i; break; } } int mx = 0,ans = 0; mm = 1; for (int i=p-(N-p);i<N;i++) { mm*=x[i]; if (mm*y[i] > mx) { mx = mm*y[i]; ans = mult(pref[i],y[i]); } } return ans; }

Compilation message (stderr)

horses.cpp: In function 'int32_t init(int32_t, int32_t*, int32_t*)':
horses.cpp:23:22: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   23 | int32_t init(int32_t N, int32_t X[], int32_t Y[]) {
      |              ~~~~~~~~^
horses.cpp:12:11: note: shadowed declaration is here
   12 | const int N = 5e5+50;
      |           ^
horses.cpp:31:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   31 |   if (mm >= 1e10) {
      |       ^~
horses.cpp:45:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   45 |  return ans;
      |         ^~~
horses.cpp: In function 'int32_t updateX(int32_t, int32_t)':
horses.cpp:56:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   56 |   if (mm >= 1e10) {
      |       ^~
horses.cpp:70:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   70 |  return ans;
      |         ^~~
horses.cpp: In function 'int32_t updateY(int32_t, int32_t)':
horses.cpp:81:7: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
   81 |   if (mm >= 1e10) {
      |       ^~
horses.cpp:95:9: warning: conversion from 'long long int' to 'int32_t' {aka 'int'} may change value [-Wconversion]
   95 |  return 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...