fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <string>
  7. #include <queue>
  8. #include <utility>
  9. #include <set>
  10. #include <iomanip>
  11. #include <ctime>
  12.  
  13. using namespace std;
  14.  
  15. #define ll long long
  16. #define pi 3.141592653589793
  17. #define pb push_back
  18. #define forto(l,a,b) for(long long l = a; l <= b; ++l)
  19. #define downto(l,a,b) for(long long l = a; l >= b; --l)
  20. #define Fred_Flinstone ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  21. #define ln '\n'
  22. #define decimal cout<<fixed<<setprecision(15)
  23.  
  24. int x[1234];
  25. int cnt;
  26.  
  27. bool cmp(long a, long b){
  28. string s;
  29. //cout << "1 " << a << ' ' << b << ln;
  30. //cout << flush;
  31. //cin >> s;
  32. cnt++;
  33. s = x[a] < x[b] ? "Y" : "N";
  34. if (s[0] == 'Y') return 1;
  35. return 0;
  36. }
  37.  
  38. int main()
  39. {
  40. Fred_Flinstone;
  41. long n;
  42. vector< long > v;
  43.  
  44. cin >> n;
  45.  
  46. forto(f, 1, n){
  47. x[f]=rand()%100000;
  48. v.pb(f);
  49. }
  50.  
  51. stable_sort(v.begin(), v.end(), cmp);
  52. cout << cnt << "\n";
  53. return 0;
  54. cout << "0 ";
  55. forto(f, 0, n-1){
  56. cout << v[f] << ' ';
  57. }
  58. return 0;
  59. }
  60.  
Success #stdin #stdout 0s 2888KB
stdin
1000
stdout
9743