Codeforces 368B. Sereja and Suffixes Solution
Solve in C++:
- ///**********ALLAH IS ALMIGHTY************///
- ///AH Tonmoy
- ///Department of CSE
- ///Islamic University,Bangladesh
- #include<iostream>
- #include<set>
- using namespace std;
- set<int>s;
- int main()
- {
- set<int>s;
- int m,n,k,s1[100009],i,r,j;
- cin>>n>>m;
- for(i=1; i<=n; i++)
- {
- cin>>s1[i];
- }
- for(i=n; i>0; i--)
- {
- s.insert(s1[i]);
- s1[i]=s.size();
- }
- for(i=1;i<=m;i++)
- {
- cin>>r;
- cout<<s1[r]<<endl;
- }
- return 0;
- }
No comments