Problem:


数当てゲーム (Unique number) 

  問題

JOI 君は友達とゲームをすることにした．このゲームには N 人のプレイヤーが参加する．1 回のゲームのルールは次のようなものである：

それぞれのプレイヤーは 1 以上 100 以下の好きな整数をカードに書いて提出する．各プレイヤーは，自分と同じ数を書いた人が他にいなかった場合，自分の書いた数と同じ得点を得る．自分と同じ数を書いた人が他にいた場合は得点を得られない．

JOI 君たちはこのゲームを 3 回行った．各プレイヤーが 3 回のゲームにおいて書いた数が与えられたとき，各プレイヤーが 3 回のゲームで得た合計得点を求めるプログラムを作成せよ．

  入力

入力は 1 + N 行からなる．

1 行目には整数 N (2 ≦ N ≦ 200) が書かれており，プレイヤーの人数を表す．

続く N 行のうちの i 行目 (1 ≦ i ≦ N) には 3 つの 1 以上 100 以下の整数が空白を区切りとして書かれており，それぞれ i 人目のプレイヤーが 1 回目，2 回目，3 回目のゲームで書いた数を表す．

  出力

出力は N 行からなる．

i 行目 (1 ≦ i ≦ N) には i 人目のプレイヤーが 3 回のゲームで得た合計得点を表す整数を出力せよ．

  入出力例

入力例 1

  

5
100 99 98
100 97 92
63 89 63
99 99 99
89 97 98

出力例 1

   

0
92
215
198
89

入力例 1 では，各プレイヤーが 3 回のゲームで得た得点の詳細は次のようになる：

    
プレイヤー 1：   0 +   0 +   0 =   0

    
プレイヤー 2：   0 +   0 +  92 =  92

    
プレイヤー 3：  63 +  89 +  63 = 215

    
プレイヤー 4：  99 +   0 +  99 = 198

    
プレイヤー 5：  89 +   0 +   0 =  89

入力例 2
  

3
89 92 77
89 92 63
89 63 77

出力例 2

   

0
63
63

問題文と自動審判に使われるデータは、情報オリンピック日本委員会が作成し公開している問題文と採点用テストデータです。



Sample input:
5
100 99 98
100 97 92
63 89 63
99 99 99
89 97 98


Sample output:
0
92
215
198
89

Submission status: Wrong Answer

Solution code:
n = int(input())

lst = [list(map(int,input().split())) for i in range(n)]
p = [0 for i in range(n)]
for i in range(3):
  dic = [[] for _ in range(101)]
  for j in range(n):
    print(lst)
    dic[lst[j][i]].append(j)
  for x in range(101):
    l = dic[x]
    if lst:
      if len(l) == 1:
        p[l[0]] += x
for i in p:
  print(i)

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())
mems = [list(map(int, input().split(' '))) for _ in range(N)]
points = [0 for _ in range(N)]

for i in range(3):
    turn = {}
    for j in range(N):
        if mems[j][i] not in turn: turn[mems[j][i]] = 0
        turn[mems[j][i]] += 1

    for j in range(N):
        if turn[mems[j][i]] == 1: points[j] += mems[j][i]

for point in points:
    print(point)

Submission status: Accepted

Solution code:
n = input()
test = [[0]*3 for i in range(101)]
a = [map(int, raw_input().split()) for i in range(n)]
ans = [0]*n
for i in range(n):
    for j in range(3):
        test[a[i][j]][j] += 1
for i in range(n):
    for j in range(3):
        if test[a[i][j]][j] < 2: ans[i] += a[i][j]
for i in range(n):
    print ans[i]

Submission status: Accepted

Solution code:
n = int(input())
arr = [input().split() for _ in range(n)]
ans = [[-1 for _ in range(3)] for _ in range(n)]
for i in range(3):
    for j in range(n-1):
        if ans[j][i] == -1:
            for k in range(j+1,n):
                if arr[j][i] == arr[k][i]:
                    ans[j][i] = 0
                    ans[k][i] = 0
        if ans[j][i] == -1:
            ans[j][i] = int(arr[j][i])
    if ans[n-1][i] == -1:
        ans[n-1][i] = int(arr[n-1][i])
[print(x[0]+x[1]+x[2]) for x in ans]

Submission status: Accepted

Solution code:
import sys
def line():return sys.stdin.readline().strip()
N = int(line())
a = [[int(i) for i in line().split()] for _ in range(N)]

s = [0] * N
for i in range(3):
    c = [0] * 101
    for j in range(N):
        c[a[j][i]]+=1
    for j in range(N):
        if(c[a[j][i]] == 1):
            s[j]+=a[j][i]
for i in range(N):
    print(s[i])

Submission status: Accepted

Solution code:
N = input()
A = [map(int, raw_input().split()) for _ in range(N)]
S = [0]*N
for i in range(3):
    T = [0]*101
    for j in range(N):
        T[A[j][i]] += 1
    for j in range(N):
        if T[A[j][i]]==1:
            S[j] += A[j][i]
for s in S:
    print s

Submission status: Accepted

Solution code:
a,b,c=[0]*200,[0]*200,[0]*200
def check(a,n):
    for i in range(n-1):
        if not a[i]:continue
        t=a[i]
        for j in range(i+1,n):
            if t==a[j]:a[i],a[j]=0,0

if __name__ == '__main__':
    n=int(input())
    for i in range(n):a[i],b[i],c[i]=map(int,input().split())
    check(a,n)
    check(b,n)
    check(c,n)
    for i in range(n):print(a[i]+b[i]+c[i])

Submission status: Accepted

Solution code:
N = int(input())
score = [list(map(int, input().split())) for _ in range(N)]
players = [0 for _ in range(N)]
for play in list(zip(*score)):
    for i, p in enumerate(play):
        if play.count(p) == 1:
            players[i] += p
print(*players, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())
score = [input().split() for _ in range(N)]
players = [0]*N
for play in list(zip(*score)):
    for i, p in enumerate(play):
        if play.count(p) == 1:
            players[i] += int(p)
print(*players, sep='\n')

Submission status: Accepted

Solution code:
N = int(input())
score = [input().split() for _ in range(N)]
players = [0]*N
for play in zip(*score):
    for i, p in enumerate(play):
        if play.count(p) == 1:
            players[i] += int(p)
print(*players, sep='\n')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0577

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    N = int(input())
    scores = [0] * N            #  ????????¬?????????????????????0??§?????????
    data = [ [int(x) for x in input().split()] for _ in range(N)] #  ?????¬??????????????¨???3??????????????????

    rounds = [[]]                 #  ????????§??¨?????¬???????????????????????°??????????????? (1???????????????????????????????????????????????????)
    rounds.append([d[0] for d in data]) #  1??????
    rounds.append([d[1] for d in data]) #  2??????
    rounds.append([d[2] for d in data]) #  3??????

    # ????????????????¨????
    for i, d in enumerate(data):
        r1, r2, r3 = d
        if rounds[1].count(r1) == 1:
            scores[i] += r1
        if rounds[2].count(r2) == 1:
            scores[i] += r2
        if rounds[3].count(r3) == 1:
            scores[i] += r3

    # ?????¬??????????????¨??????????????¨???
    for s in scores:
        print(s)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
n=int(input())
l=[[int(s) for s in input().split(" ")]for i in range(n)]
pts=[0 for i in range(n)]
for i in range(3):
    dct={}
    nums=[sl[i] for sl in l]
    for num in nums:
        if num in dct:dct[num]+=1
        else:dct[num]=1
    for p in range(n):
        if dct[nums[p]]==1:pts[p]+=nums[p]
for point in pts:print(point)

Submission status: Accepted

Solution code:
def main():
    N = int(input())

    a = []
    for _ in range(N):
        a.append(list(map(int, input().split())))

    n = []
    c1 = 0
    for _ in range(3):
        hoge = []
        for x in range(N):
            hoge.append(a[x][c1])
        c1 += 1
        n.append(hoge)

    b = [0] * N
    for x in range(3):
        for y in range(N):
            c2 = 0
            for z in range(N):
                if n[x][y] == n[x][z]:
                    c2 += 1
                else:
                    pass
            if c2 == 1:
                b[y] += n[x][y]

    for x in range(N):
        print(b[x])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())

lst = [list(map(int,input().split())) for i in range(n)]
p = [0 for i in range(n)]
for i in range(3):
  dic = [[] for _ in range(101)]
  for j in range(n):
    dic[lst[j][i]].append(j)
  for x in range(101):
    l = dic[x]
    if lst:
      if len(l) == 1:
        p[l[0]] += x
for i in p:
  print(i)

Submission status: Accepted

Solution code:
# AOJ 0577: Unique number
# Python3 2018.6.30 bal4u

c = [[0 for j in range(3)] for i in range(101)]
n = int(input())
p = [[0 for j in range(3)] for i in range(n)]
for i in range(n):
	p[i] = list(map(int, input().split()))
	for j in range(3): c[p[i][j]][j] += 1
for i in range(n):
	s = 0
	for j in range(3):
		if c[p[i][j]][j] == 1: s += p[i][j]
	print(s)

Submission status: Accepted

Solution code:
n = input()

ans = [0 for i in range(n)]
f = []

for i in range(n):
  f.append(map(int, raw_input().split()))

for i in range(3):
  for j in range(n):
    ans[j] += f[j][i]
    for k in range(n):
      if j != k and f[j][i] == f[k][i]:
        ans[j] -= f[j][i]
        break

for i in range(n):
  print ans[i]

Submission status: Accepted

Solution code:
N=input()
s1,s2,s3=set(),set(),set()
L=[]
S=[set(),set(),set()]
R=[0]*N
for i in range(N):
    t1,t2,t3=map(int,raw_input().split())
    if t1 not in s1:
        s1.add(t1)
    else:
        S[0].add(t1)
    if t2 not in s2:
        s2.add(t2)
    else:
        S[1].add(t2)
    if t3 not in s3:
        s3.add(t3)
    else:
        S[2].add(t3)
    L.append([t1,t2,t3])
for i in range(len(L)):
    for j in range(len(L[0])):
        if L[i][j] not in S[j]:
            R[i]+=L[i][j]
    print R[i]

Submission status: Accepted

Solution code:
a = []
n = int(raw_input())
for _ in range(n):
    a.append(map(int, raw_input().split()))
for i in range(n):
    f = [1,1,1]
    for j in range(n):
        if i == j:
            continue
        for k in range(3):
            if a[i][k] == a[j][k]:
                f[k] = 0
    print a[i][0]*f[0] + a[i][1]*f[1] + a[i][2]*f[2]

Submission status: Accepted

Solution code:
a = [[0 for i in range(3)] for j in range(200)]
ans = [0]*200
n = input()
for i in range(n):
    a[i] = map(int, raw_input().split())
for t in range(3):
    for i in range(n):
        c = 1
        for j in range(n):
            if i==j: continue
            if a[i][t]==a[j][t]:
                c = 0; break;
        if c: ans[i] += a[i][t]
for i in range(n):
    print ans[i]

Submission status: Accepted

Solution code:
n=range(input())
a=[map(int,raw_input().split()) for i in n]
s=[0]*len(n)
for i in [0,1,2]:
	for j in n:
		for k in n:
			if j!=k and a[j][i]==a[k][i]:break
		else:s[j]+=a[j][i]
for i in s:print i

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int,input().split())) for i in range(n)]
A = [l[i][0] for i in range(n)]
B = [l[i][1] for i in range(n)]
C = [l[i][2] for i in range(n)]
p = [0 for i in range(n)]

for i in range(n):
    if A.count(l[i][0]) < 2:
        p[i] += l[i][0]
    if B.count(l[i][1]) < 2:
        p[i] += l[i][1]
    if C.count(l[i][2]) < 2:
        p[i] += l[i][2]
    print(p[i])

Submission status: Accepted

Solution code:
n = int(input())
first = []
second = []
third = []
ten = [0] * n
for i in range(n) :
    tmp = list(map(int, input().split()))
    first.append(tmp[0])
    second.append(tmp[1])
    third.append(tmp[2])

for i in range(n) :
    if first.count(first[i]) == 1 :
        ten[i] += first[i]
    if second.count(second[i]) == 1 :
        ten[i] += second[i]
    if third.count(third[i]) == 1 :
        ten[i] += third[i]
    
    print(ten[i])

Submission status: Accepted

Solution code:
N = int(input())
A = [[0 for _ in range(N)] for _ in range(4)]
for i in range(N):
	A[0][i], A[1][i], A[2][i] = map(int, input().split())
for j in range(3):
	for k in range(N):
		if A[j].count(A[j][k])==1:
			A[3][k] += A[j][k]

for l in A[3]: print(l)

Submission status: Accepted

Solution code:
N=int(input())
Z=list()
for i in range(N):
  Z.append(list(map(int,input().split())))
S=list()
for i in range(N):
  S.append(sum(Z[i]))
L=list()
for i in range(N):
  L=list(range(N))
  del L[i]
  for j in range(3):
    for k in range(N-1):
      if Z[L[k]][j]==Z[i][j]:
        S[i]=S[i]-Z[i][j]
        break
for i in range(N):
  print(S[i])

Submission status: Accepted

Solution code:
n = int(input())
scores = [list(map(int, input().split())) for _ in range(n)]

results = []
for x in zip(*scores):
   results.append([score if x.count(score) == 1 else 0 for score in x])

for x in list(zip(*results)):
    print(sum(x))

Submission status: Accepted

Solution code:
#B
N = int(input())
A = []
B = []
C = []

for i in range(N):
    a,b,c = map(int,input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    
ans = [0]*N
for i in range(N):
    a,b,c = A[i],B[i],C[i]
    if A.count(a) == 1:
        ans[i]+=a
    if B.count(b) == 1:
        ans[i]+=b
    if C.count(c) == 1:
        ans[i]+=c
        
    print(ans[i])

Submission status: Accepted

Solution code:
n = int(input())

a = []
b = []
c = []

for i in range(n):
    x,y,z = map(int, input().split())
    a.append(x)
    b.append(y)
    c.append(z)

for i in range(n):
    score = 0
    if a.count(a[i]) == 1:
        score += a[i]
    if b.count(b[i]) == 1:
        score += b[i]
    if c.count(c[i]) == 1:
        score += c[i]
    print(score)

Submission status: Accepted

Solution code:
n=int(input())
p=[list(map(int,input().split())) for _ in range(n)]
point=[0]*n
for j in range(3):
    r=[row[j] for row in p]
    for i in range(n):
        if i==0:
            if r[i] not in r[1:]:
                point[0]+=r[i]
        elif i==n-1:
            if r[i] not in r[:n-1]:
                point[n-1]+=r[i]
        else:
            p0=r[:i]+r[i+1:]
            if r[i] not in p0:
                point[i]+=r[i]
for i in point:
    print(i)

Submission status: Accepted

Solution code:

num = int(input())
P =[]
L = [[],[],[]]
for _ in range(num):
    p = [int(x) for x in input().split()]
    P.append(p)
    for i in range(3):
        L[i].append(p[i])

for p in P:
    sum = 0
    for i in range(3):
        if L[i].count(p[i]) < 2:
            sum += p[i]
    print(sum)

Submission status: Accepted

Solution code:
N = int(input())
all_game = [[int(j) for j in input().split()] for i in range(N)]
point = [0] * N

for g_i in range(3):
    g = [int(no[g_i]) for no in all_game]
    dic = {}
    for x in g:
        if x not in dic:
            dic[x] = 1
        else:
            dic[x] += 1
    for p_i in range(N):
        if dic[g[p_i]] == 1:
            point[p_i] += g[p_i]

for line in point:
    print(line)

Submission status: Accepted

Solution code:
n=int(input())
card=[[0 for i in range(3)] for j in range(n)]
for i in range(n):
    card[i][0],card[i][1],card[i][2]=map(int,input().split())
points=[0]*n
for i in range(3):
    chk=[]
    for j in range(n):
        chk.append(card[j][i])
    for j in range(n):
        if sum(card[j][i]==x for x in chk)==1:
            points[j]+=card[j][i]
for i in points:
    print(i)

Submission status: Accepted

Solution code:
n = int(input())
number = []
for _ in range(n):
    number.append(list(map(int, input().split())))

number = [list(num) for num in zip(*number)]
score = [0] * n

for num in number:
    for i, n in enumerate(num):
        if num.count(n) == 1:
            score[i] += n

for s in score:
    print(s)

Submission status: Accepted

Solution code:
N = int(input())
ans = [0 for i in range(N)]


arr1 = [[0 for i in range(N)] for j in range(3)]
for i in range(N):
	num = list(map(int, input().split()))
	arr1[0][i] = num[0]
	arr1[1][i] = num[1]
	arr1[2][i] = num[2]


for i in range(3):
	check = [0 for i in range(100)]
	for j in range(N):
		check[arr1[i][j]-1] += 1
		
	for j in range(N):
		if check[arr1[i][j]-1] == 1:
			ans[j] += arr1[i][j]

		

for i in range(N):
	print(ans[i])

Submission status: Accepted

Solution code:
N = int(input())
ans= [0 for i in range(N)]

arr1 = [[0 for i in range(N)] for j in range(3)]
for i in range(N):
    num = list(map(int, input().split()))
    arr1[0][i] = num[0]
    arr1[1][i] = num[1]
    arr1[2][i] = num[2]
    

for i in range(3):
    check = [0 for i in range(100)]
    for j in range(N):
        check[arr1[i][j]-1] += 1
    
    for j in range(N):
        if check[arr1[i][j]-1] == 1:
            ans[j] += arr1[i][j]
            
for i in range(N):
    print(ans[i])