fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,k,cont=0;
  6. cin>>n>>k;
  7. int arr[n+3],arr2[103];
  8.  
  9. set<int>st;
  10. set<int>::iterator it;
  11. vector<int>vr;
  12. for(int i=1;i<=n;++i){
  13. cin>>arr[i];
  14. arr2[arr[i]]=i;
  15. st.insert(arr[i]);
  16. }
  17.  
  18. for(it=st.begin();it!=st.end();++it)
  19. vr.push_back(*it);
  20.  
  21. if(st.size()<k){
  22. cout<<"NO";
  23. }
  24.  
  25.  
  26.  
  27. else{
  28. cout<<"YES\n";
  29. for(int i=0;i<k;++i){
  30. cout<<arr2[vr[i]]<<" ";
  31. }
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0s 4504KB
stdin
4 4
20 10 40 30
stdout
YES
2 1 4 3