제출 #734865

#제출 시각아이디문제언어결과실행 시간메모리
734865phoebe말 (IOI15_horses)C++17
17 / 100
1574 ms39820 KiB
#include <bits/stdc++.h> #include "horses.h" using namespace std; #define ll long long const int INF = 1e9 + 7, maxn = 5e5 + 10; ll n, x[maxn], total = 1, tree[maxn * 4] = {0}; set<int> bruh; void update(int x, int v, int tl = 0, int tr = maxn, int i = 1){ if (tl > x || x > tr) return; if (tl == tr){ tree[i] = v; return; } int tm = (tl + tr) / 2; update(x, v, tl, tm, i * 2); update(x, v, tm + 1, tr, i * 2 + 1); tree[i] = max(tree[i * 2], tree[i * 2 + 1]); } ll query(int l, int r, int tl = 0, int tr = maxn, int i = 1){ if (l > tr || tl > r) return 0; if (l <= tl && tr <= r) return tree[i]; int tm = (tl + tr) / 2; return max(query(l, r, tl, tm, i * 2), query(l, r, tm + 1, tr, i * 2 + 1)); } ll mod_inverse(ll a){ ll e = INF - 2, re = 1; while (e){ if (e % 2) re = (re * a) % INF; a = (a * a) % INF; e /= 2; } return re; } int solve(){ ll re = 1, product = 1; int start = 0; for (auto it = bruh.rbegin(); it != bruh.rend(); it++){ if (product * x[*it] > (1<<32)) break; start = *it; product *= x[*it]; } product = 1; for (auto it = bruh.lower_bound(start); it != bruh.end(); it++){ int i = *it; product *= x[i]; ll best_y = query(i, n); re = max(re, best_y * product); } ll pre = (total * mod_inverse(product)) % INF; re %= INF; re = (re * pre) % INF; return (int)re; } int init(int N, int X[], int Y[]){ n = N; x[0] = 1; bruh.insert(0); for (int i = 1; i <= n; i++){ x[i] = X[i - 1]; update(i, Y[i - 1]); if (x[i] == 1) continue; total = (total * x[i]) % INF; bruh.insert(i); } return solve(); } int updateX(int pos, int val){ pos++; if (x[pos] != 1){ total = (total * mod_inverse(x[pos])) % INF; bruh.erase(pos); } x[pos] = val; if (x[pos] != 1){ total = (total * x[pos]) % INF; bruh.insert(pos); } return solve(); } int updateY(int pos, int val){ pos++; update(pos, val); return solve(); }

컴파일 시 표준 에러 (stderr) 메시지

horses.cpp: In function 'void update(int, int, int, int, int)':
horses.cpp:11:17: warning: declaration of 'x' shadows a global declaration [-Wshadow]
   11 | void update(int x, int v, int tl = 0, int tr = maxn, int i = 1){
      |             ~~~~^
horses.cpp:8:7: note: shadowed declaration is here
    8 | ll n, x[maxn], total = 1, tree[maxn * 4] = {0};
      |       ^
horses.cpp: In function 'int solve()':
horses.cpp:42:34: warning: left shift count >= width of type [-Wshift-count-overflow]
   42 |         if (product * x[*it] > (1<<32)) break;
      |                                 ~^~~~
horses.cpp:49:30: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   49 |         ll best_y = query(i, n);
      |                              ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...