/*
Uruchamiamy samolot zwiadowczy ( + 500% do wzlamaniej )
/▄/ /█/ /◐/ /▐/ /▌/ /▀/ /░/ /🔥/ choose own style!
***IT'S OUR LONG WAY TO THE OIILLLL***
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀🔥░░░░░░░░███░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░█▌░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▀██████████████████████████████████████████████████
░░░░░░░░░░░░░░░░░░░░░░░░░░▄▄▄████▄████████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ █████
░░░░░░░░░░░░░░░░░░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█████████▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░◐◐◐█████████▀▀▀▀▀▀🔥░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████████░░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░████████░░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░███████░░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░██████░░░░░░░░░░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█████░░░░░░░░░░░░░░░
*/
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
//#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define fi first
#define se second
#define eb emplace_back
#define pii pair < int , int >
#define pipii pair< int, pair < int , int > >
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());
//#include <ext/pb_ds/detail/standard_policies.hpp>'
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;template <typename T> using ordered_set = tree <T, null_type, less< T >, rb_tree_tag,tree_order_statistics_node_update>;
namespace fastio {template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}template<class T1, class T2> ostream& operator << (ostream& os, const pair<T1, T2>& p) { return os << p.first << " " << p.second; }template <class T> ostream &operator<<(ostream &os, set<T> const& con) { for (auto &u : con) os << u << " "; return os; }void pr() {}template <typename T, typename... args> void pr(T x, args... tail) { cout << x << " "; pr(tail...);}}using namespace fastio;
const int N = 1e5 + 5;
const int MA = 1e6 + 1;
const int X[4] = {0, 0, 1, -1};
const int Y[4] = {-1, 1, 0, 0};
int t[MA * 4], add[MA * 4];
void push(int v, int tl, int tr)
{
t[v] += add[v];
if (tl != tr)
{
add[v << 1] += add[v];
add[v << 1 | 1] += add[v];
}
add[v] = 0;
}
void ad(int v, int tl, int tr, int l, int r, int val)
{
if (add[v])
push(v, tl, tr);
if (l > r)
return;
if (tl == l && tr == r)
{
add[v] += val;
push(v, tl, tr);
return;
}
int tm = (tl + tr) >> 1;
ad(v << 1, tl, tm, l, min(tm, r), val);
ad(v << 1 | 1, tm + 1, tr, max(tm + 1, l), r, val);
}
int solve(int v, int tl, int tr, int pos)
{
if (add[v])
push(v, tl, tr);
if (tl == tr)
return t[v];
int tm =(tl + tr) >> 1;
if (pos <= tm)
return solve(v << 1, tl, tm, pos);
return solve(v << 1 | 1, tm + 1, tr, pos);
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#ifdef Estb_probitie
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#else
freopen("game.in","r",stdin);
freopen("game.out","w",stdout);
#endif
int n, m;
cin >> n >> m;
int a[n];
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 1; i < n; ++i)
ad(1, 1, 1e6, min(a[i], a[i - 1]), max(a[i - 1], a[i]), 1);
for (int i = 0; i < m; ++i)
{
int ty;
cin >> ty;
if (ty == 1)
{
int pos, val;
cin >> pos >> val;
--pos;
for (int i = -1; i <= 1; i += 2)
{
if (pos)
ad(1, 1, 1e6, min(a[pos - 1], a[pos]), max(a[pos - 1], a[pos]), i);
if (pos + 1 < n)
ad(1, 1, 1e6, min(a[pos], a[pos + 1]), max(a[pos], a[pos + 1]), i);
a[pos] = val;
}
} else
{
int h;
cin >> h;
cout << solve(1, 1, 1e6, h) << '\n';
}
}
}
Compilation message
bootfall.cpp: In function 'int solve(int, int, int, int)':
bootfall.cpp:96:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
if (pos <= tm)
^~
bootfall.cpp:98:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
return solve(v << 1 | 1, tm + 1, tr, pos);
^~~~~~
bootfall.cpp: In function 'int main()':
bootfall.cpp:108:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen("game.in","r",stdin);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~
bootfall.cpp:109:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
freopen("game.out","w",stdout);
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |