Title Description
K a conventional set of integers, the i-th set has Sumi elements.
A set of numbers are positive numbers, and not more than N. A set of existing definitions similar to the set B;
1. B is similar to A;
2. A set of set B is equal to A after deleting a set of elements, or change the value of an element. To now divided into K sets up group M (M> N), such that a set of mutually similar in each group. We ask you to give a legal solution. If no solution please output "impossible".
Input Format
The first line of the input file has three numbers N, K, M, as meaning the subject.
Then there are K lines of the first number represents the sequence length Sum. Sum of the number of these elements after the collection.
Output Format
There are number of output files K, each represents a set of (input order) number is assigned to the group (1 ~ M).
Sample input and output
8 20 12 5 1 3 5 6 4 5 1 3 5 6 3 4 5 6 3 3 4 5 6 3 4 4 4 6 5 8 4 7 7 7 7 3 7 7 7 2 2 2 3 2 2 7 3 1 2 3 3 1 2 4 10 1 2 3 4 5 6 7 8 7 6 10 8 7 6 5 4 3 2 1 2 1 20 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 1 3 5 7 5 4 6 4 6 4 5 6 4 6 4 6 6 6 6 6 6 6 6 3 6 6 6 1 1 1 2
2 1 9 1 6 2 4 5 3 7 8 5 4 8 7 9 1 1 2 3
Description / Tips
For 30% of the data satisfies N≤10, M≤2, K≤10.
To 100% of the data satisfies N≤100, M≤100, K≤50000, Sum≤100.
WARNING: This problem with fast read times out (sharp lesson)!
So, the code?
#include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<queue> using namespace std; int n,m,k; int main(){ cin>>n>>k>>m; for(int i=1;i<=k;i++){ int a,u=0,c; cin>>a; for(int j=1;j<=a;j++){ cin>>c; u+=c; } printf("%d\n",u%(n+1)+1); } return 0; }