online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<ld, ld> pd; typedef vector<int> vi; typedef vector<pi> vpi; typedef vector<bool> vb; typedef vector<ll> vll; typedef vector<ld> vd; template<class T> using pq = priority_queue<T>; template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define F0R(i, a) FOR(i, 0, a) #define FORd(i, a, b) for (int i = (b) - 1; i >= a; i--) #define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--) #define trav(a, x) for (auto &a : x) #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define f first #define s second #define lb lower_bound #define ub upper_bound #define all(x) x.begin(), x.end() #define ins insert #define endl '\n' #ifndef ONLINE_JUDGE #include "debug.h" #else #define deb(x...) #endif const int MOD = 1e9 + 7; const int MX = 200001; void solve() { int n; cin >> n; vi a(n); F0R(i, n) cin >> a[i]; map<int, vi> M; F0R(i, n) { M[a[i]].pb(i); } int q; cin >> q; while (q--) { int l, r, x; cin >> l >> r >> x; l--; r--; if (M.find(x) == M.end()) { cout << 0 << endl; } else { auto b = M[x]; auto p = lb(all(b), l); auto q = ub(all(b), r); cout << (q - p) << endl; } } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); solve(); return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue