Submission #344465

#TimeUsernameProblemLanguageResultExecution timeMemory
344465chienyu_xiong사육제 (CEOI14_carnival)C++14
100 / 100
17 ms396 KiB
#include <bits/stdc++.h> #define F first #define S second #define pb push_back #define mp make_pair typedef long long int lli; #define pll pair<lli, lli> #define pil pair<int, lli> #define pli pair<lli, int> #define pii pair<int, int> using namespace std; void setIO(string str, bool dbg) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (!dbg) { freopen((str + ".in").c_str(), "r", stdin); freopen((str + ".out").c_str(), "w", stdout); } } const int MAX = 155; const lli INF = 9e17; const lli MOD = 1e9 + 7; int _ = 1; // test cases int n; int cur = 0; int val[MAX]; int ans[MAX]; int que(int cnt, int idx) { cout << cnt << " "; cout << idx << " "; for (int i = 1; i < cnt; i++) cout << val[i] << " "; cout << endl; int res; cin >> res; return res; } int slv(int num) { int lo = 1; int hi = cur + 1; while (lo < hi) { int mid = (lo + hi + 0) / 2; bool can = que(mid + 1, num) != mid + 1; if (can == 0) lo = mid + 1; if (can == 1) hi = mid; } return lo; } void fnc() { cin >> n; for (int i = 1; i <= n; i++) { ans[i] = slv(i); val[ans[i]] = i; cur = max(cur, ans[i]); } cout << "0 "; for (int i = 1; i <= n; i++) cout << ans[i] << " "; cout << endl; } int main() { //setIO("", 0); while (_--) fnc(); return 0; }

Compilation message (stderr)

carnival.cpp: In function 'void fnc()':
carnival.cpp:76:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   76 |  for (int i = 1; i <= n; i++)
      |  ^~~
carnival.cpp:77:26: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   77 |   cout << ans[i] << " "; cout << endl;
      |                          ^~~~
carnival.cpp: In function 'void setIO(std::string, bool)':
carnival.cpp:25:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   25 |   freopen((str + ".in").c_str(), "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   26 |   freopen((str + ".out").c_str(), "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...