Submission #60072

#TimeUsernameProblemLanguageResultExecution timeMemory
60072dukati8Horses (IOI15_horses)C++14
0 / 100
1530 ms14592 KiB
#include "horses.h" #include <bits/stdc++.h> #define rep(i,a,b) for(int i=a; i<int(b); i++) using namespace std; int n; long long x[500000],y[500000]; long long m=1e9+7; pair<long long,long long> invgcd(long long a, long long b) { //Returns x and y such that ax+by=1 if (a==1 && b==0) return make_pair(1,0); long long c=a%b; long long d=a/b; pair<long long, long long > ans = invgcd(b,c); return make_pair(ans.second,ans.first-ans.second*d); } long long inverse(long long a) { pair<long long, long long > ans = invgcd(m,a); return ans.second; } int init(int N, int X[], int Y[]) { n=N; rep (i,0,n) { x[i]=X[i]; y[i]=Y[i]; } long long product=1; rep (i,0,n) { product*=x[i]; product%=m; } long long hi=y[n-1]; long long divide=1; for (int i = n-2; i<=0; i--) { hi*=x[i+1]; hi=max(hi,y[i]); divide*=x[i+1]; if (hi>1e9) break; } long long ans=hi*product; ans%=m; ans*=inverse(divide); ans%=m; return ans; } int updateX(int pos, int val) { x[pos]=val; long long product=1; rep (i,0,n) { product*=x[i]; product%=m; } long long hi=y[n-1]; long long divide=1; for (int i = n-2; i<=0; i--) { hi*=x[i+1]; hi=max(hi,y[i]); divide*=x[i+1]; if (hi>1e9) break; } long long ans=hi*product; ans%=m; ans*=inverse(divide); ans%=m; return ans; } int updateY(int pos, int val) { y[pos]=val; long long product=1; rep (i,0,n) { product*=x[i]; product%=m; } long long hi=y[n-1]; long long divide=1; for (int i = n-2; i<=0; i--) { hi*=x[i+1]; hi=max(hi,y[i]); divide*=x[i+1]; if (hi>1e9) break; } long long ans=hi*product; ans%=m; ans*=inverse(divide); ans%=m; return ans; }

Compilation message (stderr)

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:40:10: warning: conversion to 'double' from 'long long int' may alter its value [-Wconversion]
   if (hi>1e9) break;
          ^~~
horses.cpp:46:9: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return ans;
         ^~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:64:10: warning: conversion to 'double' from 'long long int' may alter its value [-Wconversion]
   if (hi>1e9) break;
          ^~~
horses.cpp:70:9: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  return ans;
         ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:86:10: warning: conversion to 'double' from 'long long int' may alter its value [-Wconversion]
   if (hi>1e9) break;
          ^~~
horses.cpp:92:9: warning: conversion to 'int' from 'long long int' may alter its value [-Wconversion]
  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...