# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
996821 | 2024-06-11T09:46:29 Z | hasan2006 | 말 (IOI15_horses) | C++17 | 857 ms | 58284 KB |
#include <bits/stdc++.h> //#include "horses.h" using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e5 + 9 , mod = 1e9 +7; ll a[N] , b[N] , d[N] , c[N] , dp[N] , t[4 * N]; void pushup(int i){ t[i] = max(t[2 * i] , t[2 * i + 1]); } void add(int i , int l , int r , int tl , int tr , int x){ int m = (l + r) / 2; if(l > tr || r < tl) return; if(l >= tl && r <= tr){ t[i] = x; }else { add(2 * i , l , m , tl , tr , x); add(2 * i + 1 , m + 1 , r , tl , tr , x); pushup(i); } } ll get(int i , int l , int r , int tl , int tr){ int m = (l + r) / 2; if(l > tr || r < tl) return 0; if(l >= tl && r <= tr){ return t[i]; } else return max(get(2 * i , l , m , tl , tr) , get(2 * i + 1 , m + 1 , r , tl , tr)); } ll f = 1 , n; set<int>st; ll binpow(ll x , ll n){ ll ans = 1; while(n > 0){ if(n % 2) ans = (ans * x) % mod , n--; else x = (x * x) % mod , n /= 2; } return ans; } ll divmod(ll a , ll b){ return (a * binpow(b % mod , mod - 2)) % mod; } ll mul(ll a , ll b){ return (a * b) % mod; } int getans(){ ll l , r = n - 1, x= 1 , k = f; if(st.find(0) == st.end()) st.insert(0); auto it = st.end(); it--; //cout<<x<<" "<<k<<"\n"; while(1){ l = get(1 , 1 , n , *it + 1 , r + 1 ); x = max(x , l); k = divmod(k , a[*it]); x *= a[*it]; if(x > mod) return ((x % mod) * k) % mod; if(it == st.begin()) break; r = *it - 1; it--; } return (x % mod) * k % mod; } int init(int N, int X[], int Y[]) { n = N; for(int i = 0; i < n; i++){ a[i] = X[i] , b[i] = Y[i]; f = (f * a[i]) % mod; if(a[i] > 1) st.insert(i); add(1 , 1 , n , i + 1 , i + 1 , b[i]); } return getans(); } int updateX(int pos, int val) { f = divmod(f , a[pos]); if(a[pos] > 1) st.erase(pos); a[pos] = val; f = mul(f , a[pos]); if(a[pos] > 1) st.insert(pos); return getans(); } int updateY(int pos, int val) { add(1 , 1 , n , pos + 1 , pos + 1 , val); return getans(); } /* int main(){ int a[] = {2 , 1 , 3}; int b[] = {3 , 4 , 1}; }*/ // Author : حسن
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 0 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 | 4440 KB | Output is correct |
10 | Correct | 1 ms | 4440 KB | Output is correct |
11 | Correct | 1 ms | 4440 KB | Output is correct |
12 | Correct | 1 ms | 4440 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 | 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 | 4696 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 1 ms | 4444 KB | Output is correct |
3 | Correct | 1 ms | 4700 KB | Output is correct |
4 | Correct | 1 ms | 4544 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 | 0 ms | 4548 KB | Output is correct |
10 | Correct | 1 ms | 4700 KB | Output is correct |
11 | Correct | 1 ms | 4548 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 | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 0 ms | 4444 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 1 ms | 4544 KB | Output is correct |
21 | Correct | 1 ms | 4696 KB | Output is correct |
22 | Correct | 1 ms | 4444 KB | Output is correct |
23 | Correct | 1 ms | 4444 KB | Output is correct |
24 | Correct | 2 ms | 4444 KB | Output is correct |
25 | Correct | 2 ms | 4556 KB | Output is correct |
26 | Correct | 2 ms | 4444 KB | Output is correct |
27 | Correct | 6 ms | 4600 KB | Output is correct |
28 | Correct | 3 ms | 4440 KB | Output is correct |
29 | Correct | 2 ms | 4552 KB | Output is correct |
30 | Correct | 2 ms | 4444 KB | Output is correct |
31 | Correct | 5 ms | 4444 KB | Output is correct |
32 | Correct | 7 ms | 4444 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 853 ms | 45584 KB | Output is correct |
2 | Correct | 315 ms | 58108 KB | Output is correct |
3 | Correct | 368 ms | 49236 KB | Output is correct |
4 | Correct | 327 ms | 53076 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 4440 KB | Output is correct |
2 | Correct | 0 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 | 4540 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 | 4440 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 | 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 | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4544 KB | Output is correct |
22 | Correct | 1 ms | 4444 KB | Output is correct |
23 | Correct | 1 ms | 4444 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 2 ms | 4444 KB | Output is correct |
26 | Correct | 1 ms | 4444 KB | Output is correct |
27 | Correct | 6 ms | 4444 KB | Output is correct |
28 | Correct | 3 ms | 4444 KB | Output is correct |
29 | Correct | 2 ms | 4444 KB | Output is correct |
30 | Correct | 2 ms | 4444 KB | Output is correct |
31 | Correct | 5 ms | 4444 KB | Output is correct |
32 | Correct | 6 ms | 4440 KB | Output is correct |
33 | Correct | 89 ms | 25176 KB | Output is correct |
34 | Correct | 91 ms | 25264 KB | Output is correct |
35 | Correct | 224 ms | 55288 KB | Output is correct |
36 | Correct | 235 ms | 55312 KB | Output is correct |
37 | Correct | 152 ms | 23376 KB | Output is correct |
38 | Correct | 148 ms | 36180 KB | Output is correct |
39 | Correct | 84 ms | 23176 KB | Output is correct |
40 | Correct | 199 ms | 50444 KB | Output is correct |
41 | Correct | 121 ms | 23124 KB | Output is correct |
42 | Correct | 151 ms | 23120 KB | Output is correct |
43 | Correct | 200 ms | 50904 KB | Output is correct |
44 | Correct | 201 ms | 50768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 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 | 4504 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 | 4444 KB | Output is correct |
17 | Correct | 1 ms | 4444 KB | Output is correct |
18 | Correct | 1 ms | 4544 KB | Output is correct |
19 | Correct | 1 ms | 4444 KB | Output is correct |
20 | Correct | 1 ms | 4444 KB | Output is correct |
21 | Correct | 1 ms | 4444 KB | Output is correct |
22 | Correct | 1 ms | 4444 KB | Output is correct |
23 | Correct | 1 ms | 4552 KB | Output is correct |
24 | Correct | 1 ms | 4444 KB | Output is correct |
25 | Correct | 2 ms | 4444 KB | Output is correct |
26 | Correct | 1 ms | 4600 KB | Output is correct |
27 | Correct | 6 ms | 4600 KB | Output is correct |
28 | Correct | 3 ms | 4620 KB | Output is correct |
29 | Correct | 2 ms | 4700 KB | Output is correct |
30 | Correct | 1 ms | 4444 KB | Output is correct |
31 | Correct | 5 ms | 4444 KB | Output is correct |
32 | Correct | 7 ms | 4444 KB | Output is correct |
33 | Correct | 857 ms | 49168 KB | Output is correct |
34 | Correct | 346 ms | 58284 KB | Output is correct |
35 | Correct | 383 ms | 49496 KB | Output is correct |
36 | Correct | 319 ms | 53076 KB | Output is correct |
37 | Correct | 96 ms | 25172 KB | Output is correct |
38 | Correct | 89 ms | 25172 KB | Output is correct |
39 | Correct | 241 ms | 55480 KB | Output is correct |
40 | Correct | 209 ms | 55264 KB | Output is correct |
41 | Correct | 157 ms | 23380 KB | Output is correct |
42 | Correct | 154 ms | 36000 KB | Output is correct |
43 | Correct | 83 ms | 23376 KB | Output is correct |
44 | Correct | 190 ms | 50468 KB | Output is correct |
45 | Correct | 121 ms | 23172 KB | Output is correct |
46 | Correct | 161 ms | 23384 KB | Output is correct |
47 | Correct | 190 ms | 50864 KB | Output is correct |
48 | Correct | 197 ms | 50804 KB | Output is correct |
49 | Correct | 166 ms | 28248 KB | Output is correct |
50 | Correct | 145 ms | 28160 KB | Output is correct |
51 | Correct | 419 ms | 57352 KB | Output is correct |
52 | Correct | 262 ms | 56916 KB | Output is correct |
53 | Correct | 856 ms | 26360 KB | Output is correct |
54 | Correct | 309 ms | 40020 KB | Output is correct |
55 | Correct | 168 ms | 24032 KB | Output is correct |
56 | Correct | 270 ms | 52196 KB | Output is correct |
57 | Correct | 585 ms | 24856 KB | Output is correct |
58 | Correct | 776 ms | 25224 KB | Output is correct |
59 | Correct | 192 ms | 50764 KB | Output is correct |