# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
946991 | 2024-03-15T09:31:01 Z | Nika533 | Horses (IOI15_horses) | C++14 | 45 ms | 18844 KB |
#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]; long long power(int a, int b) { long long 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; long long 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; long long 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4440 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4528 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4540 KB | Output is correct |
12 | Correct | 1 ms | 4700 KB | Output is correct |
13 | Correct | 1 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4440 KB | Output is correct |
17 | Correct | 1 ms | 4536 KB | Output is correct |
18 | Correct | 1 ms | 4440 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4548 KB | Output is correct |
3 | Correct | 1 ms | 4440 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4544 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4440 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 2 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 45 ms | 18844 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4444 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4444 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4444 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4440 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4548 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Incorrect | 1 ms | 4536 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4444 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4444 KB | Output is correct |
4 | Correct | 1 ms | 4444 KB | Output is correct |
5 | Correct | 1 ms | 4444 KB | Output is correct |
6 | Correct | 1 ms | 4444 KB | Output is correct |
7 | Correct | 1 ms | 4440 KB | Output is correct |
8 | Correct | 1 ms | 4444 KB | Output is correct |
9 | Correct | 1 ms | 4444 KB | Output is correct |
10 | Correct | 1 ms | 4444 KB | Output is correct |
11 | Correct | 1 ms | 4444 KB | Output is correct |
12 | Correct | 1 ms | 4444 KB | Output is correct |
13 | Correct | 1 ms | 4544 KB | Output is correct |
14 | Correct | 1 ms | 4444 KB | Output is correct |
15 | Correct | 1 ms | 4444 KB | Output is correct |
16 | Correct | 1 ms | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 1 ms | 4440 KB | Output is correct |
21 | Incorrect | 1 ms | 4444 KB | Output isn't correct |
22 | Halted | 0 ms | 0 KB | - |