# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
298323 | 2020-09-12T17:27:42 Z | FlashGamezzz | Carnival (CEOI14_carnival) | C++11 | 0 ms | 0 KB |
#include <iostream> #include <cstdlib> #include <cstdio> #include <fstream> #include <algorithm> #include <string> #include <utility> #include <vector> #include <queue> #include <set> #include <map> #include <cassert> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, count = 2, prefs[155], vals[155]; cin >> n; prefs[0] = 1; string s = "1"; for (int i = 1; i < n; i++) { s += " " + to_string(i+1); cout << i+1 << " " << s << endl; cin >> prefs[i]; } vals[0] = 1; for (int i = 1; i < n; i++) { if (prefs[i] == prefs[i-1]+1) { vals[i] = count; count++; } } vector<int> nums; for (int i = 0; i < n; i++) { if (vals[i] == 0) { vector<int> temp; for (int a : nums){ temp.push_back(a); } while (temp.size() > 1) { int ind = rand() % temp.size(); assert(ind >= 0); v = temp[ind], in; cout << 2 << " " << v << " " << (i+1) << endl; cin >> in; if (in == 1) { vals[i] = v; break; } temp.erase(temp.begin() + ind); } if (vals[i] == 0) { vals[i] = temp[0]; } } else { nums.push_back(vals[i]); } } cout << 0; for (int i = 0; i < n; i++) { cout << " " << vals[i]; } cout << endl; return 0; }