Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define int long long
- const int inf = 1e9;
- ll M2 = 1e9 + 9, M1 = 1e9 + 7;
- //mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
- void solve() {
- int n;
- cin >> n;
- vector<vector<int>> g(n + 1);
- vector<int> a(n);
- map<int, int> maps;
- for (auto &i : a) {
- cin >> i;
- maps[i] += 1;
- }
- int num = 1;
- for (auto &[i, j] : maps) {
- j = num;
- num += 1;
- }
- for (auto &i : a) i = maps[i];
- for (int i = 0; i < n; ++i) {
- g[a[i]].push_back(i);
- }
- int q;
- cin >> q;
- while (q--) {
- int l, r, x;
- cin >> l >> r >> x;
- --l, --r;
- if (maps[x] == 0) {
- cout << "0";
- continue;
- }
- int res = upper_bound(g[maps[x]].begin(), g[maps[x]].end(), r) - lower_bound(g[maps[x]].begin(), g[maps[x]].end(), l);
- cout << (res <= 0 ? 0 : 1);
- }
- }
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- ll thrush = 1;
- //cin >> thrush;
- while (thrush--) { solve();}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement