제출 #1134921

#제출 시각아이디문제언어결과실행 시간메모리
1134921coolsentenceidontrememberSjeckanje (COCI21_sjeckanje)C++20
110 / 110
716 ms40916 KiB
/* code on line 47 lel
##########################################################################################
################################+++*%#++++#%+++++##*++%%*+*###############################
###############################*----@+----%%-----##+--=@=-=%##############################
###############################*----*-----%*--=--+#+---+=-=%##############################
###############################*--+---=---%=--#--=%+------=%##############################
###############################*--*=--*---%---+---%+--+---=%##############################
###############################*--*+--#---#---+=--*+--@=--=%##############################
#####################%%%########++##++%+++#+++%#++**++%%++*###############################
##################%@@@@@@%################################################################
##################@@@@@%##################################################################
###################@@@%%%*################################################################
####################%%%%%#*###############################################################
####################%%%###################################################################
#################%%@@@@@%#################################################################
################%@@@@@@@@@####################################***********#################
################@@@@@@@@@@#################################***************################
################@@@@@@@@@@%##############################********************#############
################@@@@@@@%%%##############################******++++++++********############
################%@@@@@@#%%#############################******=-------+********############
#################@@@@@@%%%#############################******=-------+********############
%%###############@@@@@@@%@%############################******=------=+*****###############
%@%%%%###########%@@@@@@@%@############################%%%#*#++*+++++*#####%%####%%###%%%%
@@@%%%%%%%%%%%%%%@@@@@@@@@%%#%%%%%%@%%%%%%%%%%%%%%%%%%%%%@@@@@@@@@@@%%@@@@@%@@@@@%@%%%%%%%
%%%%%%%%@@@%%%%%%@@@@@@@@@@%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@%@@@@@@@@%@@@@@@@@@@@@@@@@@@@@@
@%%%%%%@@@@@@@@@@%@@@@@@@@@@%%%%%@@@%%@@%@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
%%%%%%%%%@%@@@@@@@@@@@@@@@@@%%%@@%@%@@@@%@@@@%%@%@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@%%%%%%@@@@@@@@@@@@@@@@@@@@@@%%@@@%%@%%%@@@@%%@@@@@@@@%%@@@@@@@@@@%@@@@@@@@@@@@%%@@@@@@@@@
%@@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@@@@@@@%%%@%@%%%%%%%%%@@@@@@@@@@@@@@@@@@@@@@%@@%@@@%@%@%%%%%%@@@
%%%%%%%@%%@@@@@@@@@@@@@@@@@@@@@%%%@%@%%%%%%%%%%%%%%@@@@@@@@@@@@@@@@@@@@@@@@@@@@%%%%%%%@@@@
%%@%%%@@@@@@@%@@@@@@@%@%@@@@%%%%%%%%%%%%%%@%%%%%%%%%%%%%@@@@@@@@@%@@@@@@@@@%%@%%@%@@@@@@@@
@@@@@@@@@@@@@@@@@@%%%%%%@@@@@%%@@@@%%%%%@@@@%%%%%%%%%%%%%%%%%@%%@@@@@@@@@@@@@@@@@@@@@@@@@@
%@@@@@@@@@@@@@@@@%%%%%%@%@@@@@@%@%@@@@%%@%%%%%%@@%@%@%%%%%%%%%%%%@@@@@@@@@@@@@@@@@@%@@@@@@
@@@@@@@@@@@@@@@@@@@@@%%%%%%%%%%%%%@@%%%%@%%%%%%@%@@%%@%%%%%%%%%%%%@@@%@@@%@@@@@@@@@%@@@%@@
*/
#include "bits/stdc++.h"
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pii pair<int, int>
#define mp make_pair


void setIO(std::string s = ""){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
 if (!s.empty()){
	freopen((s+".in").c_str(), "r", stdin);
	freopen((s+".out").c_str(), "w", stdout);
	}
}

const int N = 2e5 + 1;

struct node {
  ll l, r;
  ll dp[2][2];
  node(){
    l = r = dp[0][0] = dp[0][1] = dp[1][0] = dp[1][1] = 0;
  }
};
std::vector<node> st;

node merge(node l, node r){
  node ret;
  ret.l = l.l;
  ret.r = r.r;
  for (int x = 0; x < 2; x++){
    for (int y = 0; y < 2; y++){
      for (int m = 0; m < 2; m++) {
        for (int mm = 0; mm < 2; mm++){
          if (m && mm){
            if ((l.r < 0) == (r.l < 0)){
              ret.dp[x][y] = std::max(ret.dp[x][y], l.dp[x][m] + r.dp[mm][y]);
            }
          } else {
              ret.dp[x][y] = std::max(ret.dp[x][y], l.dp[x][m] + r.dp[mm][y]);
            }
          }
        }
      }
    }
  return ret;
  }


void upd(int id, int l, int r, int p, int v){
  if (l == r){
    st[id].l += v;
    st[id].r += v;
    st[id].dp[0][1] = st[id].dp[0][0] = st[id].dp[1][0] = 0;
    st[id].dp[1][1] = abs(st[id].l);
    return;
  }
  int m = (l + r) >> 1;
  if (p <= m) upd(id<<1, l, m, p, v);
  else upd(id<<1|1, m+1, r, p, v);
  st[id] = merge(st[id<<1], st[id<<1|1]);
}
int main(){
  int n, q;
  std::cin >> n >> q;
  st = std::vector<node>(4*n);
  int pre, post;
  std::cin >> pre;
  for (int i = 0; i < n-1; i++) {
    std::cin >> post;
    upd(1, 0, n-2, i, post - pre);
    std::swap(pre, post);
  }
  for (int i = 1; i <= q; i++){
    int l, r;
    ll x;
    std::cin >> l >> r >> x;
    l--; r--;
    if (l-1 >= 0) upd(1, 0, n-2, l-1, x);
    if (r < n-1) upd(1, 0, n-2, r, -x);
    std::cout << st[1].dp[1][1] << '\n';
  }
}

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

Main.cpp: In function 'void setIO(std::string)':
Main.cpp:61:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         freopen((s+".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen((s+".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...