Problem:


サッカー (Soccer)  

  問題

  

JOI 国ではサッカーが人気であり，JOI リーグというリーグ戦が毎週行われている．

JOI リーグには N 個のチームが所属していて，1 から N までの番号がつけられている．すべての組み合わせの試合がちょうど一度ずつ行われる．つまり， N × (N - 1) / 2 試合が行われる．各試合の勝敗はそれぞれのチームの得点で決まる．勝ったチームの勝ち点は 3 点であり，負けたチームの勝ち点は 0 点である．引き分けの場合，両チームの勝ち点は 1 点である．順位は各チームの獲得した勝ち点の合計で決定し，得失点差は考えない．勝ち点の合計が等しいチームの順位は上位に揃える．

例として， 4 チームでのリーグ戦を考える．4 × (4 - 1) / 2 = 6 試合が行われる．それらの結果が以下の表のようになったとする．ハイフンの左側はその横のチームの得点であり，右側はその縦のチームの得点である．

	

		
		  チーム 1  
		  チーム 2  
		  チーム 3  
		  チーム 4  
		  勝ち数  
		  負け数  
		  引き分け数  
		  勝ち点  
	

	

		  チーム 1  
		---
		0 - 1
		2 - 1
		2 - 2
		1
		1
		1
		4
	

	

		  チーム 2  
		1 - 0
		---
		1 - 1
		3 - 0
		2
		0
		1
		7
	

	

		  チーム 3  
		1 - 2
		1 - 1
		---
		1 - 3
		0
		2
		1
		1
	

	

		  チーム 4  
		2 - 2
		0 - 3
		3 - 1
		---
		1
		1
		1
		4
	

このとき，勝ち点の最も多いチーム 2 が 1 位である．

その次に勝ち点が多いチームはチーム 1 とチーム 4 であり，これらのチームの順位は共に 2 位である．

そして勝ち点が最も少ないチーム 3 が 4 位である．

全ての試合の結果が与えられたとき，各チームの順位を求めるプログラムを作成せよ．

  入力

入力ファイルの 1 行目にはチームの個数 N (2 ≦ N ≦ 100) が書かれている．続く N × (N - 1) / 2 行には各試合の結果が書かれている．i + 1 行目 (1 ≦ i ≦ N × (N - 1) / 2) には整数 Ai，Bi，Ci，Di (1 ≦ Ai ≦ N，1 ≦ Bi ≦ N，0 ≦ Ci ≦ 100，0 ≦ Di ≦ 100) が空白を区切りとして書かれており，チーム Ai とチーム Bi が対戦し，チーム Ai の得点が Ci 点，チーム Bi の得点が Di 点であったことを表す．全ての i について Ai ≠ Bi であり，同じ組み合わせの対戦が書かれていることはない．

  出力

出力は N 行からなる．各行は 1 つの整数からなり， i 行目 (1 ≦ i ≦ N) の整数はチーム i の順位を表す．

  入出力例

入力例 1

  

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

出力例 1

2
1
4
2

入出力例 1 は問題文中の例に対応している．

入力例 2
 

5
1 2 1 1
3 4 3 1
5 1 1 2
2 3 0 0
4 5 2 3
1 3 0 2
5 2 2 2
4 1 4 5
3 5 4 0
2 4 0 1

出力例 2

2
4
1
4
3

入出力例 2 における結果は以下の通りである．

	

		
		  勝ち数  
		  負け数  
		  引き分け数  
		  勝ち点  
	

	

		  チーム 1  
		2
		1
		1
		7
	

	

		  チーム 2  
		0
		1
		3
		3
	

	

		  チーム 3  
		3
		0
		1
		10
	

	

		  チーム 4  
		1
		3
		0
		3
	

	

		  チーム 5  
		1
		2
		1
		4
	

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



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


Sample output:
2
1
4
2

Submission status: Wrong Answer

Solution code:
def f():
 N=int(input())
 s=[0]*N
 for _ in[0]*(N*~-N//2):
  a,b,c,d=map(int,input().split())
  s[a-1]+=3*(c>d)+(c==d)
  s[b-1]+=3*(d>c)+(d==c)
 b=[[]for _ in[0]*N*3]
 for i in range(N):b[s[i]]+=[i]
 r=1
 for x in b[::-1]:
  for y in x:s[y]=r;r+=1
 print(*s,sep='\n')
f()

Submission status: Wrong Answer

Solution code:
n=range(input())
l={i+1:0 for i in n}
for i in (n*n[-1])[::2]:
	a,b,c,d=map(int,raw_input().split())
	if c>d:l[a]+=3
	if c<d:l[b]+=3
	if c==d:
		l[a]+=1
		l[b]+=1
i=x=0
for k,v in sorted(l.items(),key=lambda x:x[1])[::-1]:
	if v!=x:i+=1
	l[k] = i
	x=v
for i in n:
	print l[i+1]

Submission status: Accepted

Solution code:
n = int(input())

score = [list(map(lambda x: int(x) - 1 , input().split())) for _ in range(int(n*(n-1)/2))]

points = [0 for _ in range(n)]

for a,b,c,d in score:
    if c > d:
        points[a] += 3
    elif c < d:
        points[b] += 3
    else:
        points[a] += 1
        points[b] += 1

rank = sorted(points)
rank.reverse()

for p in points: 
    print(rank.index(p) + 1)

Submission status: Accepted

Solution code:
n = int(input())

score = [list(map(lambda x: int(x) - 1 , input().split())) for _ in range(int(n*(n-1)/2))]

points = [0 for _ in range(n)]

for a,b,c,d in score:
    if c > d:
        points[a] += 3
    elif c < d:
        points[b] += 3
    else:
        points[a] += 1
        points[b] += 1

rank = sorted(points, reverse=True)

for p in points: 
    print(rank.index(p) + 1)

Submission status: Accepted

Solution code:
n=int(input());score=[list(map(lambda x:int(x)-1,input().split())) for _ in range(int(n*(n-1)/2))];points= [0]*n
for a,b,c,d in score: 
    if c>d:points[a]+=3 
    elif c<d:points[b]+=3 
    else:points[a]+=1;points[b]+=1
rank=sorted(points,reverse=True)
for p in points:print(rank.index(p)+1)

Submission status: Accepted

Solution code:
n=int(input());s=[list(map(int,input().split())) for _ in range(int(n*(n-1)/2))];p=[0]*n
for a,b,c,d in s: 
    if c>d:p[a-1]+=3 
    elif c<d:p[b-1]+=3 
    else:p[a-1]+=1;p[b-1]+=1
r=sorted(p,reverse=True)
for q in p:print(r.index(q)+1)

Submission status: Accepted

Solution code:
n=int(input());p=[0]*n
for i in range(n*(n-1)//2):
    a,b,c,d=map(int,input().split())
    if c>d:p[a-1]+=3 
    elif c<d:p[b-1]+=3 
    else:p[a-1]+=1;p[b-1]+=1
r=sorted(p,reverse=True)
for q in p:print(r.index(q)+1)

Submission status: Accepted

Solution code:
n = input()
p = {i:0 for i in range(n)}
for i in xrange(n*(n-1)/2):
    a,b,sa,sb = map(int, raw_input().split())
    if sa > sb: p[a-1]+=3
    elif sa < sb: p[b-1]+=3
    else: p[a-1]+=1; p[b-1]+=1
p = reversed(sorted(p.items(), key = lambda x:x[1]))
ans = [0]*n
rank = 0
same = 0
top = 1<<10
for k,v in p:
    if top != v:
        rank += same + 1
        ans[k] = rank
        same = 0
    else:
        ans[k] = rank
        same += 1
    top = v
for i in ans:
    print i

Submission status: Accepted

Solution code:
N = input()
X = [0]*N
for _ in range(N*(N-1)/2):
  A,B,C,D = map(int, raw_input().split())
  if C>D:
    X[A-1] += 3
  elif D>C:
    X[B-1] += 3
  else:
    X[A-1] += 1
    X[B-1] += 1

for i in range(N):
  c = 0
  for x in X:
    if x>X[i]:
      c += 1
  print c+1

Submission status: Accepted

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

"""
import sys
from sys import stdin
from heapq import heappop, heappush
input = stdin.readline


def main(args):
    N = int(input())
    scores = [0] * (N+1)
    scores[0] = -1
    results = [-1] * (N+1)

    for _ in range(N*(N-1)//2):
        a, b, c, d = [int(x) for x in input().split()]
        if c > d:
            scores[a] += 3
        elif c < d:
            scores[b] += 3
        else:
            scores[a] += 1
            scores[b] += 1

    pq = []
    for i, s in enumerate(scores[1:], start=1):
        heappush(pq, [-s, i])

    rank = 1
    display_rank = 1
    prev_score = float('inf')
    while pq:
        s, i = heappop(pq)
        if s == prev_score:
            results[i] = rank
        else:
            rank = display_rank
            results[i] = rank
        display_rank += 1
        prev_score = s

    for r in results[1:]:
        print(r)



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

Submission status: Accepted

Solution code:
n=int(input())
macthes=[[int(s)for s in input().split(" ")]for i in range(n*(n-1)//2)]
pts=[0 for i in range(n)]
for m in macthes:
    if m[2]>m[3]:pts[m[0]-1]+=3
    elif m[2]<m[3]:pts[m[1]-1]+=3
    else:
        pts[m[0]-1]+=1
        pts[m[1]-1]+=1
d={}
for pt in pts:
    if pt in d:d[pt]+=1
    else:d[pt]=1
ks=sorted(d.keys(),reverse=True)
ag=1
r={}
for k in ks:
    r[k]=ag
    ag+=d[k]
for pt in pts:
    print(r[pt])

Submission status: Accepted

Solution code:
t = int(input())
point_l = [0 for i in range(t)]
for i in range(int(t*(t-1)/2)):
    tmp = [int(x) for x in input().split()]
    if tmp[2] > tmp[3]:
        point_l[tmp[0]-1] += 3
    elif tmp[3] > tmp[2]:
        point_l[tmp[1]-1] += 3
    elif tmp[2] == tmp[3]:
        point_l[tmp[0]-1] += 1
        point_l[tmp[1]-1] += 1

rank_l = [0 for i in range(t)]
rank = 1
for l in sorted(point_l, reverse=True):
    dup = point_l.count(l)
    for j in range(dup):
        rank_l[point_l.index(l)] += rank
        point_l[point_l.index(l)] = -1
    rank += dup

for l in rank_l:
    print(l)

Submission status: Accepted

Solution code:
INF = 1000000000000
n = int(input())
rank = [0 for i in range(n)]
plst = [[0, i] for i in range(n)]

for i in range(n * (n - 1) // 2):
  a,b,c,d = map(int,input().split())
  if c == d:
    plst[a - 1][0] += 1
    plst[b - 1][0] += 1
  elif c < d:
    plst[b - 1][0] += 3
  else:
    plst[a - 1][0] += 3

plst.sort(reverse=True)

count = 0
same_num = 1
pre_point = INF

for p in plst:
  point = p[0]
  t_num = p[1]
  if point < pre_point:
    pre_point = point
    count += same_num
    rank[t_num] = count
    same_num = 1
  elif point == pre_point:
    same_num += 1
    rank[t_num] = count

for r in rank:
  print(r)

Submission status: Accepted

Solution code:
N=int(input())
s=[0]*N
for _ in[0]*(N*~-N//2):
 a,b,c,d=map(int,input().split())
 s[a-1]+=3*(c>d)+(c==d)
 s[b-1]+=3*(d>c)+(d==c)
b=[[]for _ in[0]*N*3]
for i in range(N):
 b[s[i]]+=[i]
r=1
for x in b[::-1]:
 for y in x:
  s[y]=r
 if x:r+=len(x)
print(*s,sep='\n')

Submission status: Accepted

Solution code:
def f():
 N=int(input())
 s=[0]*N
 for _ in[0]*(N*~-N//2):
  a,b,c,d=map(int,input().split())
  s[a-1]+=3*(c>d)+(c==d)
  s[b-1]+=3*(d>c)+(d==c)
 b=[[]for _ in[0]*N*3]
 for i in range(N):b[s[i]]+=[i]
 r=1
 for x in b[::-1]:
  for y in x:s[y]=r
  if x:r+=len(x)
 print(*s,sep='\n')
f()

Submission status: Accepted

Solution code:
def f():
 from heapq import heappop, heappush
 N=int(input())
 r=[0]*N
 for _ in[0]*(N*~-N//2):
  a,b,c,d=map(int,input().split())
  r[a-1]+=3*(c>d)+(c==d)
  r[b-1]+=3*(d>c)+(d==c)
 b=[[]for _ in[0]*N*3]
 for i in range(N):b[r[i]]+=[i]
 pq = []
 for i, s in enumerate(r):heappush(pq,[-s,i])
 rank=1
 display_rank=1
 prev_score=float('inf')
 while pq:
  s,i=heappop(pq)
  if s!=prev_score:rank=display_rank
  r[i]=rank
  display_rank+=1
  prev_score=s
 print(*r,sep='\n')
f()




########################################################################################################################
##################################################v
################################################################################
##########v####################v##############################v##########v

Submission status: Accepted

Solution code:
def f():
 from heapq import heappop, heappush
 N=int(input())
 r=[0]*N
 for _ in[0]*(N*~-N//2):
  a,b,c,d=map(int,input().split())
  r[a-1]+=3*(c>d)+(c==d)
  r[b-1]+=3*(d>c)+(d==c)
 b=[[]for _ in[0]*N*3]
 for i in range(N):b[r[i]]+=[i]
 pq = []
 for i, s in enumerate(r):heappush(pq,[-s,i])
 rank=1
 display_rank=1
 prev_score=float('inf')
 while pq:
  s,i=heappop(pq)
  if s!=prev_score:rank=display_rank
  r[i]=rank
  display_rank+=1
  prev_score=s
 print(*r,sep='\n')
f()

Submission status: Accepted

Solution code:
# AOJ 0566: Soccer
# Python3 2018.6.30 bal4u

n = int(input())
m = n*(n-1)>>1
team = [[0 for j in range(3)] for i in range(n)] #[id,win,lost]
for i in range(n): team[i][0] = i
for i in range(m):
	a, b, c, d = map(int, input().split())
	a, b = a-1, b-1
	if   c > d: team[a][1] += 3
	elif c < d: team[b][1] += 3
	else:
		team[a][1] += 1
		team[b][1] += 1
team.sort(key=lambda x:(-x[1],x[0]))
team[0][2] = 1
for i in range(1, n):
	if team[i][1] == team[i-1][1]: team[i][2] = team[i-1][2]
	else: team[i][2] = i+1
team.sort()
for i in range(n): print(team[i][2])

Submission status: Accepted

Solution code:
N = int(raw_input())
score = [0] * N

for x in xrange(N * (N - 1) / 2):
    a, b, sa, sb = map(int, raw_input().split(' '))
    if sa > sb:
        score[a - 1] += 3
    elif sa < sb:
        score[b - 1] += 3
    else:
        score[a - 1] += 1
        score[b - 1] += 1

for t in score:
    print len(filter(lambda x: x > t, score)) + 1

Submission status: Accepted

Solution code:
N=input()
L=[0]*(N+1)
for i in range(N*(N-1)/2):
    A,B,C,D=map(int,raw_input().split())
    if C>D:
        L[A]+=3
    elif C<D:
        L[B]+=3
    else:
        L[A]+=1
        L[B]+=1
for i in range(1,N+1):
    cnt=0
    for j in range(1,N+1):
        if L[i]<L[j]:
            cnt+=1
    print cnt+1

Submission status: Accepted

Solution code:
n = input(); t = dict(zip(range(1,n+1),[0]*n))
for i in xrange(n*(n-1)/2):
    a,b,c,d=map(int, raw_input().split())
    if c==d:
        t[a]+=1; t[b]+=1;
    elif c>d:
        t[a]+=3
    else:
        t[b]+=3
c = 0; cnt = 0; p = -1;
for k, v in sorted(t.items(), key = lambda x:x[1], reverse=True):
    cnt += 1;
    if p!=t[k]:
        c = cnt; p = t[k];
    t[k] = c
for v in t.values():
    print v

Submission status: Accepted

Solution code:
n = int(raw_input())
dic = {}
rank = {}
count = 0
now_rank = -1
prev = -1
for i in range(n):
    dic[i] = 0
for i in range(n*(n-1)/2):
    a, b, c, d = [int(i) for i in raw_input().split(" ")]
    if c > d: 
        dic[a-1] += 3
    elif c < d:
        dic[b-1] += 3
    else: 
        dic[a-1] += 1
        dic[b-1] += 1

l = dic.items()
l.sort(cmp=(lambda x,y: cmp(y[1], x[1])))
for i in range(len(l)):
    if prev == l[i][1]:
        count += 1
    else :
        now_rank += count + 1
        prev = l[i][1]
        count = 0
    rank.update({l[i][0]:now_rank+1})

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

Submission status: Accepted

Solution code:
n=input()
l=[0]*(n+1)
for i in range(n*(n-1)/2):
    a,b,c,d=map(int,raw_input().split())
    if c>d:l[a]+=3
    if c<d:l[b]+=3
    if c==d:
    	l[a]+=1
        l[b]+=1
for i in range(1,n+1):
    x=1
    for j in range(1,n+1):
        if l[i]<l[j]:x+=1
    print x

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int,input().split())) for i in range(n*(n-1)//2)]
p = [[0,i,0] for i in range(n+1)]

for i in range(n*(n-1)//2):
    if l[i][2] == l[i][3]:
        p[l[i][0]][0] += 1
        p[l[i][1]][0]  += 1
    elif l[i][2] > l[i][3]:
        p[l[i][0]][0]  += 3
    else:
        p[l[i][1]][0]  += 3

p = sorted(p,key = lambda x:-x[0])
p.pop(-1)

rank = 1
k = [p[i][0] for i in range(n)]

for i in range(n):
    if k.count(p[i][0]) == 1:
        p[i][2] = rank
        rank += 1

    else:
        p[i][2] = rank
        if i+2 == rank + k.count(p[i][0]):
            rank += k.count(p[i][0])

p = sorted(p,key = lambda x:x[1])
for i in range(n):
    print(p[i][2])

Submission status: Accepted

Solution code:
n = int(input())
R = {}
for i in range(n): R[i] = 0
for _ in range(n*(n-1)//2):
	a, b, c, d = map(int, input().split())
	if c>d:
		R[a-1] += 3
	elif c==d:
		R[a-1] += 1
		R[b-1] += 1
	else:
		R[b-1] += 3

rank, temp = 1, -1
ranks = []
R = sorted(R.items(), key=lambda x:-x[1])
#print(R)
for i in range(len(R)):
	if temp!=R[i][1]:
		rank = i+1
		ranks.append([R[i][0], i+1])
	else:
		ranks.append([R[i][0], rank])
	temp = R[i][1]

ranks = sorted(ranks)
for i in ranks:
	print(i[1])

Submission status: Accepted

Solution code:
n = int(input())
m = int(n * (n-1) / 2)
score = list(0 for i in range(n))
for i in range(m) :
    team1, team2, score1, score2 = map(int, input().split())
    if score1 == score2 :
        score[team1 - 1] += 1
        score[team2 - 1] += 1
    elif score1 > score2 :
        score[team1 - 1] += 3
    else :
        score[team2 - 1] += 3

sorted_score = sorted(score, reverse=True)
for i in range(n) :
    print(sorted_score.index(score[i])+1)

Submission status: Accepted

Solution code:
def main():
	number_of_team = int(input())
	#チーム数
	result_matrix = [list(map(int, input().split())) for l in range(int(number_of_team*(number_of_team-1)/2))]
	#入力される試合の結果
	points_of_team = [0 for l in range(number_of_team)]
	#勝ち点を保存するリスト
	
	
	#勝ち点の計算
	for low in result_matrix:
		if low[2] == low[3]:
			points_of_team[int(low[0])-1] += 1
			points_of_team[int(low[1])-1] += 1
		elif low[2] > low[3]:
			points_of_team[int(low[0])-1] += 3
		else:
			points_of_team[int(low[1])-1] += 3

	sort_list = sorted(points_of_team,reverse=True)
	result_list = [0 for i in range(number_of_team)]#出力用のリスト
	rank = 1
	pred = sort_list[0]
	for i in range(number_of_team):
		max_index = points_of_team.index(sort_list[i])
		if pred != sort_list[i]:
			pred = sort_list[i]
			rank = i+1			

		result_list[max_index] = rank
		points_of_team[max_index] = -1

	for i in range(number_of_team):
		print(result_list[i])
		
	

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
#B
N = int(input())
ABCD = [list(map(int,input().split())) for i in range(N*(N-1)//2)]

point = [[0,i] for i in range(N)]

for abcd in ABCD:
    a,b,c,d = abcd
    if c > d:
        point[a-1][0]+=3
    elif c < d:
        point[b-1][0]+=3
    else:
        point[a-1][0]+=1
        point[b-1][0]+=1
        
rank = [0]*N
point.sort(reverse=True)

mae = 0
now = 0
for i in range(N):
    p = point[i][0]
    ind = point[i][1]
    if p != mae:
        mae = p
        now = i
        rank[ind] = now+1
    else:
        rank[ind] = now+1
        
for r in rank:
    print(r)

Submission status: Accepted

Solution code:
n = int(input())
score = [0]*n
for i in range(n*(n-1)//2):
    x, y, a, b = map(int, input().split())
    if a > b:
        score[x-1] += 3
    elif a < b:
        score[y-1] += 3
    else:
        score[x-1] += 1
        score[y-1] += 1

s = [1]*n
for i in range(n):
    for j in range(n):
        if score[i] < score[j]:
            s[i] += 1
    print(s[i])

Submission status: Accepted

Solution code:
n = int(input())
point = [0] * n
for i in range(n * (n - 1) // 2):
    A, B, X, Y = map(int, input().split())
    if X > Y:
        point[A - 1] += 3
    elif Y > X:
        point[B - 1] += 3
    else:
        point[A - 1] += 1
        point[B - 1] += 1

point_sorted = sorted(point, reverse=True)

for i in range(n):
    print(point_sorted.index(point[i]) + 1)

Submission status: Accepted

Solution code:
def main():
	team_num  = int(input())
	match_num = int((team_num * (team_num - 1)) / 2)
	win_points = {}

	for i in range(team_num):
		win_points[i+1] = 0

	for i in range(match_num):
		match_result = input().split(" ")
		teamA_num    = int(match_result[0])
		teamB_num    = int(match_result[1])
		teamA_point  = int(match_result[2])
		teamB_point  = int(match_result[3])

		if teamA_point > teamB_point:
			# TeamA Win
			win_points[teamA_num] += 3
		elif teamA_point < teamB_point:
			# TeamB Win
			win_points[teamB_num] += 3
		else:
			# Draw
			win_points[teamA_num] += 1
			win_points[teamB_num] += 1

	win_points_sorted = sorted(win_points.items(), key=lambda x:x[1], reverse=True)

	pre_team_point = -1
	ranks = [0]*team_num
	rank = 0
	for i in range(len(win_points_sorted)):
		if win_points_sorted[i][1] != pre_team_point:
			rank = i+1
		ranks[win_points_sorted[i][0]-1] = rank
		pre_team_point = win_points_sorted[i][1]

	for i in ranks:
		print(i)


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n=int(input())
point=[0]*(n+1)
for i in range(int(n*(n-1)/2)):
    a,b,c,d=map(int,input().split())
    if c>d:
        point[a]+=3
    elif d>c:
        point[b]+=3
    elif c==d:
        point[a]+=1
        point[b]+=1
point_s=point[:]
point_s.sort(reverse=True)
for i in point[1:]:
    print(point_s.index(i)+1)

Submission status: Accepted

Solution code:
import copy

n = int(input())
game = n * (n-1) // 2

point = [0] * n
for _ in range(game):
    a, b, c, d = map(int, input().split())
    if c > d:
        point[a-1] += 3
    elif c < d:
        point[b-1] += 3
    else:
        point[a-1] += 1
        point[b-1] += 1

point_tmp = copy.deepcopy(point)
point_tmp.sort(reverse=True)

grade = [0] * n
for i, p in enumerate(point):
    grade[i] = point_tmp.index(p) + 1

for g in grade:
    print(g)

Submission status: Runtime Error

Solution code:
t = int(input())
point_l = [0 for i in range(t)]
for i in range((t*(t-1))/2):
    input_line = input()
    tmp = [int(x) for x in input_line.rstrip().split(' ')]
    if tmp[2] > tmp[3]:
        point_l[tmp[0]-1] += 3
    elif tmp[3] > tmp[2]:
        point_l[tmp[1]-1] += 3
    elif tmp[2] == tmp[3]:
        point_l[tmp[0]-1] += 1
        point_l[tmp[1]-1] += 1

rank_l = [0 for i in range(t)]
rank = 1
for l in sorted(point_l, reverse=True):
    dup = point_l.count(l)
    for j in range(dup):
        rank_l[point_l.index(l)] += rank
        point_l[point_l.index(l)] = -1
    rank += dup

for l in rank_l:
    print(l)