Submission #1028092

#TimeUsernameProblemLanguageResultExecution timeMemory
1028092otariusCarnival (CEOI14_carnival)C++17
100 / 100
17 ms856 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> using namespace __gnu_pbds; using namespace std; // #pragma GCC optimize("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define ff first #define sc second #define pb push_back #define ll long long #define pll pair<ll, ll> #define pii pair<int, int> #define ull unsigned long long #define all(x) (x).begin(),(x).end() // #define int long long // #define int unsigned long long // #define ordered_set(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update> // #define ordered_multiset(T) tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update> void open_file(string filename) { freopen((filename + ".in").c_str(), "r", stdin); freopen((filename + ".out").c_str(), "w", stdout); } // const ll mod = 1e9 + 7; // const ll mod = 998244353; const ll inf = 1e9; const ll biginf = 1e18; // const int maxN; void ask(vector<int> v) { cout << v.size() << ' '; for (int i : v) cout << i << ' '; cout << endl; } void solve() { int n; cin >> n; int clr[n + 1], cur = 1; clr[1] = cur; for (int i = 2; i <= n; i++) { vector<int> v; for (int j = 1; j < i; j++) v.pb(j); ask(v); int x1; cin >> x1; v.pb(i); ask(v); int x2; cin >> x2; if (x1 != x2) clr[i] = ++cur; else { int l = 1, r = i - 1, m, ans; while (l <= r) { m = (l + r) / 2; v.clear(); for (int j = m; j < i; j++) v.pb(j); ask(v); int x1; cin >> x1; v.pb(i); ask(v); int x2; cin >> x2; if (x1 == x2) { ans = m; l = m + 1; } else { r = m - 1; } } clr[i] = clr[ans]; } } cout << "0 "; for (int i = 1; i <= n; i++) cout << clr[i] << ' '; cout << endl; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int t = 1; // cin >> t; while (t--) { solve(); } return 0; }

Compilation message (stderr)

carnival.cpp: In function 'void open_file(std::string)':
carnival.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((filename + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp:27:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |     freopen((filename + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
carnival.cpp: In function 'void solve()':
carnival.cpp:66:31: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   66 |             } clr[i] = clr[ans];
      |                        ~~~~~~~^
#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...