PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#DSU0000036. Artsem và Saunders (Artsem and Saunders)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Artsem và Saunders (Artsem and Saunders)
Artsem and Saunders
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given a function from to itself, represented by the sequence .
Find a positive integer and two functions and satisfying both identities:
If no such exist, report that there is no solution. Otherwise, output any valid choice. You do not need to minimize or maximize .
Input
The first line contains . The second line contains .
Output
Print -1 if impossible. Otherwise print on line one, values on line two, and values on line three. Require , , .
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
3
2 2 2
Output
1
1 1 1
2
Explanation
Choose , and . Then and for all .