# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1039835 | 2024-07-31T10:10:51 Z | Zicrus | 말 (IOI15_horses) | C++17 | 87 ms | 33920 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 OF (1ll << 30ll) #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] > OF) { segMul[pos] %= MOD; segOF[pos] = true; } 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 >= OF) 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] >= OF) { 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 | 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 | 388 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 | 436 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 | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 1 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 348 KB | Output is correct |
20 | Correct | 1 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 | 348 KB | Output is correct |
4 | Correct | 0 ms | 436 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 | 600 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 | 348 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 | 1 ms | 348 KB | Output is correct |
25 | Incorrect | 1 ms | 424 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 49 ms | 25100 KB | Output is correct |
2 | Correct | 87 ms | 33920 KB | Output is correct |
3 | Correct | 46 ms | 25148 KB | Output is correct |
4 | Correct | 69 ms | 28896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 1 ms | 436 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 | 428 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 | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 436 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 500 KB | Output is correct |
25 | Incorrect | 0 ms | 348 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 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 | 1 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 | 600 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 | 604 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 1 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Incorrect | 1 ms | 348 KB | Output isn't correct |
26 | Halted | 0 ms | 0 KB | - |