DIFFV - Different Vectors
You are given set of N vectors, each vector consists of K integers. Vector ex equals ey iff there exists function bijection f and integer r, such that ex[i] = f( ey[(i+r)%K] ), for each i in range [0, K> Eg. (1, 2, 2, 3) == (22, 3, 4, 22), with r=2 and f(22)=2, f(3)=3 and f(4)=1. But (22,3,22,4) is not equal to (1, 2, 2, 3).
How many different vectors are there in set of N given vectors?
Constraints:
n <= 10000
k <= 100
vector values are from range [0, 10^9]
Input
First number contains T (T <= 10), number of test cases. Each test cases consists of following. First line consists of N and K. N lines follows, the i-th containing K integers describing i-th vector.
Output
Output one number, number of different vectors.
Input: 2 3 4 22 3 4 22 1 2 2 3 22 3 22 4 5 5 3 3 3 0 3 8 4 4 4 0 1 1 1 1 1 1 1 8 6 1 1 3 3 3 5 Output: 2 3
hide comments
Lovro Puzar:
2018-01-01 14:26:00
Nice one!
|
|
Buda IM (retired):
2014-03-30 13:36:51
nema pitanja |
|
(Tjandra Satria Gunawan)(曾毅昆):
2012-11-14 02:43:19
Question for all: is there other strategy to solve this problem other than linked list?
|
|
:D:
2012-11-13 20:34:05
I added a fail-safe to my heuristics and disqualified the previous iffy top solution. So my best time is now from a legit solution.
|
|
:D:
2012-11-13 20:34:05
It's a great problem. It's very subjective, but I love the analysis you need to do here and how it merges a lot of algos and still requires an original idea to keep it together. There's also a lot of room for optimizations on every stage of the program. Overall, one of my best problem solving experiences, highly recommended.
|
|
(Tjandra Satria Gunawan)(曾毅昆):
2012-11-13 20:34:05
Finally AC after a lot of mistake! my first linked list problem :-)
|
Added by: | Buda IM |
Date: | 2012-11-01 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own Problem |