Submission #1093692

#TimeUsernameProblemLanguageResultExecution timeMemory
1093692vjudge1Foehn Phenomena (JOI17_foehn_phenomena)C++17
0 / 100
72 ms9316 KiB
#include<bits/stdc++.h> /* */namespace __DEBUG_UTIL__{/*####################---++++++++++++++++++++++++++++++++++++---------....................................................*/using namespace std; void print/*############### */(const char *x) {cerr<<x;}void print/*######---+++++++++++++++++++++++++++++++++++++++---------...........--.........................................*/(bool x) {cerr<<(x?"T":"F");}void print/*##### */(char x) {cerr<<'\''<<x<<'\'';}/*########+++++++++++++++++++++++++++++++++++++++++++++--------..........----...........................................*/void print/*################################ */(signed short int x) {cerr << x;}/*###++++++++++++++++++++++++++++++++++++++++++++++++-------...........---..................................................*/void print/*########################## *//*################################-----++++++++++++++++++++++++++++++++++++++++++++---------...................................................................*//*################################## *//*##############################--------+++++++++++++++++++++++++++++++++++++++++++--------...................................................--...---..........*//*################################# *//*############################---------+++++++++++++++++++++++++++++++++++++++++++++-------..................................................-++++++++--...........*//*############################## *//*###########################---------+++++++++++++++++++++++++++++++++++++++++++++-------..................................................-++*//*###++--...........*//*############################ *//*##########################---------+++++++++++++++++++++++++++++++++++++++++++++++-----...................................................-++*//*#####++-..........-*//*########################### *//*########################----------++++++++++++++++++++++++++++++++++++++++++++++++-----...................................................--+*//*#######+--........--*//*########################## *//*########################---------+++++++++++++++++++++++++++++++++++++++++++++++++----.....................................................--+*//*#######+--........--*//*######################### *//*######################----------++++++++++++++++++++++++++++++++++++++++++++++++-----.......................................................--++*//*######++-........--*//*######################## *//*######################---------++++++++++++++++++++++++++++++++++++++++++++++++------.........................................................--++*//*#####+--.........-*//*####################### *//*#####################-++++++++++++++++++++++++++++++++++++++++++++++++++++++-+-------...........................................................--++*//*####+--........--*//*###################### *//*####################-+++###+++++++++++++++++++++++++++++++++++++++++++++++++-+--------............................................................--++*//*##++-..........*//*###################### *//*####################+++####+++++++++++++++++++++++++++++++++++++++++++++++++++---------..............................................................-++####++-.........---*//*#################### *//*#####################+#####+++++++++++++++++++++++++++++++++++++++++++++++++++--++++----..............................................................--+++#++--..........--*//*################### *//*##########################++++++++++++++++++++++++++++++++++++++++++++++++++++-----------...............................................................--++++-...........----*//*################# *//*#########################+++++++++++++++++++++++++++++++++++++++++++++++++++++-------------...............................................................-----............----+*//*############### *//*########################++++++++++++++++++++++++++++++++++++++++++++++++++++----------------.................................................................--...............---*//*############## *//*#######################+++++++++++++++++++++++++++++++++++++++++++++++++++++------------------...................................................................................---*//*########### *//*######################++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------..................................................................................---*//*########## *//*#####################+++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------..................................................................................--*//*######### *//*#####################+++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------..................................................................................--*//*####### *//*#################+++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------..................................................................................*//*####### *//*###############+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------................................................................................--*//*##### *//*##############+++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------................................................................................-*//*#### *//*#############++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------.............................................................................--*//*### *//*############++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------.............................................................................-*//*## *//*###########+++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------........--------------..........................................................................--##### *//*##########+++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------............------------....................................................--...................---### *//*#########++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------..............------------....................................................-...................--### *//*#########+++++++++++++++++++++++++++++++++++++++++++++++--------.-----------------------------...####.......-------------.................................................--...................---# *//*########+++++++++++++++++++++++++++++++++++++++++++++++-------..------------------------------.....#..........-------------................................................-....................--- *//*#######++++++++++++++++++++++++++++++++++++++++++++++-----....--.------------------------------..............-----------------...................................................................-- *//*#######+++++++++++++++++++++++++++++++++++++++++++----------------------------------------------.......------------------------...................................................................- *//*######++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------....-----------------.-----------................................................................. *//*######++++++++++++++++++++++++++++++++++++++----------------------------------------------------.....------------------......------................................................................ *//*######++++++++++++++++++++++++++++++++++++-----------------------------------------------------------------------------............................................................................ *//*#####+++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------..----..................................................................... *//*#####++++++++++++++++++++++++++++++++++----.----------------------------------------------------------------...---....................####......................................................... *//*#####++++++++++++++++++++++++++++++++-----------------------------------------------------------.......................................####........................................................ *//*####+++++++++++++++++++++++++++++++--------------------------------------------------------.................................................................................--..................... *//*####++++++++++++++++++++++++++++-----------------------------------------------------------...............................................................................----..................... *//*###++++++++++++++++++++++++++-----------------------------------------------------......................................................................................------..................... *//*###++++++++++++++++++++++++------------------------------------------------------...........................................................................------....--------..................... *//*###+++++++++++++++++++++++-------------------------------------------------------.............................................................................----------------..................... *//*###++++++++++++++++++++---------------------------------------------------........................................................................................------------..................... *//*###+++++++++++++++++++----------------------------------------------------.............................................................................................-------..................... *//*###++++++++++++++++++-----------------------------------------------------..............................................................................................------..................... *//*###++++++++++++++++++-----------------------------------------------.----.................................................................................................----..................... *//*###++++++++++++++++++------------------------------------------------..-..................................................................................................---...................... *//*###++++++++++++++++++-----------------------------------------------......................................................................................................--....................... *//*###+++++++++++++++++----------------------------------------------........................................................................................................--....................... *//*###+++++++++++++++++----------------------------------------------.....................................................---................................................--....................... *//*###++++++++++++++++-----------------------------------------------..............................................--++++++++++++---........................................----...................... *//*###++++++++++++++----------------------------------------+++++---............................................--++++++++++++++++++++-......................................-----.................... *//*###+++++++++++++-----------------------------------++*//*#######++--........................................-+++-----+++++++---++++++--...................................------................... *//*###++++++++++++---------------------------------+++####++++++++++++++-.....................................------....--+++++++-----++++--..................................------.................. *//*###++++++++++---------------------------------++++++++-----+++++#+++--.........................................---....-+++++++++--.---+++-..................................-----.................. *//*###++++++++++-------------------------------+++#++--------..--+++++++-........................................--+-----+++++++++++-....-----...................................----................. *//*###++++++++--------------------------------+++++---------...--++++++++-.......................................-++++++++++++++++++--.....----...................................---................. *//*#####++++++-------------------------------++++---....-------+++++++++++-.....................................--+++++++++++++++++++-.......---...................................---................ -...#####+++++---------------------------------+---......--+++++++++++++++++-....................................--+++++++++++++++++++--............................................---................ --...--+##+++------------------------------------........-++++++++++++++++++-....................................-+++++--++++++---------..............................................-................ --....------------------------------------------........--++++++++++++++------...................................--+------++++----------..............................................--............... ---.....--------------------------------------...........-++++----+++++------.....................................---------------------................................................................ +---..........-------------------------------............-------------------.......................................----................................................................................ ++--...........-----------------------------..............-----.........................................................................................................................-.............. ++--................------------------------...............--...........................................................................................................................-.............. ++--...................------------------...............................................................................................................................................-------........ ++--..................###..------------.................................................................................................................................................------......... ++--.....................#####----------.................................................................................................................................................---........... +++-.........................*//*##.----............................................................................................................................................................... +++-............................*//*####----........................................................................................................................................................... +++-...---........................*//*#######.......................................................................................................................................................... +++--.---------......................*//*#########....................................-----------...................................................................................................... +++--.---------.........................*//*##########-.............................-----------------.................................................................................................. +++--.---------............................*//*###########...------................--------------------.............................................................................---................ +++--.-------------------------................*//*#########--------..............----------......................................................................................----------........... +++--.-----------------+++++++-----...............*//*######---------.............-------.....................................................................................----------------......... +++-------------------------+++++--------............*//*####--------.............------....................................................................................-----####-----------......- +++-----------------...-----------+++---------......--..#####---------.............---......................................................................................-----##++++-----------.---- +++++--------------------...-----------+++++-----------.....#----------.............-......................................................................-............---..---###++------------------ ##+++++++++--------------------------------------------------.---------...................................................................................---........---------------------------------- ####+++++++++++++++----------------------------------------------------...................................................................................--.......---------------------------------### ####++++++++#+++++++++-------------------------------------------------...............................................................................----------------------------------------------### *//*###########++++++++++++---------------------------------------------............................................................................-------------++++---------------------------++##### *//*##############+++++++++++++++------------------------------------------.......................................................................*//*##---------+++++-------------------------+#+++### *//*###############+++++++++++++++++++-------------------------------++++--------................................................*//*#####################-----------++---------------------###+++++### *//*###############++++++++++++++++++++++++++--------------------------++---------.....-------.................-*/(unsigned short int x) {cerr << x;}/*#####--------------------------------+++++++++## */void print/*#####++++++++++++++++++-+++++++++-------------------------------................*/(signed int x) {cerr << x;}void print/*########################----####-------------------+--+++++++++- *//*###############++++++++++++++++++++#####++++----------------------------............*/(unsigned int x) {cerr << x;}void print(signed long int x) {cerr << x;}/*####-------------+++++-----+++++++-- */void print/*#####++++++++++++++++++++#####++++----------------------------------........-*/(unsigned long int x) {cerr << x;}void print/*############################------------++++++----++++++++-- *//*###############++++++++++++++++++++#####++++------------......------....--------.........*/(signed long long int x) {cerr << x;}void print/*#######################+-----+++++++##+++----++++++++-- *//*###############+++++++++++++++++++++####++++------------....................................*/(unsigned long long int x) {cerr << x;}void print/*#################+++++++++++++###++++-+++++++++++- *//*###############++++++++++++++++++++++###+++------------........................................*/(float x) {cerr << x;}void print(double x) {cerr << x;}/*#########++++++++++++###++++++++++++++++# */void print/*#####+++++++++----+++++++++###+---------------.............--............................*/(long double x) {cerr << x;}void print/*######################----++++++#####+++++++++++++++++ *//*###############+++++++------+++++++++##++----------------...............---..........................*/(string x) {cerr << '\"' << x << '\"';}template <size_t N>/*#+---+++++#####+++++++++++++++++ */void print/*#####+++++--------++++++++++++++++-------------...............----............................-*/(bitset<N> x) {cerr << x;}void print(vector<bool> v) { /*#---++++*//*##++++++++++++++++- */int f = 0;/*#####++++--------+++++++++-------+++++++-------.................------...........................-*/cerr << '{';for (auto &&i : v)cerr/*###################----+++*//*##+++++++++++++++++ *//*###############+++-------++++++++++++++----+++++++-------.................--------.............................*/<< (f++ ? "," : "") << (i ? "T" : "F");/*###########---++++*//*##+++++++++++++++++ *//*##############++++----+++++++++++++++++++++-++++++--------................-----------.............................*/cerr << "}"; } template <typename T>void print/*#----++++#####+++++++++++++++++ */(T &&x);/*######+++----++++++++++++++++---++++++++++---------...............-------------------.........................*/template <typename T>void print/*############----+++*//*##+++++++++++++++++ *//*##############++++-+++++++++++++++-------+++++++-----------...............----------------------......................--.*/(vector<vector<T>> mat);/*################---++++*//*##+++++++++++++++++ *//*##############+++++++++++++++++++---------++++++-----------...............----+++----------------...........................*//*####################################+++++++*//*###++++++++++++++++# *//*##############+++++++++++++++++++--------+++++++--++-------..............----++++++-----------------..........................--*//*###############################++++++++*//*###++++++++++++++### *//*###############++++++++++++++++++--------++++++++-++--------.............---++++++++---------------------.........................*//*#############################++++++++*//*###++++++++++++++++# *//*##############+++++++++++++++++++---------+++++++-+++-------............---++++++++++-----------------------.......................-.-*//*#########################++++++++*//*####++++++++++++++++ *//*##############++++++++++++++++++++--------++++++++++++-------------....---+++++++++++++------------------------------------.....--....---*//*######################++++++++*//*####++++++++++++++++ *//*##############+++++++++++++++++++++++++---+++#++++++++++++--------------++++++++++++++++-----------------------------------------.--..-...--*//*###################++++++*//*######++++++++++++++++ *//*##############+++++++++++++++++++++++++++-+++#++++++++++####++++------++++++++++++++++++---------------------------------------------.......---*//*################++++++*//*######++++++++++++++++ *//*##############+++++++++++++++++++++++++----++#+++++++++*//*##++++++++++++++++++++++++++++-------------------------------------------------------.-*//*#############++++++*//*######++++++++++++++++ *//*##############+++++++++++++++++++++++++++++++++++++++++*//*#####++++++++++++++++++++++++++------------------------------------------------------...-*//*############+++++*//*######++++++++++++++++ *//*##############+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------*//*########################++++++++++++++++ *//*###############+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------++--------------------*//*#######+++*//*######++++++++++++++++ *//*###############++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------+++++++++++-----------------------*//*##################++++++++++++++++ *//*################+++++++++++++++++++++++++++++++++++++++++++-----++++++++++++++++++++++++++++++-------------------+++++++++++++++++++++---------------------------*//*##############++++++++++++++++ */template <typename T, size_t N, size_t M>void print(T (&mat)[N][M]);template <typename F, typename S>void print(pair<F, S> x);template <typename T, size_t N>struct Tuple;template <typename T>/*#### */struct Tuple<T, 1>;template <typename... Args>void print(tuple<Args...> t);template <typename... T>void print(priority_queue<T...> pq);template <typename T>void print(stack<T> st);/*############### */template <typename T>void print(queue<T> q); template <typename T>void print(T &&x) { int f = 0;cerr << '{';for (auto &&i : x)cerr << (f++ ? "," : ""), print(i);cerr << "}"; }/*#################### */template <typename T>void print(vector<vector<T>> mat) {int f = 0;cerr << "\n~~~~~\n";for (auto &&i : mat) {cerr << setw(2) << left << f++, print(i), cerr << "\n"; }cerr << "~~~~~\n"; }/*########## */template <typename T, size_t N, size_t M>void print(T (&mat)[N][M]) {int f = 0;cerr << "\n~~~~~\n";for (auto &&i : mat) {cerr << setw(2) << left << f++, print(i), cerr << "\n"; }/*################# */cerr << "~~~~~\n"; }template <typename F, typename S>void print(pair<F, S> x) {cerr << '(';print(x.first);cerr << ',';print(x.second);cerr << ')'; }template <typename T, size_t N>struct Tuple{/*### */static void printTuple(T t) {Tuple<T, N - 1>::printTuple(t);cerr << ",", print(get<N - 1>(t)); } };template <typename T>struct Tuple<T, 1> {static void printTuple(T t) { print(get<0>(t)); } };/*### */template <typename... Args>void print(tuple<Args...> t) {cerr << "(";Tuple<decltype(t),sizeof...(Args)>::printTuple(t);cerr << ")"; }template <typename... T>void print(priority_queue<T...> pq) {/*# */int f = 0;cerr << '{';while (!pq.empty())cerr << (f++ ? "," : ""),print(pq.top()), pq.pop();cerr << "}"; }template <typename T>void print(stack<T> st) {int f = 0;cerr << '{';while (!st.empty())/*## */cerr << (f++ ? "," : ""),print(st.top()), st.pop();cerr << "}"; }template <typename T>void print(queue<T> q) {int f = 0;cerr << '{';while (!q.empty())cerr << (f++ ? "," : ""),print/*############### */(q.front()), q.pop();cerr << "}"; }void printer(const char *) {} template <typename T, typename... V>void printer(const char *names, T &&head, V &&...tail) {int i = 0;for (size_t bracket = 0;/*#### */names[i] != '\0' and(names[i] != ',' or bracket != 0); i++)if (names[i] == '(' or names[i] == '<' or names[i] == '{')bracket++;else if (names[i] == ')' or names[i] == '>' or names[i] == '}')/*##### */bracket--;cerr.write(names, i) << " = ";print(head);if (sizeof...(tail))cerr << " ||",printer(names + i + 1, tail...);else cerr << "]\n"; }void printerArr(const char *) {} /*####################### */template <typename T, typename... V>void printerArr(const char *names, T arr[], size_t N, V... tail) {size_t ind = 0;for (; names[ind] and names[ind] != ','; ind++)cerr << names[ind];/*############ */for (ind++; names[ind] and names[ind] != ','; ind++) ;cerr << " = {";for (size_t i = 0; i < N; i++)cerr << (i ? "," : ""), print(arr[i]);cerr << "}";if (sizeof...(tail))cerr << " ||",/*############ */printerArr(names + ind + 1, tail...);else cerr << "]\n"; } }/*######################################################################################################################################## */ #ifndef ONLINE_JUDGE #define debug(...) std::cerr << __LINE__ << ": [", __DEBUG_UTIL__::printer(#__VA_ARGS__, __VA_ARGS__) #define debugArr(...) std::cerr << __LINE__ << ": [", __DEBUG_UTIL__::printerArr(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) #define debugArr(...) #endif using namespace std; int n, q, s, t; vector<int> v, dif; int ans; inline int calc(int val) { return (val > 0) ? -val * s : -val * t; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> q >> s >> t; v.resize(n + 1); dif.resize(n + 1); for (int i = 0; i <= n; ++i) { cin >> v[i]; } for (int i = 1; i <= n; ++i) { dif[i] = v[i] - v[i - 1]; ans += calc(dif[i]); } while (q--) { int st, dr, x; cin >> st >> dr >> x; ans -= calc(dif[st]); dif[st] += x; ans += calc(dif[st]); if (dr != n) { ans -= calc(dif[dr + 1]); dif[dr + 1] -= x; ans += calc(dif[dr + 1]); } cout << ans << '\n'; } return 0; }

Compilation message (stderr)

foehn_phenomena.cpp: In function 'void __DEBUG_UTIL__::print(std::stack<T>)':
foehn_phenomena.cpp:130:177: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
  130 | */int f = 0;cerr << '{';while (!pq.empty())cerr << (f++ ? "," : ""),print(pq.top()), pq.pop();cerr << "}"; }template <typename T>void print(stack<T> st) {int f = 0;cerr << '{';while (!st.empty())/*##
      |                                                                                                                                                                                 ^~~~~
foehn_phenomena.cpp:131:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
  131 | */cerr << (f++ ? "," : ""),print(st.top()), st.pop();cerr << "}"; }template <typename T>void print(queue<T> q) {int f = 0;cerr << '{';while (!q.empty())cerr << (f++ ? "," : ""),print/*###############
      |                                                      ^~~~
foehn_phenomena.cpp: In function 'void __DEBUG_UTIL__::printer(const char*, T&&, V&& ...)':
foehn_phenomena.cpp:133:135: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  133 | */names[i] != '\0' and(names[i] != ',' or bracket != 0); i++)if (names[i] == '(' or names[i] == '<' or names[i] == '{')bracket++;else if (names[i] == ')' or names[i] == '>' or names[i] == '}')/*#####
      |                                                                                                                                       ^~
foehn_phenomena.cpp:134:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  134 | */bracket--;cerr.write(names, i) << " = ";print(head);if (sizeof...(tail))cerr << " ||",printer(names + i + 1, tail...);else cerr << "]\n"; }void printerArr(const char *) {} /*#######################
      |             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...