SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iostream> | |
| 2 | - | #include <cstdlib> |
| 2 | + | #include <fstream> |
| 3 | #include <sstream> | |
| 4 | #include <cstdio> | |
| 5 | #include <cstring> | |
| 6 | - | #include <string> |
| 6 | + | #include <memory.h> |
| 7 | - | #include <string.h> |
| 7 | + | |
| 8 | #include <iomanip> | |
| 9 | ||
| 10 | #include <vector> | |
| 11 | #include <queue> | |
| 12 | #include <deque> | |
| 13 | #include <stack> | |
| 14 | #include <set> | |
| 15 | - | #include <ctime> |
| 15 | + | |
| 16 | #include <list> | |
| 17 | - | #define pb push_back |
| 17 | + | |
| 18 | - | #define mp make_pair |
| 18 | + | |
| 19 | - | #define PI 3.1415926535897932384626433832795 |
| 19 | + | #define INF (2147483647) |
| 20 | - | #define ALL(x) x.begin(), x.end() |
| 20 | + | |
| 21 | - | #define F first |
| 21 | + | |
| 22 | - | #define S second |
| 22 | + | |
| 23 | - | #define m0(x) memset(x,0,sizeof(x)) |
| 23 | + | class Compressor {
|
| 24 | - | #define m1(x) memset(x,-1,sizeof(x)) |
| 24 | + | public: |
| 25 | - | #define pw(x) (1ull<<(x)) |
| 25 | + | vector<int> v; |
| 26 | ||
| 27 | Compressor(vector<int> _a) | |
| 28 | - | typedef long long ll; |
| 28 | + | {
|
| 29 | - | typedef unsigned long long ull; |
| 29 | + | v.clear(); |
| 30 | - | typedef long double ld; |
| 30 | + | sort(_a.begin(), _a.end()); |
| 31 | - | typedef pair<int,int> pii; |
| 31 | + | v.push_back(-INF); |
| 32 | - | const int INF = 2147483647; |
| 32 | + | v.push_back(_a[0]); |
| 33 | - | const ll LLINF = 9223372036854775807LL; |
| 33 | + | for(int _i=1; _i<(int)_a.size(); ++_i) |
| 34 | if(_a[_i]!=_a[_i-1]) | |
| 35 | - | struct qu {
|
| 35 | + | v.push_back(_a[_i]); |
| 36 | - | int l,r,num; |
| 36 | + | v.push_back(INF); |
| 37 | } | |
| 38 | int size() | |
| 39 | - | const int maxn = 200000; |
| 39 | + | {
|
| 40 | - | int a[maxn]; |
| 40 | + | return v.size(); |
| 41 | - | int so[maxn]; |
| 41 | + | } |
| 42 | - | int ans[maxn]; |
| 42 | + | int get(int a) |
| 43 | - | int col[maxn]; |
| 43 | + | {
|
| 44 | - | int p[maxn]; |
| 44 | + | return lower_bound(v.begin(), v.end(), a) - v.begin(); |
| 45 | - | int n,qc; |
| 45 | + | } |
| 46 | - | qu q[maxn]; |
| 46 | + | |
| 47 | - | int sc = 0; |
| 47 | + | vector<int> vv[70000]; |
| 48 | - | int bl; |
| 48 | + | |
| 49 | int main() | |
| 50 | - | bool comp(int a, int b) {
|
| 50 | + | {
|
| 51 | - | return (q[a].l/bl<q[b].l/bl) || (q[a].l/bl==q[b].l/bl && q[a].r<q[b].r); |
| 51 | + | ios_base::sync_with_stdio(0); |
| 52 | - | } |
| 52 | + | |
| 53 | vector<int> m; | |
| 54 | - | int main() {
|
| 54 | + | int n; |
| 55 | - | //freopen("input.txt", "r", stdin);
|
| 55 | + | cin>>n; |
| 56 | - | //freopen("output.txt", "w", stdout);
|
| 56 | + | int i, l, r, a; |
| 57 | - | cin >> n; |
| 57 | + | for(i=1;i<=n;++i){
|
| 58 | - | for (int i=0;i<n;i++) {
|
| 58 | + | cin>>a; |
| 59 | - | scanf("%d", &a[i]);
|
| 59 | + | m.push_back(a); |
| 60 | - | so[sc++] = a[i]; |
| 60 | + | } |
| 61 | - | } |
| 61 | + | Compressor comp(m); |
| 62 | - | bl = (int)(sqrt(n)); |
| 62 | + | for(i=0; i<(int)m.size(); ++i){
|
| 63 | - | cin >> qc; |
| 63 | + | vv[comp.get(m[i])].push_back(i+1); |
| 64 | - | for (int i=0;i<qc;i++) {
|
| 64 | + | } |
| 65 | - | scanf("%d%d%d", &q[i].l, &q[i].r, &q[i].num);
|
| 65 | + | sort(m.begin(), m.end()); |
| 66 | - | so[sc++] = q[i].num; |
| 66 | + | cin>>n; |
| 67 | - | } |
| 67 | + | for(i=0;i<n;++i){
|
| 68 | - | sort(so, so+sc); |
| 68 | + | cin>>l>>r>>a; |
| 69 | - | for (int i=0;i<n;i++) a[i] = (int)(lower_bound(so, so+sc, a[i])-so); |
| 69 | + | int t = lower_bound(m.begin(), m.end(), a) - m.begin(); |
| 70 | - | for (int i=0;i<qc;i++) q[i].num = (int)(lower_bound(so, so+sc, q[i].num)-so); |
| 70 | + | if(t<n && m[t]==a){
|
| 71 | - | for (int i=0;i<qc;i++) p[i] = i; |
| 71 | + | t = comp.get(a); |
| 72 | - | sort(p, p+qc, comp); |
| 72 | + | int tt = lower_bound(vv[t].begin(), vv[t].end(), l)-vv[t].begin(); |
| 73 | - | int l = 0, r = -1; |
| 73 | + | if(tt<(int)vv[t].size() && vv[t][tt]<=r) cout<<1; |
| 74 | - | for (int i=0;i<qc;i++) {
|
| 74 | + | else cout<<0; |
| 75 | - | qu &cur = q[p[i]]; |
| 75 | + | |
| 76 | - | cur.l--; cur.r--; |
| 76 | + | }else cout<<0; |
| 77 | - | while (r<cur.r) {
|
| 77 | + | } |
| 78 | - | r++; |
| 78 | + | |
| 79 | - | col[a[r]]++; |
| 79 | + | return 0; |
| 80 | - | } |
| 80 | + |