Test instructions: Given your unknown size n number, you allow not more than 10,000 times the query, each query two number, the number of I is smaller than the number of J? Then the background will return you a result yes or no (that is, one line of input),
Then after many queries, you need to give an ascending order of the correct original unknown sequence.
Analysis: At that time is really not understand test instructions is what meaning, then let go, if understand, not very difficult, this is not a sort of, you can ask the background to data, and then you decide how to sort,
We just have to deal with this sort, but we can't sort by sorts, because the complexity is not always nlogn, and if the extreme data is stuck, that means it might be more than 10,000 times.
Either we write a quick line ourselves or use stabble_sort, the sorting function to solve.
The code is as follows:
#pragma COMMENT (linker, "/stack:1024000000,1024000000") #include <cstdio> #include <string> #include < cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include < queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include < cmath> #include <stack> #define FREOPENR freopen ("In.txt", "R", stdin) #define FREOPENW freopen ("OUT.txt", "W", STDOUT) using namespace Std;typedef long Long ll;typedef pair<int, int> p;const int inf = 0x3f3f3f3f;const double inf = 0x3f3f3f3f3f3f;const Double PI = ACOs ( -1.0); const double EPS = 1e-8;const int maxn = 1e3 + 5;const int mod = 1e9 + 7;co NST int dr[] = {-1, 0, 1, 0};const int dc[] = {0, 1, 0, -1};const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0 101 "," 0110 "," 0111 "," $ "," 1001 "," 1010 "," 1011 "," 1100 "," 1101 "," 1110 "," 1111 "};int N, m;const int mon[] = {0, 31, 2 8, A, a, a, a, a, a, a, a, 31};const inT monn[] = {0, h, h, N, N, H,, H, H, N, h, 31};inline int Min (int a, int b) {return a < b? A:b;} inline int Max (int a, int b) {return a > b a:b;} inline ll Min (ll A, ll b) {return a < b a:b;} inline ll Max (ll A, ll b) {return a > b a:b;} inline bool Is_in (int r, int c) {return R >= 0 && r < n && C >= 0 && C < m;} int a[maxn];string S;bool CMP (int a, int b) {cout << "1" << a << "" << b << Endl; Cin >> S; return s[0] = = ' Y ';} int main () {Cout.flush (); CIN >> N; for (int i = 0; i < n; ++i) a[i] = i+1; Stable_sort (A, a+n, CMP); cout << "0"; for (int i = 0; i < n; ++i) cout << "" << a[i]; cout << Endl; return 0;}
Codeforces Gym 100685J Just Another Disney problem (STL, sort)