# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128751 | raisel | Simple game (IZhO17_game) | C++20 | 2 ms | 320 KiB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#define forn for(int i=1;i<=n;i++)
#define Yes cout<<"YES\n"
#define No cout<<"NO\n"
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define pb push_back
#define sp setprecision
#define int long long
#define ll long long
#define nn '\n'
using namespace std;
const int N=1e6+26;
const int MOD=1e9+7;
int a[N];
int n,m;
void al(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
}
while(m--){
int type;
cin>>type;
if(type==1){
int x,y;
cin>>x>>y;
a[x]=y;
}
else {
int x;
cin>>x;
int cnt=0;
for(int i=1;i<n;i++){
if((a[i]<=x && a[i+1]>=x) || (a[i]>=x && a[i+1]<=x)) cnt++;
}
cout<<cnt<<'\n';
}
}
}
signed main(){
freopen("game.in","r",stdin);
freopen("game.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;
// cin>>t;
while(t--) {
al();
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |