Advertisement
sashasashasasha151

Untitled

Oct 17th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. //int s = 0;
  8. int n;
  9.  
  10. bool f(int i, int j) {
  11.     //s++;
  12.     if(i>n || j>n) {
  13.         string ansss="0 ";
  14.         for (int k = 0; k < n-1; ++k) {
  15.             ansss+="0 ";
  16.         }
  17.         ansss+="0";
  18.         cout << ansss;
  19.         cout.flush();
  20.         exit(0);
  21.     }
  22.     string ans;
  23.     string l = to_string(i);
  24.     string r = to_string(j);
  25.     string z = "1 " + l + " " + r;
  26.     cout << z;
  27.     cout.flush();
  28.     cin >> ans;
  29.     if (ans == "YES") {
  30.         return true;
  31.     } else {
  32.         return false;
  33.     }
  34. }
  35.  
  36. int main() {
  37.     cin >> n;
  38.     int *arr = new int[n];
  39.     for (int i = 0; i < n; ++i) {
  40.         arr[i] = i + 1;
  41.     }
  42.     sort(arr, arr + n, f);
  43.     string anss="0 ";
  44.     for (int j = 0; j < n-1; ++j) {
  45.         anss+=to_string(arr[j]) + " ";
  46.     }
  47.     anss+=to_string(arr[n-1]);
  48.     cout << anss;
  49.     cout.flush();
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement