This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
n,m,r,t,k = map(int,input().split())
X = [None]* n
for _ in range(k):
u,v = map(int,input().split())
if(X[u-1] == None):
X[u-1] = [v]
else:
X[u-1].append(v)
max_level = 0
for i in X:
if i != None:
max_level = max(max_level,len(i))
tc = 0
solved = set()
answers = []
for level in range(max_level):
for j in range(len(X)):
if(X[j] != None and level < len(X[j])):
if(X[j][level] not in solved):
tc += (r + (level * r))
solved.add(X[j][level])
answers.append([j+1,X[j][level],level * r])
print(len(solved),tc)
for item in answers:
print(*item,end=' ')
print()
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |