# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1039839 | 2024-07-31T10:18:30 Z | Zicrus | 말 (IOI15_horses) | C++17 | 1500 ms | 34128 KB |
#include <bits/stdc++.h> #include "horses.h" using namespace std; typedef long long ll; ll n, pow2; vector<ll> segMul; vector<bool> segOF; vector<ll> x, y; #define MOD (1000000007) void setX(int pos, int val) { x[pos] = val; pos += pow2; segMul[pos] = val; pos /= 2; while (pos) { segMul[pos] = segMul[2*pos] * segMul[2*pos+1]; if (segOF[2*pos] || segOF[2*pos+1] || segMul[pos] > MOD) { segMul[pos] %= MOD; segOF[pos] = true; } else { segOF[pos] = false; } pos /= 2; } } int getOFId(int i = 1, ll prod = 1) { if (i >= pow2) return i-pow2; if (segOF[2*i+1] || segMul[2*i+1] * prod >= MOD) return getOFId(2*i+1, prod); return getOFId(2*i, prod * segMul[2*i+1]); } int getMulMod(int i) { int low = pow2, high = pow2+i; ll res = 1; while (low <= high) { if (low & 1) res = (res * segMul[low++]) % MOD; if (!(high & 1)) res = (res * segMul[high--]) % MOD; low /= 2; high /= 2; } return res % MOD; } int calc() { ll ofId = getOFId(); ll mx = y[ofId]; ll offCnt = getMulMod(ofId); ll tCnt = 1; ll mxRes = (y[ofId] * offCnt) % MOD; ofId++; if (!segOF[1]) { offCnt = 1; ofId = 0; mx = 0; } for (int i = ofId; i < n; i++) { offCnt *= x[i]; offCnt %= MOD; tCnt *= x[i]; ll val = tCnt * y[i]; if (val > mx) { mx = val; mxRes = (offCnt * y[i]) % MOD; } } return mxRes; } int init(int N, int X[], int Y[]) { n = N; pow2 = 1ll << (ll)ceil(log2(n)); x = vector<ll>(n); y = vector<ll>(n); for (int i = 0; i < n; i++) { x[i] = X[i]; y[i] = Y[i]; } segMul = vector<ll>(2*pow2, 1); segOF = vector<bool>(2*pow2); for (int i = 0; i < n; i++) { segMul[pow2+i] = X[i]; } for (int i = pow2-1; i > 0; i--) { segMul[i] = segMul[2*i] * segMul[2*i+1]; if (segOF[2*i] || segOF[2*i+1] || segMul[i] >= MOD) { segMul[i] %= MOD; segOF[i] = true; } } return calc(); } int updateX(int pos, int val) { setX(pos, val); return calc(); } int updateY(int pos, int val) { y[pos] = val; return calc(); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 344 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 424 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 352 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 1 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 348 KB | Output is correct |
27 | Correct | 2 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 5 ms | 348 KB | Output is correct |
30 | Correct | 2 ms | 348 KB | Output is correct |
31 | Correct | 5 ms | 444 KB | Output is correct |
32 | Correct | 3 ms | 444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 21328 KB | Output is correct |
2 | Correct | 72 ms | 21352 KB | Output is correct |
3 | Correct | 43 ms | 21412 KB | Output is correct |
4 | Correct | 69 ms | 21328 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 432 KB | Output is correct |
4 | Correct | 1 ms | 344 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 344 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 344 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 2 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 5 ms | 348 KB | Output is correct |
30 | Correct | 2 ms | 348 KB | Output is correct |
31 | Correct | 5 ms | 348 KB | Output is correct |
32 | Correct | 3 ms | 348 KB | Output is correct |
33 | Correct | 156 ms | 24660 KB | Output is correct |
34 | Correct | 25 ms | 24460 KB | Output is correct |
35 | Correct | 49 ms | 31336 KB | Output is correct |
36 | Correct | 50 ms | 31292 KB | Output is correct |
37 | Correct | 884 ms | 22632 KB | Output is correct |
38 | Correct | 22 ms | 23380 KB | Output is correct |
39 | Execution timed out | 1537 ms | 22364 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 344 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 600 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 1 ms | 344 KB | Output is correct |
27 | Correct | 2 ms | 348 KB | Output is correct |
28 | Correct | 1 ms | 392 KB | Output is correct |
29 | Correct | 5 ms | 348 KB | Output is correct |
30 | Correct | 2 ms | 348 KB | Output is correct |
31 | Correct | 5 ms | 452 KB | Output is correct |
32 | Correct | 3 ms | 348 KB | Output is correct |
33 | Correct | 45 ms | 25132 KB | Output is correct |
34 | Correct | 74 ms | 34128 KB | Output is correct |
35 | Correct | 44 ms | 25164 KB | Output is correct |
36 | Correct | 75 ms | 29128 KB | Output is correct |
37 | Correct | 154 ms | 24404 KB | Output is correct |
38 | Correct | 24 ms | 24408 KB | Output is correct |
39 | Correct | 49 ms | 31272 KB | Output is correct |
40 | Correct | 51 ms | 31376 KB | Output is correct |
41 | Correct | 954 ms | 22872 KB | Output is correct |
42 | Correct | 21 ms | 23380 KB | Output is correct |
43 | Execution timed out | 1541 ms | 22424 KB | Time limit exceeded |
44 | Halted | 0 ms | 0 KB | - |