jakaria_hossain

Codeforce Gym 101889C -Complete Naebbirac’s sequence

Sep 28th, 2018
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  4. int main()
  5. {
  6. fast();
  7. int k,n;
  8. cin>>k>>n;
  9. list<int>ls;
  10. map<int,int>mp;
  11. vector<pair<int,int> >v;
  12. vector<int>vv;
  13. for(int i=0;i<n;i++)
  14. {
  15. int a;
  16. cin>>a;
  17. mp[a]+=1;
  18. }
  19. for(int i=1;i<=k;i++)
  20. {
  21. v.push_back(make_pair(mp[i],i));
  22. vv.push_back(mp[i]);
  23. ls.push_back(mp[i]);
  24. // cout<<mp[i]<<" ";
  25. }
  26. //cout<<endl;
  27. sort(v.begin(),v.end());
  28. sort(vv.begin(),vv.end());
  29. ls.sort();
  30. if(vv[0]==0 && vv[1]==0 && vv.size()>3)cout<<"*"<<endl;
  31. else
  32. {
  33. ls.unique();
  34. list<int>::iterator it=ls.begin();
  35. advance(it, 0);
  36. int a=*it;
  37. advance(it, 1);
  38. int b=*it;
  39. //cout<<a<<" "<<b<<endl;
  40. if(ls.size()==2 && b-a==1)
  41. {
  42. if(v[0].first==v[1].first)cout<<"-"<<v[v.size()-1].second<<endl;
  43. else if(v[v.size()-1].first==v[v.size()-2].first)cout<<"+"<<v[0].second<<endl;
  44. else cout<<"*"<<endl;
  45. }
  46.  
  47. else if(ls.size()==3)
  48. {
  49. if((v[v.size()-1].first-v[0].first)==2)cout<<"-"<<v[v.size()-1].second<<" +"<<v[0].second<<endl;
  50. else cout<<"*"<<endl;
  51. }
  52. else cout<<"*"<<endl;
  53. }
  54. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×