Codeforces 368B. Sereja and Suffixes Solution

Solve in C++:
  1. ///**********ALLAH IS ALMIGHTY************///
  2. ///AH Tonmoy
  3. ///Department of CSE
  4. ///Islamic University,Bangladesh
  5. #include<iostream>
  6. #include<set>
  7. using namespace std;
  8. set<int>s;
  9. int main()
  10. {
  11. set<int>s;
  12. int m,n,k,s1[100009],i,r,j;
  13. cin>>n>>m;
  14. for(i=1; i<=n; i++)
  15. {
  16. cin>>s1[i];
  17. }
  18. for(i=n; i>0; i--)
  19. {
  20. s.insert(s1[i]);
  21. s1[i]=s.size();
  22. }
  23. for(i=1;i<=m;i++)
  24. {
  25. cin>>r;
  26. cout<<s1[r]<<endl;
  27. }
  28. return 0;
  29. }
  30.  

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.