301441: CF271C. Secret
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Secret
题意翻译
## 【题目描述】 有史以来最伟大的秘密包含$n$个单词,它们的顺序从$1$到$n$。秘密必须在$k$个守密的人之间进行分割(用正整数$1$到$k$表示守密人的序号),第$i$个守密人得到一个非空字符串以及$U_i=(u_{i,1},u_{i,2},...,u_{i,|U_i|})$集合中的数。我们把集合元素按照升序排列。 如果以下条件成立,则秘密被成功保守: - 对于任何两个整数$i,j(i<=i,j<=k)$,则升序中的$U_i$和$U_j$为空集合; - $U_1,U_2,...,U_k$的联合是集合$(1,2,...,n)$; - 对于每一个集合$U_i$,它的元素$u_{i,1},u_{i,2},...u_{i,|u_{i}|}$不构成等差数列,即$|U_i|>=3$应当成立; 让我们提醒你,集合$(u_1,u_2,...,u_s)$的元素在满足以下条件时构成等差数列:有一个数$d$,它满足所有的$i(1<=i<=s)$,使得$u_i+d=u_{i+1}$。例如,元素$(5),(1,10)$和$(1,5,9)$构成等差数列,而$(1,2,4)$和$(3,6,8)$则不构成。 你的任务就是找到任意一个把这一集合的文字分割成子集合$U_1,U_2,...,U_k$的方法,使得秘密能够被保守。否则指出没有满足条件的分割方式。 ## 【输入格式】 输入只有一行,包括两个整数$n,k(2<=k<=n<=10^6)$——分别代表秘密所含单词的数量和守密的人数。两个数字之间用一个空格分隔。 ## 【输出格式】 如果没有办法使得秘密保守,输出一个整数"$-1$"(不包括双引号)。否则,输出$n$个整数,其中第$i$个整数表示得到第$i$个单词的人的序号。 如果有多种结果,输出任意一种。题目描述
The Greatest Secret Ever consists of $ n $ words, indexed by positive integers from $ 1 $ to $ n $ . The secret needs dividing between $ k $ Keepers (let's index them by positive integers from $ 1 $ to $ k $ ), the $ i $ -th Keeper gets a non-empty set of words with numbers from the set $ U_{i}=(u_{i,1},u_{i,2},...,u_{i,|Ui}|) $ . Here and below we'll presuppose that the set elements are written in the increasing order. We'll say that the secret is safe if the following conditions are hold: - for any two indexes $ i,j $ ( $ 1<=i<j<=k $ ) the intersection of sets $ U_{i} $ and $ U_{j} $ is an empty set; - the union of sets $ U_{1},U_{2},...,U_{k} $ is set $ (1,2,...,n) $ ; - in each set $ U_{i} $ , its elements $ u_{i,1},u_{i,2},...,u_{i,|Ui}| $ do not form an arithmetic progression (in particular, $ |U_{i}|>=3 $ should hold). Let us remind you that the elements of set $ (u_{1},u_{2},...,u_{s}) $ form an arithmetic progression if there is such number $ d $ , that for all $ i $ ( $ 1<=i<s $ ) fulfills $ u_{i}+d=u_{i+1} $ . For example, the elements of sets $ (5) $ , $ (1,10) $ and $ (1,5,9) $ form arithmetic progressions and the elements of sets $ (1,2,4) $ and $ (3,6,8) $ don't. Your task is to find any partition of the set of words into subsets $ U_{1},U_{2},...,U_{k} $ so that the secret is safe. Otherwise indicate that there's no such partition.输入输出格式
输入格式
The input consists of a single line which contains two integers $ n $ and $ k $ ( $ 2<=k<=n<=10^{6} $ ) — the number of words in the secret and the number of the Keepers. The numbers are separated by a single space.
输出格式
If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print $ n $ integers, the $ i $ -th of them representing the number of the Keeper who's got the $ i $ -th word of the secret. If there are multiple solutions, print any of them.
输入输出样例
输入样例 #1
11 3
输出样例 #1
3 1 2 1 1 2 3 2 2 3 1
输入样例 #2
5 2
输出样例 #2
-1