제출 #1128417

#제출 시각아이디문제언어결과실행 시간메모리
1128417erasyl123Simple game (IZhO17_game)C++20
49 / 100
1095 ms12728 KiB
#include <bits/stdc++.h> #define int long long #define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); using namespace std; const int N = 1e6+5; const int inf = 1e9; const int mod=1e9+7; struct edge{ int pos,val,t; }; vector<int>v; vector<edge>v1; int dp[N]; signed main(){ //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); boost int n,m; cin>>n>>m; v.push_back(0); for(int i=1;i<=n;i++){ int x; cin>>x; v.push_back(x); } int cnt=0; for(int i=1;i<=m;i++){ int x; cin>>x; if(x==1){ edge y; cin>>y.pos>>y.val; y.t=1; v1.push_back(y); }else{ edge y; cin>>y.val; y.pos=0; y.t=2; cnt++; v1.push_back(y); } } if(cnt==m){ for(int i=1;i<n;i++){ int l=min(v[i],v[i+1]); int r=max(v[i],v[i+1]); dp[l]++; dp[r+1]--; } for(int i=1;i<=N-5;i++){ dp[i]+=dp[i-1]; } for(int i=1;i<=m;i++){ cout<<dp[v1[i-1].val]<<"\n"; } return 0; }else{ for(int i=1;i<=m;i++){ if(v1[i-1].t==1){ v[v1[i-1].pos]=v1[i-1].val; continue; }else{ int ans=0; int y=v1[i-1].val; for(int i=1;i<n;i++){ int l=min(v[i],v[i+1]); int r=max(v[i],v[i+1]); if(l<=y&&y<=r){ ans++; } } cout<<ans<<"\n"; } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...