제출 #432734

#제출 시각아이디문제언어결과실행 시간메모리
432734Kevin_Zhang_TW말 (IOI15_horses)C++17
100 / 100
287 ms60808 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]; node val[MAX_N << 1]; void modify(int i) { val[i+n] = node(sx[i], sy[i]); i += n; while (i>>=1) val[i] = node(val[i<<1], val[i<<1|1]); } int qry(int l, int r) { l += n, r += n; node lv, rv; for (;l < r;l>>=1, r>>=1) { if (l&1) lv = node(lv, val[l++]); if (r&1) rv = node(val[--r], rv); } return node(lv, rv).get(); } 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) { modify(i); //dp[i] = node( node(sx[i], sy[i]), dp[i+1] ); } return qry(0, n); //return dp[0].get(); } int updateX(int pos, int val) { sx[pos] = val; modify(pos); // for (int i = n-1;i >= 0;--i) { // dp[i] = node( node(sx[i], sy[i]), dp[i+1] ); // } return qry(0, n); //return dp[0].get(); } int updateY(int pos, int val) { sy[pos] = val; modify(pos); // for (int i = n-1;i >= 0;--i) { // dp[i] = node( node(sx[i], sy[i]), dp[i+1] ); // } return qry(0, n); //return dp[0].get(); }

컴파일 시 표준 에러 (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 qry(int, int)':
horses.cpp:93:25: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   93 |  return node(lv, rv).get();
      |         ~~~~~~~~~~~~~~~~^~
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:108:26: warning: declaration of 'val' shadows a global declaration [-Wshadow]
  108 | int updateX(int pos, int val) {
      |                      ~~~~^~~
horses.cpp:78:6: note: shadowed declaration is here
   78 | node val[MAX_N << 1];
      |      ^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:118:26: warning: declaration of 'val' shadows a global declaration [-Wshadow]
  118 | int updateY(int pos, int val) {
      |                      ~~~~^~~
horses.cpp:78:6: note: shadowed declaration is here
   78 | node val[MAX_N << 1];
      |      ^~~
#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...