Submission #764054

# Submission time Handle Problem Language Result Execution time Memory
764054 2023-06-23T06:21:09 Z rithikkatyal Programming Contest (POI11_pro) Python 3
0 / 100
1000 ms 7420 KB
n, m, r, t, k = map(int, input().split())
# graph = defaultdict(list)
graph ={}
matching = [-1] * m
degree = [0] * n
for i in range(n):
      if graph.get(i)==None:
        graph[i]=[]
# used = [0] * (n + 1)
# T = 0
# def try_dfs(v, deg):
#        global T
#        if used[v] == T:
#               return False
#        used[v] = T
#        if degree[v] > deg + 1:
#               return True
#        for u in graph[v]:
#               if try_dfs(matching[u], deg):
#                      degree[matching[u]] -= 1
#                      matching[u] = v
#                      degree[v] += 1
#                      return True
#        return False

def find(d,matching,degree):
       for u in range(m):
        if matching[u] == -1:
              for v in range(d,n):
                     if u in graph[v] and matching[u] == -1:
                            matching[u] = v
                            degree[v] += 1
                            if v<n-1:
                                   find(v+1,matching,degree)
                            else:
                                   return 0 
                            
 
for _ in range(k):
       u, v = map(int, input().split())
       u -= 1
       v -= 1
       graph[u].append(v)
 
find(0,matching,degree)
# for u in range(m):
#        if matching[u] == -1:
#               for v in range(n):
#                      if u in graph[v] and matching[u] == -1:
#                             matching[u] = v
#                             degree[v] += 1
#                             break
                
 
# updated = True
# while updated:
#        ds = [(degree[v], v) for v in range(n)]
#        ds.sort()
#        T += 1
#        updated = any(try_dfs(v, degree[v]) for _, v in ds)
 
penalty = 0
res = []
for v in range(n):
       degree[v] = min(degree[v], t // r)
 
for u in range(m):
       if matching[u] != -1 and degree[matching[u]]:
             # print(matching[u],degree[matching[u]])
              penalty += degree[matching[u]] * r
              degree[matching[u]] -= 1
              res.append((matching[u] + 1, u + 1, degree[matching[u]] * r))
res.sort(key=lambda x:(x[2],x[0]))        
print(len(res), penalty)
for el in res:
       print(el[0], el[1], el[2])
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 3028 KB It was possible to solve 100 problems and you solved only 57.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 2900 KB It was possible to solve 95 problems and you solved only 59.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 2972 KB It was possible to solve 80 problems and you solved only 36.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 61 ms 3220 KB It was possible to solve 200 problems and you solved only 137.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 676 ms 6140 KB It was possible to solve 494 problems and you solved only 207.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 242 ms 5444 KB It was possible to solve 500 problems and you solved only 167.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 297 ms 7420 KB It was possible to solve 500 problems and you solved only 250.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 578 ms 3532 KB It was possible to solve 390 problems and you solved only 124.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 249 ms 5780 KB It was possible to get penalty of 500 points and you received 11312.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1018 ms 3796 KB Time limit exceeded
2 Halted 0 ms 0 KB -