Submission #718512

#TimeUsernameProblemLanguageResultExecution timeMemory
718512mseebacherHorses (IOI15_horses)C++17
17 / 100
1556 ms8144 KiB
#include "horses.h" #include <stdio.h> #include <stdlib.h> #include <iostream> #include <string> #include <vector> #include <cmath> #include <cstring> #include <algorithm> #include <iomanip> #include <map> #include <set> #include <stack> #include <queue> #include <functional> #include <iostream> #include <fstream> #include <string> using namespace std; vector<int> x; vector<int> y; int n; double logp(int i){ return log2(i); } int expp(double i){ return round(pow(2,i)); } const double MOD = logp(1e9+7); int calc(){ double horses = logp(1); double p = 0; for(int i = 0;i<n;i++){ horses += logp(x[i]); p = max(p,horses+logp(y[i])); } int a = p/MOD; p -= a*MOD; return expp(p); } int init(int N, int X[], int Y[]) { n = N; x.assign(N,0); y.assign(N,0); for(int i = 0;i<n;i++){ x[i] = X[i]; y[i] = Y[i]; } return calc(); } int updateX(int pos, int val) { x[pos] = val; return calc(); } int updateY(int pos, int val) { y[pos] = val; return calc(); }

Compilation message (stderr)

horses.cpp: In function 'int expp(double)':
horses.cpp:31:14: warning: conversion from 'double' to 'int' may change value [-Wfloat-conversion]
   31 |  return round(pow(2,i));
      |         ~~~~~^~~~~~~~~~
horses.cpp: In function 'int calc()':
horses.cpp:45:11: warning: conversion from 'double' to 'int' may change value [-Wfloat-conversion]
   45 |  int a = p/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...