RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 IOIF001 ⇄ 인터랙티브

Detecting Molecules

설명

You are given the weights \(w_1, \dots, w_n\) of \(n\) molecules and a target range \([\ell, u]\). Find a non-empty subset of the molecules whose total weight lies in \([\ell, u]\), or report that no such subset exists.

It is guaranteed that \(\max_i w_i - \min_i w_i \le u - \ell\).

This is an interactive task. The grader sends you the arguments; you print the subset (or report impossibility). Because many subsets may be valid, the grader validates your subset rather than comparing it to a fixed answer.

Note. This is an adaptation of an IOI function-implementation task to an interactive stdin/stdout problem. The test data is RiseOJ-generated (self-validated against an independent brute force), not the official IOI data.

Interaction / I/O protocol

Input. The grader first sends one line with three integers \(n\), \(\ell\), \(u\). The second line contains \(n\) integers \(w_1 \dots w_n\).

Output. If a valid subset exists, print its size \(m\) (\(m \ge 1\)) on one line, then \(m\) distinct 1-based indices on the next line. If no valid subset exists, print a single line containing -1 (or 0).

Flush after printing. Any valid subset is accepted.

Example. For n=4, [l,u]=[10,12], weights 5 8 7 3:

(receive) 4 10 12
(receive) 5 8 7 3
(send)    2
(send)    1 3

The subset \(\{1,3\}\) has weight \(5+7=12 \in [10,12]\), so it is accepted.

제약
  • \(1 \le n \le 200\)
  • \(1 \le w_i \le 1000\)
  • \(1 \le \ell \le u \le 20000\)
  • \(\max_i w_i - \min_i w_i \le u - \ell\)
입력 형식

The grader first sends one line with three integers \(n\), \(\ell\), \(u\). The second line contains \(n\) integers \(w_1 \dots w_n\).

출력 형식

If a valid subset exists, print its size \(m\) (\(m \ge 1\)) on one line, then \(m\) distinct 1-based indices on the next line. If no valid subset exists, print a single line containing -1 (or 0).

Flush after printing. Any valid subset is accepted.

인터랙티브 문제
프로그램이 고정된 입력을 읽는 대신 표준 입출력으로 채점기와 메시지를 주고받습니다. 한 줄을 출력할 때마다 표준 출력을 flush하고(예: cout에 endl / print(..., flush=True) / System.out.flush()), 채점기의 응답을 읽으세요. 파일을 읽거나 쓰면 안 됩니다.
문제 정보

rip 작성

출처 IOI 2016

평가 및 의견

Detecting Molecules

개요
출제자 난이도 Gold III 골드 III 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Detecting Molecules

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8