제출 #233882

#제출 시각아이디문제언어결과실행 시간메모리
233882triple_fault말 (IOI15_horses)C++14
17 / 100
84 ms56568 KiB
#include "horses.h" #include <vector> #include <algorithm> #include <cstdio> #define MAX 500001 typedef int64_t ll; ll MOD = 1e9 + 7; using namespace std; ll seg[4 * MAX]; vector<pair<ll, ll>> lazy(4 * MAX, {1, 1}); ll n; ll pp[MAX]; ll y[MAX]; ll x[MAX]; void build(ll v, ll tl, ll tr) { if (tl == tr) seg[v] = pp[tl] * y[tr]; else { ll mid = (tl + tr) / 2; build(v * 2, tl, mid); build((v * 2) + 1, mid + 1, tr); seg[v] = max(seg[v * 2], seg[(v * 2) + 1]); } } void push(ll v) { if (lazy[v].first != 1 || lazy[v].second != 1) { ll f = lazy[v].first, s = lazy[v].second; lazy[v * 2].first *= f; lazy[v * 2].second *= s; lazy[(v * 2) + 1].first *= f; lazy[(v * 2) + 1].second *= s; lazy[v] = {1, 1}; seg[v * 2] /= s; seg[v * 2] *= f; seg[(v * 2) + 1] /= s; seg[(v * 2) + 1] *= f; } } void update(ll numer, ll denom, ll v, ll l, ll r, ll tl, ll tr) { if (l > r) return; if (tl == l && tr == r) { lazy[v].first *= numer; lazy[v].second *= denom; seg[v] /= denom; seg[v] *= numer; return; } push(v); ll mid = (tl + tr) / 2; update(numer, denom, v * 2, l, min(r, mid), tl, mid); update(numer, denom, (v * 2) + 1, max(l, mid + 1), r, mid + 1, tr); seg[v] = max(seg[v * 2], seg[(v * 2) + 1]); } void update_specific(ll v, ll idx, ll l, ll r, ll nw) { if (l > r) return; if (l == idx && r == idx) { seg[v] /= y[idx]; seg[v] *= nw; return; } push(v); ll mid = (l + r) / 2; if (idx <= mid) update_specific(v * 2, idx, l, mid, nw); else update_specific((v * 2) + 1, idx, mid + 1, r, nw); seg[v] = max(seg[v * 2], seg[(v * 2) + 1]); } int init(int N, int X[], int Y[]) { n = (ll)N; for (ll i = 0; i < n; ++i) y[i] = (ll)Y[i]; for (ll i = 0; i < n; ++i) x[i] = (ll)X[i]; pp[0] = x[0]; for (ll i = 1; i < n; ++i) pp[i] = pp[i - 1] * x[i]; build(1, 0, n - 1); return seg[1] % MOD; } int updateX(int pos, int val) { update((ll)val, x[pos], 1, (ll)pos, n - 1, 0, n - 1); x[pos] = (ll)val; return seg[1] % MOD; } int updateY(int pos, int val) { update_specific(1, (ll)pos, 0, n - 1, val); y[pos] = (ll)val; return seg[1] % MOD; }

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

horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:80:16: warning: conversion to 'int' from 'll {aka long int}' may alter its value [-Wconversion]
  return seg[1] % MOD;
         ~~~~~~~^~~~~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:86:16: warning: conversion to 'int' from 'll {aka long int}' may alter its value [-Wconversion]
  return seg[1] % MOD;
         ~~~~~~~^~~~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:92:16: warning: conversion to 'int' from 'll {aka long int}' may alter its value [-Wconversion]
  return seg[1] % MOD;
         ~~~~~~~^~~~~
#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...