제출 #1128789

#제출 시각아이디문제언어결과실행 시간메모리
1128789satbergenSimple game (IZhO17_game)C++20
0 / 100
1098 ms50696 KiB
#include <bits/stdc++.h> #define y1 sat #define dl double #define int long long #define ff first #define ss second // #define sz size #define pb push_back #define wrans cout << -1 #define neutral cout << 0 using namespace std; const int N=1e6+1; const int M=2600; const int MOD=1e9+7; const double long E=2.718281828459045; const double long pi=3.14159265359; const long long INF=1e18; int a[N]; // ╔╗╔╗╔╗╔╗╔╗╔╗╔═╗ // ║║║║║║║║║║║║╚╗║ // ║╚╝║║║║║║╚╝║╔╝║ // ║╔╗║║║║║║╔╗║║╔╝11 // ║║║║║╚╝║║║║║╔╗─ // ╚╝╚╝╚══╝╚╝╚╝╚╝─ // int binpow(int a,int b){ // if(b==0) return 1; // if(b%2 == 0){ // int x=binpow(a,b/2); // return (x*x)%MOD; // } // else return (a*binpow(a,b-1))%MOD; // } void solve(){ int n,m; cin >> n >> m; map <int,int> mp; for(int i = 1 ; i <= n ; i++){ cin >> a[i]; if(i>=2){ for(int j = min(a[i],a[i-1]) ; j <= max(a[i-1],a[i]) ; j++) { mp[j]++; } } } for(int i = 1 ; i <= m ; i++){ int q; cin >> q; if(q==1){ int v,h; cin >> v >> h; if(v!=1){ for(int j = min(a[v],a[v-1]) ; j <= max(a[v],a[v-1]) ; j++) mp[j]--; for(int j = min(h,a[v-1]) ; j <= max(h,a[v-1]) ; j++) mp[j]++; } if(v!=n){ for(int j = min(a[v],a[v+1]) ; j <= max(a[v],a[v+1]) ; j++) mp[j]--; for(int j = min(h,a[v+1]) ; j <= max(h,a[v+1]) ; j++) mp[j]++; } } else{ int h; cin >> h; cout << mp[h]<<'\n'; } } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); // cout.tie(0); // for(int i = 2 ; i <= INF ; i++){ // if(prime[i]==0){ // for(int j = 2 ; i*j<=INF ; j++){ // prime[i*j]=1; // } // } // } // fact(); int test=1; // cin >> test; while(test--){ solve(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...