# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
203602 | 2020-02-21T14:50:45 Z | mohammad | Horses (IOI15_horses) | C++14 | 147 ms | 25720 KB |
/* ░░░░██████████████████ ░░▄███████▀▀▀▀▀▀███████▄ ░▐████▀▒mohammad▒▀██████▄ ░███▀▒▒▒▒alaa▒▒▒▒▒▒▀█████ ░▐██▒▒▒alwrawrah▒▒▒▒▒████▌ ░▐█▌▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒████▌ ░░█▒▄▀▀▀▀▀▄▒▒▄▀▀▀▀▀▄▒▐███▌ ░░░▐░░░▄▄░░▌▐░░░▄▄░░▌▐███▌ ░▄▀▌░░░▀▀░░▌▐░░░▀▀░░▌▒▀▒█▌ ░▌▒▀▄░░░░▄▀▒▒▀▄░░░▄▀▒▒▄▀▒▌ ░▀▄▐▒▀▀▀▀▒▒▒▒▒▒▀▀▀▒▒▒▒▒▒█ ░░░▀▌▒▄██▄▄▄▄████▄▒▒▒▒█▀ ░░░░▄██████████████▒▒▐▌ ░░░▀███▀▀████▀█████▀▒▌ ░░░░░▌▒▒▒▄▒▒▒▄▒▒▒▒▒▒▐ ░░░░░▌▒▒▒▒▀▀▀▒▒▒▒▒▒▒▐ */ #include<bits/stdc++.h> #include "horses.h" using namespace std; typedef long long ll ; const ll oo = 1e13 ; const double PI = acos(-1) ; const ll M = 1e9 + 7 ; ll x[500010] , y[500010] , n; ll f = 1 , mp[33] ; ll fastpower( ll x , ll n ){ ll res = 1 ; while(n > 0){ if(n % 2 == 1) res = (res * x) % M; x = ( x * x ) % M; n = n / 2 ; } 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] , f = (x[i] * f) % M; ll x1 = 1 , pl = 0 , ans = 1; for(int i = max(0ll,n - 31) ; i < N ; ++i){ x1 *= x[i]; if(y[pl] < x1 * y[i]) x1 = 1 ,pl = i ; if(i != max(0ll , n - 31)) mp[i] = (mp[i - 1] * x[i]) % M; else mp[i] = x[i]; } ans = (f * fastpower(((mp[N - 1] * fastpower(mp[pl] , M - 2)) % M) , M - 2)) % M; return (ans * y[pl]) % M; } int updateX(int pos, int val){ ll pr = x[pos]; f = (f * fastpower(pr , M - 2)) % M; f = (f * val) % M; x[pos] = val; ll x1 = 1 , pl = 0 , ans = 1; for(int i = max(0ll,n - 31) ; i < n ; ++i){ x1 *= x[i]; if(y[pl] < x1 * y[i]) x1 = 1 ,pl = i ; if(i != max(0ll , n - 31)) mp[i] = (mp[i - 1] * x[i]) % M; else mp[i] = x[i]; } ans = (f * fastpower(((mp[n - 1] * fastpower(mp[pl] , M - 2)) % M) , M - 2)) % M; return (ans * y[pl]) % M; } int updateY(int pos, int val){ y[pos] = val; ll x1 = 1 , pl = 0 , ans = 1; for(int i = max(0ll,n - 31) ; i < n; ++i){ x1 *= x[i]; if(y[pl] < x1 * y[i]) x1 = 1 ,pl = i ; } ans = (f * fastpower(((mp[n - 1] * fastpower(mp[pl] , M - 2)) % M) , M - 2)) % M; return (ans * y[pl]) % M; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 256 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 4 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 504 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 376 KB | Output is correct |
20 | Correct | 5 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 504 KB | Output is correct |
13 | Correct | 5 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 256 KB | Output is correct |
20 | Correct | 4 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 256 KB | Output is correct |
23 | Incorrect | 5 ms | 376 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 80 ms | 13048 KB | Output is correct |
2 | Correct | 147 ms | 25720 KB | Output is correct |
3 | Correct | 105 ms | 17020 KB | Output is correct |
4 | Correct | 141 ms | 20728 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 504 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 4 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 376 KB | Output is correct |
13 | Correct | 4 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 376 KB | Output is correct |
19 | Correct | 5 ms | 376 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 376 KB | Output is correct |
22 | Correct | 5 ms | 376 KB | Output is correct |
23 | Incorrect | 6 ms | 376 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 5 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 5 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 5 ms | 376 KB | Output is correct |
12 | Correct | 5 ms | 268 KB | Output is correct |
13 | Correct | 5 ms | 256 KB | Output is correct |
14 | Correct | 5 ms | 376 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 376 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 5 ms | 256 KB | Output is correct |
19 | Correct | 5 ms | 376 KB | Output is correct |
20 | Correct | 5 ms | 376 KB | Output is correct |
21 | Correct | 5 ms | 256 KB | Output is correct |
22 | Correct | 5 ms | 256 KB | Output is correct |
23 | Incorrect | 5 ms | 376 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |