# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1039820 | 2024-07-31T09:49:49 Z | Zicrus | 말 (IOI15_horses) | C++17 | 46 ms | 23128 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 = 0; ll mxRes = 0; ll offCnt = getMulMod(ofId++); ll tCnt = 1; if (!segOF[1]) { offCnt = 1; ofId = 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 | 1 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 | 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 | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 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 | 348 KB | Output is correct |
21 | Correct | 0 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Incorrect | 1 ms | 348 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 23128 KB | Output isn't correct |
2 | 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 | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 344 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 | 1 ms | 344 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 | Incorrect | 1 ms | 348 KB | Output isn't correct |
24 | 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 | 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 | 1 ms | 356 KB | Output is correct |
21 | Correct | 1 ms | 348 KB | Output is correct |
22 | Correct | 0 ms | 356 KB | Output is correct |
23 | Incorrect | 1 ms | 348 KB | Output isn't correct |
24 | Halted | 0 ms | 0 KB | - |