Problem:


  MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

形状データ処理 

コンピュータグラフィクスでは、三次元の形状を表現する方法として、ポリゴンモデルが使われます。ポリゴンモデルとは、頂点座標と、それらの頂点のつなぎ方を与えて面を作るモデルです。

一般のポリゴンモデルでは、任意の多角形を扱えますが、今回は三角形からなるポリゴンモデルを考えることにします。任意のポリゴンモデルは三角形を表す面情報の集まりとして表すことができます。

一つの面情報は、３つの頂点を並べて表します。ただし、並び方が異なるだけで同じ３点からなる場合は、同じ面情報を表すことにします。例えば、下図の四面体で、頂点１,２,３を繋いでできる面は、頂点２,３,１や、頂点３,２,１などのように表すこともできます。このように、同じ面情報が複数あると無駄になるので、１つにまとめてしまった方が良いでしょう。 

面情報が与えられたとき、重複した面を無くすために消さなければならない面情報の個数を求めるプログラムを作成せよ。 

Input

入力は以下の形式で与えられる。

N
p11 p12 p13
p21 p22 p23
:
pN1 pN2 pN3

１行目に、ポリゴンモデルの面情報の数 N (1 ≤ N ≤ 1000) が与えられる。続く N 行に、i 番目の面を作るために使う頂点の番号 pij (1 ≤ pij ≤ 1000) が与えられる。ただし、一つの面について、同じ頂点を２度以上使うことはない（pi1 &ne; pi2 かつ pi2 &ne; pi3 かつ pi1 &ne; pi3 である）。

Output

重複した面を無くすために消さなければならない面情報の個数を１行に出力する。 

Sample Input 1

4
1 3 2
1 2 4
1 4 3
2 3 4 

Sample Output 1

0

Sample Input 2

6
1 3 2
1 2 4
1 4 3
2 3 4
3 2 1
2 3 1 

Sample Output 2

2

入出力例２では、１つ目と５つ目と６つ目の面は頂点1, 3, 2を使って三角形を作っていて、点の順番が異なるだけなので重複している。つまり、重複した面のうち２つの面を消せば重複した面は無くなる。



Sample input:
4
1 3 2
1 2 4
1 4 3
2 3 4


Sample output:
0

Submission status: Wrong Answer

Solution code:
l = []
N = int(input())
for i in range(N):
	a,b,c = map(int,input().split(' '))
	d = a + b + c
	l.append(d)

e = l.count(9)
f = l.count(8)
g = l.count(7)
h = l.count(6)

ans = 0

if e>1:
	ans += e - 1
if f>1:
	ans += f - 1
if g>1:
	ans += g - 1
if h>1:
	ans += h - 1

print(ans)

Submission status: Wrong Answer

Solution code:
l = []
N = int(input())
for i in range(N):
	a,b,c = map(int,input().split(' '))
	d = a + b + c
	l.append(d)

e = l.count(9)
f = l.count(8)
g = l.count(7)
h = l.count(6)

ans = 0

if e>1:
	ans += e - 1
if f>1:
	ans += f - 1
if g>1:
	ans += g - 1
if h>1:
	ans += h - 1

if e == 1 and f == 1 and g == 1 and h == 1:
	ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
l = []
N = int(input())
for i in range(N):
	a,b,c = map(int, input().split(' '))
	d = a + b + c
	l.append(d)

e = l.count(9)
f = l.count(8)
g = l.count(7)
h = l.count(6)

ans = 0

if e>1:
	ans += e - 1
if f>1:
	ans += f - 1
if g>1:
	ans += g - 1
if h>1:
	ans += h - 1

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
s = set()
for i in range(N):
	a,b,c = map(int,input().split(' '))
	d = a + b + c
	s.add(d)
print(N - len(s))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = []
for i in range(N):
	a,b,c = map(int,input().split(' '))
	d = a + b + c
	l.append(d)
	s = set(l)
print(N - len(s))

Submission status: Memory Limit Exceeded

Solution code:
N=int(input())
c=set()
for i in range(N):
    ls=input().split()
    ls.sort()
    ls_sum=ls[0]*1000**2+ls[1]*1000+ls[2]
    c.add(ls_sum)

print(N-len(c))

Submission status: Memory Limit Exceeded

Solution code:
N=int(input())
c=set()
for i in range(N):
    ls=input().split()
    ls.sort()
    ls_sum=ls[0]*1000000+ls[1]*1000+ls[2]
    c.add(ls_sum)

print(N-len(c))

Submission status: Accepted

Solution code:
N = int(input())
s = set()
for i in range(N):
    s.add(tuple(sorted(map(int, input().split()))))
print(N-len(s))

Submission status: Accepted

Solution code:
N,S=int(input()),set()
for _ in [0]*N:
    S.add(str(sorted(list(map(int,input().split())))))
print(N-len(S))

Submission status: Accepted

Solution code:
n = int(input())
l = [tuple(sorted(input().split())) for _ in range(n)]
print(len(l) - len(set(l)))

Submission status: Accepted

Solution code:
N = int(input())
l = []
s = set()
for i in range(N):
	a,b,c = map(int,input().split(' '))
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	d = str(l[0])
	e = str(l[1])
	f = str(l[2])
	g = d + e + f
	s.add(g)
	l = []
print(N - len(s))

Submission status: Accepted

Solution code:
# encoding: 'utf-8'

N = int(input())
ls = list()

for _ in range(N):
    e = sorted([int(x) for x in input().split()])
    if e in ls:
        continue
    else:
        ls.append(e)
print(N - len(ls))

Submission status: Accepted

Solution code:
n = int(input())
p = []
for i in range(n):
    p.append([int(num) for num in input().split()])

flag = []
for i in range(n):
    flag.append(False)
count = 0

for i in range(n):
    p[i].sort()

for i in range(n):
    if flag[i]:
        continue

    flag[i] = True
    for j in range(i + 1, n):
        if flag[j]:
            continue
        if (p[i][0] == p[j][0]) & (p[i][1] == p[j][1]) & (p[i][2] == p[j][2]):
            flag[j] = True
            count += 1

print(count)

Submission status: Accepted

Solution code:
n = int(input())
m = set()
c = 0
for _ in range(n):
    s = sorted(list(map(int, input().split())))
    s = tuple(s)
    if s in m:c += 1
    else:m.add(s)
print(c)

Submission status: Accepted

Solution code:
from collections import defaultdict
c = defaultdict(int)

N = raw_input().split(' ')[0]
for i in range(int(N)):
    c[frozenset((sorted([int(k) for k in raw_input().split(' ')[0:3]])))] += 1


print(sum([i - 1 for i in c.values() if i > 1]))

Submission status: Accepted

Solution code:
from collections import Counter
import string
import re

c = Counter()

N = int(re.split('\s', raw_input())[0])

for i in range(N):
  l = sorted([int(i) for i in re.split('\s', raw_input())[0:3]])
  c[frozenset(l)] += 1

print(len(list(c.elements())) - len(list(c)))

Submission status: Accepted

Solution code:
n = int(input())
save = set()
for _ in range(n):
  t = tuple(sorted(list(input().split())))
  save.add(t)
print(n - len(save))

Submission status: Accepted

Solution code:
N=int(input())
A=[]
for _ in range(0,N):
	a=list(map(int,input().split()))
	a.sort()
	if A.count(a)==0:
		A.append(a)

print(N-len(A))

Submission status: Accepted

Solution code:
N = int(input())
A = []
cnt = 0
for i in range(N) :
    x, y, z = map(int, input().split())
    a, c = min(x, y, z), max(x, y, z)
    b = x + y + z - a - c
    if [a, b, c] in A :
        cnt += 1
    else :
        A.append([a, b, c])
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
a = []
c = 0
for i in range(n):
    tmp = sorted(list(map(int, input().split())))
    if tmp in a:
        c += 1
    else:
        a.append(tmp)
print(c)

Submission status: Accepted

Solution code:
n=int(input())
a={tuple(sorted(list(map(int,input().split())))) for _ in range(n)}
print(n-len(a))

Submission status: Accepted

Solution code:

N = int(input())
id = set()
for l in range(N):
    a = [int(i) for i in input().split()]
    a.sort()
    id.add(a[0]*1000000 + a[1]*1000 + a[2])
    
print(N-len(id))

Submission status: Accepted

Solution code:
N = int(input())
l = []
count = 0
for _ in range(N):
    p = set(map(int, input().split()))
    if p in l: count+=1
    else: l.append(p)
print(count)

Submission status: Accepted

Solution code:
n=int(input())
n_keep=[]
count=0
for i in range(n):
    n_li=list(map(int,input().split()))
    n_li.sort()
    if n_li in n_keep:
        count+=1
    else:
        n_keep.append(n_li)
print(count)

Submission status: Accepted

Solution code:
def unique(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]


n = int(input())

point = []
for _ in range(n):
    p = list(map(int, input().split()))
    p.sort()
    point.append(p)

point_uni = unique(point)
ans = len(point) - len(point_uni)
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
V = []
n = 0
for _ in range(N):
    p = set(input().split())
    if p in V:
        n += 1
    else:
        V.append(p)
print(n)

Submission status: Accepted

Solution code:
n = int(input())
points = []
tmp = (list(map(int, input().split())))
tmp.sort()
points.append(tmp)

for i in range(n-1):
	new = list(map(int, input().split()))
	new.sort()
	flag = True
	for arr in points:
		if(arr[0] == new[0] and arr[1] == new[1] and arr[2] == new[2]):
			flag = False
	if(flag):
		points.append(new)
		
print(n - len(points))

Submission status: Runtime Error

Solution code:
l = []
N = int(input())
for i in range(N):
	a,b,c = map(int,input().split(' '))
	d = a + b + c
	l.append(d)

e = l.count(9)
f = l.count(8)
g = l.count(7)
h = l.count(6)

ans = 0

if e>1:
	ans += e - 1
if f>1:
	ans += f - 1
if g>1:
	ans += g - 1
if h>1:
	ans += h - 1

if e = 1 and f = 1 and g = 1 and h = 1:
	ans = 4

print(ans)

Submission status: Runtime Error

Solution code:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int N = s.nextInt();
		int[] I = new int[N];
		int D = 0;
		int E = 0;
		int F = 0;
		int G = 0;
		int ans = 0;

		for(int i=0;i<N;i++){
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();

			int n = a + b + c;
			I[i] = n;
		}
		for(int j=0;j<N;j++){
			int d = I[j];
			if(d==9){
				if(D!=1){
					D += 1;
				}else{
					ans += 1;
				}
			}
			if(d==8){
				if(E!=1){
					E += 1;
				}else{
					ans += 1;
				}
			}
			if(d==7){
				if(F!=1){
					F += 1;
				}else{
					ans += 1;
				}
			}
			if(d==6){
				if(G!=1){
					G += 1;
				}else{
					ans += 1;
				}
			}
		}
		System.out.println(ans);
	}
}

Submission status: Runtime Error

Solution code:
N = int(input())
s = set()
for i in range(N):
	a = map(int,input().split(' '))
	b = sorted(a)
	s.add(d)
print(N - len(s))

Submission status: Runtime Error

Solution code:
N = int(input())
s = set()
for i in range(N):
	a,b,c = map(str,input().split(' '))
	e = a + b + c
	e = sorted(d)
	s.add(e)
print(N - len(s))

Submission status: Runtime Error

Solution code:
N = int(input())
s = set()
l = []
for i in range(N):
	a,b,c = map(int,input().split(' '))
	l.append(a,b,c)
	e = sorted(l)
	s.add(e)
	l = 0
print(N - len(s))

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
for i in range(N):
	a,b,c = map(int,input().split(' '))
	l.append(a,b,c)
	l.sort()
	s.add(l)
	l = []
print(N - len(s))

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
for i in range(N):
	a,b,c = map(int,input().split(' '))
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	s.add(l)
	l = []
print(N - len(s))

Submission status: Runtime Error

Solution code:
N = int(input())
l = []
s = set()
for i in range(N):
	a,b,c = map(int,input().split(' '))
	l.append(a)
	l.append(b)
	l.append(c)
	l.sort()
	s.add(l)
	l = []
print(N - len(s))

Submission status: Runtime Error

Solution code:
# encoding: 'utf-8'

N = int(input())
ls = list()
for _ in range(N):
    e = sorted([int(x) for x in split(input())])
    if e in ls:
        continue
    else:
        ls.append(e)
print(N - len(ls))