Submission #946988

#TimeUsernameProblemLanguageResultExecution timeMemory
946988Nika533Horses (IOI15_horses)C++17
17 / 100
43 ms16220 KiB
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #include "horses.h" #define pb push_back #define f first #define s second #define MOD 1000000007 #define flush fflush(stdout) #define all(x) (x).begin(),(x).end() #define allr(x) (x).rbegin(), (x).rend() #define pii pair<int,int> using namespace std; const int N=5e5+5; int n,m,T,k; long long arr[N],x[N],y[N]; int power(int a, int b) { int res=1; while (b) { if (b%2) { res*=a; res%=MOD; } b/=2; a*=a; a%=MOD; } return res; } int init(int N, int X[], int Y[]) { n=N; for (int i=0; i<n; i++) { x[i]=X[i]; y[i]=Y[i]; } arr[0]=x[0]; for (int i=1; i<n; i++) { arr[i]=arr[i-1]*x[i]; arr[i]%=MOD; } for (int i=0; i<n; i++) { arr[i]*=y[i]; arr[i]%=MOD; } int ind=n-1; int num=1e9; long long p=1; for (int i=n-1; i>=0; i--) { p*=x[i]; if (p<=num) ind=i; else break; } long long mx=0,idx; long long a=1; for (int i=ind; i<n; i++) { a*=x[i]; if (a*y[i]>mx) { idx=i; mx=a*y[i]; } } int ARR=arr[idx]; return ARR; } int updateX(int pos, int val) { for (int i=max(pos,n-35); i<n; i++) { arr[i]*=val; arr[i]%=MOD; //arr[i]/=x[pos]; arr[i]*=power(x[pos],MOD-2); arr[i]%=MOD; } x[pos]=val; int ind=n-1; int num=1e9; long long p=1; for (int i=n-1; i>=0; i--) { p*=x[i]; if (p<=num) ind=i; else break; } long long mx=0,idx; long long a=1; for (int i=ind; i<n; i++) { a*=x[i]; if (a*y[i]>mx) { idx=i; mx=a*y[i]; } } int ARR=arr[idx]; return ARR; } int updateY(int pos, int val) { arr[pos]*=val; arr[pos]%=MOD; //arr[pos]/=y[pos]; arr[pos]*=power(y[pos],MOD-2); arr[pos]%=MOD; y[pos]=val; int ind=n-1; int num=1e9; long long p=1; for (int i=n-1; i>=0; i--) { p*=x[i]; if (p<=num) ind=i; else break; } long long mx=0,idx; long long a=1; for (int i=ind; i<n; i++) { a*=x[i]; if (a*y[i]>mx) { idx=i; mx=a*y[i]; } } int ARR=arr[idx]; return ARR; }

Compilation message (stderr)

horses.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:29:14: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   29 | int init(int N, int X[], int Y[]) {
      |          ~~~~^
horses.cpp:13:11: note: shadowed declaration is here
   13 | const int N=5e5+5;
      |           ^
horses.cpp:62:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   62 |  int ARR=arr[idx];
      |          ~~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:70:22: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   70 |   arr[i]*=power(x[pos],MOD-2); arr[i]%=MOD;
      |                 ~~~~~^
horses.cpp:91:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   91 |  int ARR=arr[idx];
      |          ~~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:98:23: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   98 |  arr[pos]*=power(y[pos],MOD-2); arr[pos]%=MOD;
      |                  ~~~~~^
horses.cpp:118:17: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
  118 |  int ARR=arr[idx];
      |          ~~~~~~~^
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:62:17: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   62 |  int ARR=arr[idx];
      |          ~~~~~~~^
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:91:17: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   91 |  int ARR=arr[idx];
      |          ~~~~~~~^
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:118:17: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
  118 |  int ARR=arr[idx];
      |          ~~~~~~~^
#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...