#P15586. [KTSC 2026] 五万酱汁 / 50,000 Sauces

    ID: 17467 远端评测题 3000ms 2048MiB 尝试: 0 已通过: 0 显示难度提高 上传者: 标签>交互题Special Judge2026KTSC(韩国)

[KTSC 2026] 五万酱汁 / 50,000 Sauces

Background

Submission notes:

  1. Do not include any header files.
  2. Add the following at the top of the file:
    #include <vector>
    int query(std::vector<int>);
    
  3. Submit using C++ 20/23\texttt{C++\,\red{20/23}}.

Problem Description

This is an interactive problem. In this problem, the interactive library is non-adaptive.

You are given a positive integer NN.

There is a hidden family of sets XX. Each element SS of XX is a subset of {0,1,…,N−1}\{0,1,\ldots,N-1\}. Here, ∣S∣|S| is 22 or 33. Note that, by definition, a set cannot contain duplicate elements.

You may make the following queries multiple times, and your goal is to determine ∣X∣|X| using as few queries as possible:

Query

Given Y⊆{0,1,…,N−1}Y\subseteq \{0,1,\ldots, N-1\} with ∣Y∣≤⌈N2⌉+1|Y|\le \lceil \frac{N}{2} \rceil + 1.

The interactive library returns f(Y)=∣{S∈X∣S⊆Y}∣f(Y)=|\{S\in X \mid S \subseteq Y \}|.

Determine ∣X∣|X| using as few queries as possible.

Implementation Details

This is a function-based interactive problem. You do not need to, and must not, implement the main function.

You should implement the following function:

int solve(int N)
  • Return ∣X∣|X|.
  • This function is called exactly once.

You may call the following function:

int query(vector<int> Y)
  • The elements in YY must be pairwise distinct.
  • It must hold that 0≤Y[i]≤N−10\le Y[i]\le N-1.
  • It must hold that ∣Y∣≤⌈N2⌉+1|Y|\le \lceil \frac{N}{2} \rceil + 1.
  • This function returns f(Y)=∣{S∈X∣S⊆Y}∣f(Y)=|\{S\in X \mid S \subseteq Y \}|.
  • In each test case, this function can be called at most 3 0003\,000 times.

Your source code must not call any input/output functions.

Input Format

The input format of the sample grader program is as follows:

  • Line 11: NN
  • Line 22: KK (=∣X∣)(= |X|)
  • For each 0≤i<K0 \le i < K:
    • Line 3+i3 + i: LL a0a_0 a1a_1 ... aL−1a_{L-1}
      • 2≤L≤32 \le L \le 3
      • 0≤aj≤N−10 \le a_j \le N - 1
      • a0,a1,…,aL−1a_0, a_1, \ldots, a_{L-1} are all distinct.
      • {a0,a1,…,aL−1}\{a_0, a_1, \ldots, a_{L-1}\} is an element of the set family XX.

Output Format

The sample grader program outputs the value returned by your code in the solve function and the number of calls to query in the following format:

  • Line 11: the value xx returned by the solve function
  • Line 22: the number of calls to query, QQ
6
2
2 0 1
3 2 3 4

2
3

Hint

Constraints

  • 6≤N≤1 0006\le N\le 1\, 000.
  • 1≤∣X∣≤50 0001\le |X|\le 50\, 000.
  • For any S∈XS\in X, ∣S∣∈{2,3}|S|\in \{2,3\}.
  • The interactive library is non-adaptive. In other words, XX is fixed before solve is called.

Subtasks

ID Score N≤N\le Special Property
11 1111 500500 AB\text{AB}
22 3232 A\text{A}
33 2525 1 0001\, 000 B\text{B}
44 3232
  • Special property A\text{A}: For any two different Si,Sj∈XS_i,S_j\in X, Si∩Sj=∅S_i\cap S_j=\varnothing.
  • Special property B\text{B}: For any S∈XS\in X, ∣S∣=2|S|=2.

Scoring

In each subtask, if there is any case where the answer ∣X∣|X| is incorrect, then this subtask gets 00 points.

Otherwise, let QQ be the maximum number of calls to query among all test cases in that subtask. The score is calculated by the following rules:

  • For subtasks 1,21,2, if Q≤3 000Q\le 3\, 000, you get full score.
  • For subtasks 3,43,4:
    • If 41<Q≤3 00041\lt Q\le 3\, 000, you get (0.5+412Q)\displaystyle (0.5 + \frac{41}{2Q}) times the full score of the subtask.
    • If Q≤41Q\le 41, you get full score.

Example

N=6N = 6, X={{0,1},{2,3,4}}X = \{\{0,1\}, \{2,3,4\}\}. ∣X∣=2|X| = 2.

The maximum size of a query set is ⌊6/2⌋+1=4\lfloor 6/2 \rfloor + 1 = 4.

The grader program initially calls the following function:

solve(6)

Your code may interact as follows:

query(0, 1, 2)
query(2, 3, 4)
query(0, 2, 3, 5)
  • Since {0,1}⊆{0,1,2}\{0, 1\} \subseteq \{0, 1, 2\} and {2,3,4}⊈{0,1,2}\{2, 3, 4\} \not\subseteq \{0, 1, 2\}, query(0, 1, 2) returns 11.
  • Since {0,1}⊈{2,3,4}\{0, 1\} \not\subseteq \{2, 3, 4\} and {2,3,4}⊆{2,3,4}\{2, 3, 4\} \subseteq \{2, 3, 4\}, query(2, 3, 4) returns 11.
  • Since {0,2,3,5}\{0, 2, 3, 5\} does not contain any element of XX, query(0, 2, 3, 5) returns 00.

Your code submits the answer by returning 22 as the return value of solve(6).

Translated by ChatGPT 5