PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#TP0000078. Các chỉ dẫn của robot (Robot Instructions)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Các chỉ dẫn của robot (Robot Instructions)
Robot Instructions
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
A robot starts at . Each of distinguishable instructions adds vector . For every , count size- subsets of instructions whose sum equals the destination .
Input
Line 1: . Line 2: destination . Next lines: displacement vectors .
Output
Print exactly lines, one answer for each subset size .
Subtasks
- Subtask 1 (20 points): Exactly one dataset; ; ; the goal and every instruction vector are nonzero; instruction indices distinguish choices.
- Subtask 2 (30 points): Exactly one dataset; ; ; the goal and every instruction vector are nonzero; instruction indices distinguish choices.
- Subtask 3 (50 points): Exactly one dataset; ; ; the goal and every instruction vector are nonzero; instruction indices distinguish choices.
Example
Input
3
1 1
1 0
0 1
1 1
Output
1
1
0
Explanation
There is one size-one subset selecting (1,1) and one size-two subset selecting (1,0),(0,1); no size-three subset works.