Submission #638462

#TimeUsernameProblemLanguageResultExecution timeMemory
638462ghostwriterCarnival (CEOI14_carnival)C++14
100 / 100
33 ms388 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include <debug.h> #endif #define st first #define nd second #define pb push_back #define pf push_front #define _pb pop_back #define _pf pop_front #define lb lower_bound #define ub upper_bound #define mtp make_tuple #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pi; typedef pair<ll, ll> pll; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll; typedef string str; template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i)) #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i)) #define EACH(i, x) for (auto &(i) : (x)) #define WHILE while #define file "TEST" mt19937 rd(chrono::steady_clock::now().time_since_epoch().count()); ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); } /* Tran The Bao CTL - Da Lat Cay ngay cay dem nhung deo duoc cong nhan */ const int N = 155; int n, c[N], cnt = 0; vi a, cc, ans, d[N]; #ifndef LOCAL void get_input() { cin >> n; } int number_of_color(vi a) { cout << sz(a) << ' '; EACH(i, a) cout << i << ' '; cout << endl; int ans; cin >> ans; return ans; } void check_answer(vi a) { cout << 0 << ' '; EACH(i, a) cout << i << ' '; cout << endl; } #else #include "grader.cpp" #endif signed main() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); // freopen(file".inp", "r", stdin); // freopen(file".out", "w", stdout); get_input(); vi a1; FOR(j, 1, n) a1.pb(j); int ans1 = number_of_color(a1); FOR(i, 1, n) { vi a; FOR(j, 1, n) if (j != i) a.pb(j); int ans2 = number_of_color(a); if (ans1 > ans2) c[i] = ++cnt; else ::a.pb(i); } FOR(i, 0, sz(a) - 1) { int pos = a[i]; if (cc.empty()) { c[pos] = ++cnt; d[cnt].pb(pos); cc.pb(cnt); continue; } vi a1; FOR(j, 0, i - 1) a1.pb(a[j]); int ans1 = number_of_color(a1); a1.clear(); FOR(j, 0, i) a1.pb(a[j]); int ans2 = number_of_color(a1); if (ans1 < ans2) { c[pos] = ++cnt; d[cnt].pb(pos); cc.pb(cnt); continue; } bool ok = 0; EACH(j, cc) { vi a1; EACH(z, d[j]) a1.pb(z); a1.pb(pos); int ans1 = number_of_color(a1); if (ans1 == 1) { c[pos] = j; d[j].pb(pos); ok = 1; break; } } if (ok) continue; c[pos] = ++cnt; d[cnt].pb(pos); cc.pb(cnt); } FOR(i, 1, n) ans.pb(c[i]); check_answer(ans); return 0; } /* 5 1 2 1 3 2 */

Compilation message (stderr)

carnival.cpp: In function 'int number_of_color(vi)':
carnival.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
carnival.cpp:45:3: note: in expansion of macro 'EACH'
   45 |   EACH(i, a) cout << i << ' ';
      |   ^~~~
carnival.cpp: In function 'void check_answer(vi)':
carnival.cpp:26:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   26 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
carnival.cpp:53:3: note: in expansion of macro 'EACH'
   53 |   EACH(i, a) cout << i << ' ';
      |   ^~~~
carnival.cpp: In function 'int main()':
carnival.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
carnival.cpp:65:2: note: in expansion of macro 'FOR'
   65 |  FOR(j, 1, n) a1.pb(j);
      |  ^~~
carnival.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
carnival.cpp:67:5: note: in expansion of macro 'FOR'
   67 |     FOR(i, 1, n) {
      |     ^~~
carnival.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
carnival.cpp:69:6: note: in expansion of macro 'FOR'
   69 |      FOR(j, 1, n)
      |      ^~~
carnival.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
carnival.cpp:76:5: note: in expansion of macro 'FOR'
   76 |     FOR(i, 0, sz(a) - 1) {
      |     ^~~
carnival.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
carnival.cpp:85:6: note: in expansion of macro 'FOR'
   85 |      FOR(j, 0, i - 1) a1.pb(a[j]);
      |      ^~~
carnival.cpp:24:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
carnival.cpp:88:6: note: in expansion of macro 'FOR'
   88 |      FOR(j, 0, i) a1.pb(a[j]);
      |      ^~~
carnival.cpp:26:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   26 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
carnival.cpp:97:6: note: in expansion of macro 'EACH'
   97 |      EACH(j, cc) {
      |      ^~~~
carnival.cpp:26:31: warning: unnecessary parentheses in declaration of 'z' [-Wparentheses]
   26 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
carnival.cpp:99:7: note: in expansion of macro 'EACH'
   99 |       EACH(z, d[j]) a1.pb(z);
      |       ^~~~
carnival.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
carnival.cpp:114:5: note: in expansion of macro 'FOR'
  114 |     FOR(i, 1, n) ans.pb(c[i]);
      |     ^~~
#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...