Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
- int main()
- {
- fast();
- int k,n;
- cin>>k>>n;
- list<int>ls;
- map<int,int>mp;
- vector<pair<int,int> >v;
- vector<int>vv;
- for(int i=0;i<n;i++)
- {
- int a;
- cin>>a;
- mp[a]+=1;
- }
- for(int i=1;i<=k;i++)
- {
- v.push_back(make_pair(mp[i],i));
- vv.push_back(mp[i]);
- ls.push_back(mp[i]);
- // cout<<mp[i]<<" ";
- }
- //cout<<endl;
- sort(v.begin(),v.end());
- sort(vv.begin(),vv.end());
- ls.sort();
- if(vv[0]==0 && vv[1]==0 && vv.size()>3)cout<<"*"<<endl;
- else
- {
- ls.unique();
- list<int>::iterator it=ls.begin();
- advance(it, 0);
- int a=*it;
- advance(it, 1);
- int b=*it;
- //cout<<a<<" "<<b<<endl;
- if(ls.size()==2 && b-a==1)
- {
- if(v[0].first==v[1].first)cout<<"-"<<v[v.size()-1].second<<endl;
- else if(v[v.size()-1].first==v[v.size()-2].first)cout<<"+"<<v[0].second<<endl;
- else cout<<"*"<<endl;
- }
- else if(ls.size()==3)
- {
- if((v[v.size()-1].first-v[0].first)==2)cout<<"-"<<v[v.size()-1].second<<" +"<<v[0].second<<endl;
- else cout<<"*"<<endl;
- }
- else cout<<"*"<<endl;
- }
- }
RAW Paste Data