제출 #1134500

#제출 시각아이디문제언어결과실행 시간메모리
1134500AgageldiSimple game (IZhO17_game)C++17
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define N 20000005 #define pb push_back #define ff first #define ss second #define sz(s) (int)s.size() ll n, t, a[N], p[N], m, fb[N], fg[N], vis[N]; void solve(int x,int y,int bal) { while(x > 0) { fb[x] += bal; x -= (x&(-x)); } while(y <= 1e6) { fg[y] += bal; y += (y&(-y)); } } int find(int x,int y) { int sum = 0; while(x > 0) { sum += fg[x]; x-= (x&(-x)); } while(y <= 1e6) { sum += fb[y]; y += (y & (-y)); } return sum; } int main (){ ios::sync_with_stdio(0);cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++) { cin >> a[i]; vis[a[i]]++; if(i > 1) solve(min(a[i],a[i-1]), max(a[i],a[i - 1]), 1); } for(int i = 1; i <= m; i++) { int x, y; cin >> t; if(t == 1) { cin >> x >> y; continue; } cin >> x; int ans = find(x,x); cout << n - 1 - ans + vis[x] << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...