Submission #638461

# Submission time Handle Problem Language Result Execution time Memory
638461 2022-09-06T08:02:27 Z ghostwriter Carnival (CEOI14_carnival) C++14
80 / 100
43 ms 572 KB
#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
	int totalquery = 0;
	void get_input() {
		cin >> n;
	}
	int number_of_color(vi a) {
		++totalquery;
		cout << sz(a) << ' ';
		EACH(i, a) cout << i << ' ';
		cout << endl;
		int ans;
		cin >> ans;
		return ans;
	}
	void check_answer(vi a) {
		assert(totalquery <= 3500);
		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();
    FOR(i, 1, n) {
    	vi a;
    	FOR(j, 1, n) a.pb(j);
    	int ans1 = number_of_color(a);
    	a.clear();
    	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;
    	}
    	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

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:47:3: note: in expansion of macro 'EACH'
   47 |   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:56:3: note: in expansion of macro 'EACH'
   56 |   EACH(i, a) cout << i << ' ';
      |   ^~~~
carnival.cpp: In function 'int main()':
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) a.pb(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:72:6: note: in expansion of macro 'FOR'
   72 |      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:79:5: note: in expansion of macro 'FOR'
   79 |     FOR(i, 0, sz(a) - 1) {
      |     ^~~
carnival.cpp:26:31: warning: unnecessary parentheses in declaration of 'j' [-Wparentheses]
   26 | #define EACH(i, x) for (auto &(i) : (x))
      |                               ^
carnival.cpp:88:6: note: in expansion of macro 'EACH'
   88 |      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:90:7: note: in expansion of macro 'EACH'
   90 |       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:105:5: note: in expansion of macro 'FOR'
  105 |     FOR(i, 1, n) ans.pb(c[i]);
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 208 KB Output is correct
2 Correct 21 ms 208 KB Output is correct
3 Correct 18 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 8 ms 324 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 17 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 308 KB Output is correct
2 Correct 27 ms 312 KB Output is correct
3 Correct 11 ms 208 KB Output is correct
4 Correct 8 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 7 ms 308 KB Output is correct
7 Correct 10 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 336 KB Output is correct
2 Correct 11 ms 208 KB Output is correct
3 Runtime error 43 ms 572 KB Execution killed with signal 6
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 208 KB Output is correct
2 Correct 9 ms 328 KB Output is correct
3 Correct 12 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 6 ms 208 KB Output is correct
7 Correct 15 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 332 KB Output is correct
2 Correct 14 ms 324 KB Output is correct
3 Correct 23 ms 208 KB Output is correct
4 Correct 21 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 ms 208 KB Output is correct
7 Correct 8 ms 208 KB Output is correct