제출 #1039952

#제출 시각아이디문제언어결과실행 시간메모리
1039952c2zi6말 (IOI15_horses)C++14
54 / 100
1531 ms65464 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<typename T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "horses.h" const ll MOD = 1e9 + 7; struct SEGTREEPROD { int n; VL tree; SEGTREEPROD(){} SEGTREEPROD(int sz) { n = 1; while (n < sz) n *= 2; tree = VL(2*n); } void upd(int N, int L, int R, int i, int s) { if (i < L || i > R) return; if (L == R) { tree[N] = s; return; } int M = (L + R) / 2; upd(2*N+1, L, M, i, s); upd(2*N+2, M+1, R, i, s); tree[N] = tree[2*N+1] * tree[2*N+2] % MOD; } int get(int N, int L, int R, int l, int r) { if (l <= L && R <= r) return tree[N]; if (R < l || L > r) return 1; int M = (L + R) / 2; return 1ll * get(2*N+1, L, M, l, r) * get(2*N+2, M+1, R, l, r) % MOD; } void upd(int i, int s) { upd(0, 0, n-1, i, s); } int get(int l, int r) { return get(0, 0, n-1, l, r); } }; struct SEGTREEMAX { int n; VL tree; SEGTREEMAX(){} SEGTREEMAX(int sz) { n = 1; while (n < sz) n *= 2; tree = VL(2*n); } void upd(int N, int L, int R, int i, int s) { if (i < L || i > R) return; if (L == R) { tree[N] = s; return; } int M = (L + R) / 2; upd(2*N+1, L, M, i, s); upd(2*N+2, M+1, R, i, s); tree[N] = max(tree[2*N+1], tree[2*N+2]); } int get(int N, int L, int R, int l, int r) { if (l <= L && R <= r) return tree[N]; if (R < l || L > r) return -2e9; int M = (L + R) / 2; return max(get(2*N+1, L, M, l, r), get(2*N+2, M+1, R, l, r)); } void upd(int i, int s) { upd(0, 0, n-1, i, s); } int get(int l, int r) { return get(0, 0, n-1, l, r); } }; int n; VL a, b; SEGTREEPROD sega; SEGTREEMAX segb; set<int> nonone; ll recalc() { ll leave = n-1; ll prod = 1; for (auto it = prev(nonone.end()); it != nonone.begin(); it--) {} reprl(i, n-1, 0) { if (b[i] > prod) { prod = a[i] * b[i]; leave = i; } else { prod = a[i] * prod; } if (prod > 1e9) break; } return sega.get(0, leave) * b[leave] % MOD; } int init(int N, int X[], int Y[]) { n = N; a = b = VL(n); rep(i, n) { a[i] = X[i]; b[i] = Y[i]; } sega = SEGTREEPROD(n); rep(i, n) sega.upd(i, a[i]); segb = SEGTREEMAX(n); rep(i, n) segb.upd(i, b[i]); rep(i, n) if (a[i] != 1) nonone.insert(i); return recalc(); } int updateX(int pos, int val) { if (a[pos] != 1) nonone.erase(pos); a[pos] = val; if (a[pos] != 1) nonone.insert(pos); sega.upd(pos, a[pos]); return recalc(); } int updateY(int pos, int val) { b[pos] = val; segb.upd(pos, b[pos]); return recalc(); }

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

horses.cpp: In member function 'int SEGTREEPROD::get(int, int, int, int, int)':
horses.cpp:57:44: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   57 |         if (l <= L && R <= r) return tree[N];
      |                                            ^
horses.cpp:60:72: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   60 |         return 1ll * get(2*N+1, L, M, l, r) * get(2*N+2, M+1, R, l, r) % MOD;
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
horses.cpp: In member function 'int SEGTREEMAX::get(int, int, int, int, int)':
horses.cpp:90:44: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
   90 |         if (l <= L && R <= r) return tree[N];
      |                                            ^
horses.cpp: In function 'll recalc()':
horses.cpp:120:13: warning: conversion from 'll' {aka 'long long int'} to 'double' may change value [-Wconversion]
  120 |         if (prod > 1e9) break;
      |             ^~~~
horses.cpp:122:21: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  122 |  return sega.get(0, leave) * b[leave] % MOD;
      |                     ^~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:133:31: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
  133 |     rep(i, n) sega.upd(i, a[i]);
      |                               ^
horses.cpp:135:31: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
  135 |     rep(i, n) segb.upd(i, b[i]);
      |                               ^
horses.cpp:137:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  137 |     return recalc();
      |            ~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:144:25: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
  144 |     sega.upd(pos, a[pos]);
      |                         ^
horses.cpp:145:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  145 |  return recalc();
      |         ~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:150:25: warning: conversion from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' may change value [-Wconversion]
  150 |     segb.upd(pos, b[pos]);
      |                         ^
horses.cpp:151:15: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  151 |  return recalc();
      |         ~~~~~~^~
#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...