이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
using namespace std;
using vi = vector<int>;
const int mx = (1<<20);
vi st(mx<<1, 0);
void add(int l, int r, int v)
{
if(r < l) swap(l, r);
l += mx;
r += mx+1;
while(l < r)
{
if(l & 1)
{
st[l] += v;
l++;
}
if(r & 1)
{
r--;
st[r] += v;
}
l >>= 1;
r >>= 1;
}
}
int get(int i)
{
i += mx;
int res = 0;
while(i >= 1)
{
res += st[i];
i >>= 1;
}
return res;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, M;
cin >> N >> M;
vi h(1+N);
for(int i = 1; i <= N; i++) cin >> h[i];
for(int i = 1; i < N; i++)
add(h[i], h[i+1], 1);
for(int j = 1; j <= M; j++)
{
int o;
cin >> o;
if(o == 1)
{
int i, v;
cin >> i >> v;
if(i != 1) add(h[i], h[i-1], -1);
if(i != N) add(h[i], h[i+1], -1);
h[i] = v;
if(i != 1) add(h[i], h[i-1], +1);
if(i != N) add(h[i], h[i+1], +1);
}
else
{
int H;
cin >> H;
cout << get(H) << '\n';
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |