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;
}

Russ Allbery: Review: Radiant...

Science fiction enthusiasts and literary critics alike are turning...

Why Pet Travel Gear...

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

Mall Together-TENOKE

Simulation gaming enthusiasts have a fresh operational challenge to...

7 Reasons This Coffee...

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

Why Kitchen Organization Tools...

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

Is Dorm Room Hacks...

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

Russ Allbery: Review: Radiant Star

Science fiction enthusiasts and literary critics alike are turning their eyes toward the upcoming release of Radiant Star, the latest novel by award-winning author...

Why Pet Travel Gear Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.After putting the Pet Travel Gear through a proper 30-day real-world test, I can tell...

Mall Together-TENOKE

Simulation gaming enthusiasts have a fresh operational challenge to tackle with the arrival of Mall Together-TENOKE. This brand-new release delivers an immersive shopping mall...

7 Reasons This Coffee Bar Accessories Is Worth Every Single Penny

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Why Kitchen Organization Tools Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Is Dorm Room Hacks Worth Your Money Here Is Our Full Review

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

Stop Buying Cheap Alternatives This Camping Essentials Is the Real Deal

📢 As an Amazon Associate, I earn from qualifying purchases.There comes a point when you realise that tolerating a frustrating situation is costing you...

Everything You Need to Know About Outdoor Patio Tech Right Now

📢 As an Amazon Associate, I earn from qualifying purchases.I'll be honest — I was skeptical at first. My daily routine had a gap...

Why Bathroom Organization Hacks Is Currently Breaking the Internet

📢 As an Amazon Associate, I earn from qualifying purchases.I'll be honest — I was skeptical at first. My daily routine had a gap...