Codeforces Round #385 (Div. 2), problem: (D) Hongcow’s Game Solution in C/C++

#include <limits.h>
#include <stdio.h>

#define N	1000

void query(int *ww, int *aa, int k, int n) {
	int i;

	printf("%d\n", k);
	for (i = 0; i < k; i++)
		printf("%d ", ww[i]);
	printf("\n");
	fflush(stdout);
	for (i = 1; i <= n; i++)
		scanf("%d", &aa[i]);
}

int main() {
	int i, j, n;
	static int mm[N + 1];

	scanf("%d", &n);
	for (i = 1; i <= n; i++)
		mm[i] = INT_MAX;
	for (i = 0; 1 << i <= n; i++) {
		int aa[N], bb[N], acnt, bcnt;
		int amin[N + 1], bmin[N + 1];

		acnt = bcnt = 0;
		for (j = 1; j <= n; j++) {
			if ((j & 1 << i) == 0)
				aa[acnt++] = j;
			else
				bb[bcnt++] = j;
		}
		query(aa, amin, acnt, n);
		query(bb, bmin, bcnt, n);
		for (j = 1; j <= n; j++) {
			int min;

			min = (j & 1 << i) == 0 ? bmin[j] : amin[j];
			if (mm[j] > min)
				mm[j] = min;
		}
	}
	printf("-1\n");
	for (i = 1; i <= n; i++)
		printf("%d ", mm[i]);
	printf("\n");
	fflush(stdout);
	return 0;
}

Why Travel Organization Gear...

📢 As an Amazon Associate, I earn from qualifying...

Why Everyone Is Talking...

📢 As an Amazon Associate, I earn from qualifying...

Why Everyone Is Talking...

📢 As an Amazon Associate, I earn from qualifying...

Why Everyone Is Talking...

📢 As an Amazon Associate, I earn from qualifying...

Why Everyone Is Talking...

📢 As an Amazon Associate, I earn from qualifying...

Why Everyone Is Talking...

📢 As an Amazon Associate, I earn from qualifying...

Why Travel Organization Gear Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.💰 Official Price: Check on Amazon🌟 Why Buy the Travel Organization Gear?The Travel Organization Gear...

Why Everyone Is Talking About the Car Detailing Essentials

📢 As an Amazon Associate, I earn from qualifying purchases.💰 Official Price: Check on Amazon🌟 Why Buy the Car Detailing Essentials?The Car Detailing Essentials...

Why Everyone Is Talking About the Smart Home Hacks

📢 As an Amazon Associate, I earn from qualifying purchases.💰 Official Price: Check on Amazon🌟 Why Buy the Smart Home Hacks?The Smart Home Hacks...

Why Everyone Is Talking About the Viral Kitchen Gadgets

📢 As an Amazon Associate, I earn from qualifying purchases.💰 Official Price: Check on Amazon🌟 Why Buy the Viral Kitchen Gadgets?The Viral Kitchen Gadgets...

Why Everyone Is Talking About the Travel Organization Gear

📢 As an Amazon Associate, I earn from qualifying purchases.💰 Official Price: Check on Amazon🌟 Why Buy the Travel Organization Gear?The Travel Organization Gear...

Why Everyone Is Talking About the Travel Organization Gear

📢 As an Amazon Associate, I earn from qualifying purchases.💰 Official Price: Check on Amazon🌟 Why Buy the Travel Organization Gear?The Travel Organization Gear...

GLP-1 Drugs Like Ozempic Carry Elevated Risks of Muscle Loss and Malnutrition in Adults Over 65

Understanding the Risks of GLP-1 Drugs for Older Adults GLP-1 receptor agonists, such as Ozempic, Wegovy, and Mounjaro, have transformed the landscape of weight management...

Renew your MSIG car insurance online in minutes — and get 10% off with promo PAULTAN

Renewing your car insurance is often perceived as a tedious chore, historically involving back-and-forth communication with agents, waiting for manual quotes, and dealing with...

When healthcare stops being a promise: AbdulRazaq’a quiet revolution in Kwara

For decades, healthcare delivery in many parts of Nigeria has been defined by broken promises, decaying infrastructure, and a demoralized medical workforce. However, in...