Submission #1121832

#TimeUsernameProblemLanguageResultExecution timeMemory
1121832SalihSahinHorses (IOI15_horses)C++14
17 / 100
1537 ms13772 KiB
#include <bits/stdc++.h> #define pb push_back using namespace std; #include "horses.h" const long long mod = 1e9 + 7; vector<array<long long, 2> > arr; int n; int init(int N, int X[], int Y[]) { arr.resize(N); n = N; for(int i = 0; i < N; i++){ arr[i] = {X[i], Y[i]}; } long long vl = 1; int ind = 0; for(int i = N-1; i >= 0; i--){ vl *= arr[i][0]; if(vl > mod){ ind = i; break; } } vl = 1; long long precarp = 1; for(int i = 0; i < ind; i++){ precarp = (precarp * arr[i][0])%mod; } long long ans = 0; for(int i = ind; i < N; i++){ vl *= arr[i][0]; ans = max(ans, vl * arr[i][1]); } ans %= mod; ans *= precarp; ans %= mod; int res = ans; return res; } int updateX(int pos, int val) { int N = n; arr[pos][0] = val; long long vl = 1; int ind = 0; for(int i = N-1; i >= 0; i--){ vl *= arr[i][0]; if(vl > mod){ ind = i; break; } } vl = 1; long long precarp = 1; for(int i = 0; i < ind; i++){ precarp = (precarp * arr[i][0])%mod; } long long ans = 0; for(int i = ind; i < N; i++){ vl *= arr[i][0]; ans = max(ans, vl * arr[i][1]); } ans %= mod; ans *= precarp; ans %= mod; int res = ans; return res; } int updateY(int pos, int val){ int N = n; arr[pos][1] = val; long long vl = 1; int ind = 0; for(int i = N-1; i >= 0; i--){ vl *= arr[i][0]; if(vl > mod){ ind = i; break; } } vl = 1; long long precarp = 1; for(int i = 0; i < ind; i++){ precarp = (precarp * arr[i][0])%mod; } long long ans = 0; for(int i = ind; i < N; i++){ vl *= arr[i][0]; ans = max(ans, vl * arr[i][1]); } ans %= mod; ans *= precarp; ans %= mod; int res = ans; return res; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:41:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   41 |     int res = ans;
      |               ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:71:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   71 |     int res = ans;
      |               ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:102:15: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  102 |     int res = 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...