Submission #432726

#TimeUsernameProblemLanguageResultExecution timeMemory
432726Kevin_Zhang_TW말 (IOI15_horses)C++17
34 / 100
1579 ms31528 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define pb emplace_back #define AI(i) begin(i), end(i) template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); } template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); } #ifdef KEV #define DE(args...) kout("[ " + string(#args) + " ] = ", args) void kout() { cerr << endl; } template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); } template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; } #else #define DE(...) 0 #define debug(...) 0 #endif #include "horses.h" const int MAX_N = 500010, p = 1e9 + 7; const ll inf = p; //ll dp[MAX_N], mdp[MAX_N]; int sx[MAX_N], sy[MAX_N], n; struct dint { ll val, mod_val; dint (ll a, ll b) : val(a), mod_val(b) {} dint () : val(0), mod_val(0) {} #define fastop(op) dint &operator op (const dint &b) { val = min(inf, (val op b.val)), mod_val = val op b.val % p; return *this; } fastop(*=); fastop(+=); dint operator + (const dint &b) { dint x = *this; x += b; return x; } dint operator * (const dint &b) { dint x = *this; x *= b; return x; } bool operator < (dint b) { return val < b.val; } // dint &operator *= (dint b) { // val }; struct node { ll mod_mxv, mod_mulx, lx, rx, ay; node(ll x, ll y) { mod_mxv = x * y % p; mod_mulx = x; lx = x, rx = 1; ay = y; } node () { mod_mxv = 1, mod_mulx = 1, lx = 1, rx = 1, ay = 1; } node (node a, node b) { if (min(inf, a.rx * b.lx) * b.ay > a.ay) { lx = min(inf, min(inf, a.lx * a.rx) * b.lx); rx = b.rx; ay = b.ay; mod_mxv = b.mod_mxv * a.mod_mulx % p; } else { lx = a.lx; rx = min(inf, min(inf, b.lx * b.rx) * a.rx); ay = a.ay; mod_mxv = a.mod_mxv; } mod_mulx = a.mod_mulx * b.mod_mulx % p; } ll get() { return mod_mxv; } }; node dp[MAX_N]; int init(int N, int X[], int Y[]) { n = N; copy(X, X+n, sx); copy(Y, Y+n, sy); for (int i = n-1;i >= 0;--i) { dp[i] = node( node(sx[i], sy[i]), dp[i+1] ); } return dp[0].get(); // for (int i = n-1;i >= 0;--i) { // dp[i] = max<ll>(se[i], mu[i+1] * dp[i+1]); // } } int updateX(int pos, int val) { sx[pos] = val; for (int i = n-1;i >= 0;--i) { dp[i] = node( node(sx[i], sy[i]), dp[i+1] ); } return dp[0].get(); } int updateY(int pos, int val) { sy[pos] = val; for (int i = n-1;i >= 0;--i) { dp[i] = node( node(sx[i], sy[i]), dp[i+1] ); } return dp[0].get(); }

Compilation message (stderr)

horses.cpp: In member function 'dint& dint::operator*=(const dint&)':
horses.cpp:30:60: warning: operation on '((dint*)this)->dint::val' may be undefined [-Wsequence-point]
   30 | #define fastop(op) dint &operator op (const dint &b) { val = min(inf, (val op b.val)), mod_val = val op b.val % p; return *this; }
      |                                                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:31:2: note: in expansion of macro 'fastop'
   31 |  fastop(*=);
      |  ^~~~~~
horses.cpp: In member function 'dint& dint::operator+=(const dint&)':
horses.cpp:30:60: warning: operation on '((dint*)this)->dint::val' may be undefined [-Wsequence-point]
   30 | #define fastop(op) dint &operator op (const dint &b) { val = min(inf, (val op b.val)), mod_val = val op b.val % p; return *this; }
      |                                                        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
horses.cpp:32:2: note: in expansion of macro 'fastop'
   32 |  fastop(+=);
      |  ^~~~~~
horses.cpp: In function 'int init(int, int*, int*)':
horses.cpp:86:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   86 |  return dp[0].get();
      |         ~~~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:98:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   98 |  return dp[0].get();
      |         ~~~~~~~~~^~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:106:18: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
  106 |  return dp[0].get();
      |         ~~~~~~~~~^~
#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...