ural 1613 For Fans of Statistics

 1 #include <cstdio>

 2 #include <cstring>

 3 #include <map>

 4 #include <vector>

 5 #include <algorithm>

 6 using namespace std;

 7 map<int,vector<int> >t;

 8 vector<int>::iterator it;

 9 int main()

10 {

11     int n,x;

12     scanf("%d",&n);

13     for(int i=1; i<=n; i++)

14     {

15         scanf("%d",&x);

16         t[x].push_back(i);

17     }

18     int m,r,l;

19     scanf("%d",&m);

20     for(int i=1; i<=m; i++)

21     {

22         scanf("%d%d%d",&l,&r,&x);

23         it=lower_bound(t[x].begin(),t[x].end(),l);

24         if(it==t[x].end()) printf("0");

25         else if((*it)<=r) printf("1");

26         else printf("0");

27     }

28     printf("\n");   

29     return 0;

30 }
View Code

 

你可能感兴趣的:(for)