SSK-DNB commited on
Commit
c39d49d
·
verified ·
1 Parent(s): 8c8f3d3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +177 -0
README.md CHANGED
@@ -23,3 +23,180 @@ configs:
23
  このデータセットは、deepmind/code_contestsからAtCoderのデータのみを抽出し、Pythonで正解として提出された最初のコードを取得して格納したものです。これにより、教師あり学習に適した形に整えられています。
24
 
25
  This dataset is created by extracting only the data from AtCoder within deepmind/code_contests and retrieving the first Python code submission marked as correct. As a result, it has been formatted to be suitable for supervised learning.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  このデータセットは、deepmind/code_contestsからAtCoderのデータのみを抽出し、Pythonで正解として提出された最初のコードを取得して格納したものです。これにより、教師あり学習に適した形に整えられています。
24
 
25
  This dataset is created by extracting only the data from AtCoder within deepmind/code_contests and retrieving the first Python code submission marked as correct. As a result, it has been formatted to be suitable for supervised learning.
26
+
27
+ # Example
28
+ description
29
+ ```
30
+ There are n persons who initially don't know each other. On each morning, two of them, who were not friends before, become friends.
31
+
32
+ We want to plan a trip for every evening of m days. On each trip, you have to select a group of people that will go on the trip. For every person, one of the following should hold:
33
+
34
+ * Either this person does not go on the trip,
35
+ * Or at least k of his friends also go on the trip.
36
+
37
+
38
+
39
+ Note that the friendship is not transitive. That is, if a and b are friends and b and c are friends, it does not necessarily imply that a and c are friends.
40
+
41
+ For each day, find the maximum number of people that can go on the trip on that day.
42
+
43
+ Input
44
+
45
+ The first line contains three integers n, m, and k (2 ≤ n ≤ 2 ⋅ 10^5, 1 ≤ m ≤ 2 ⋅ 10^5, 1 ≤ k < n) — the number of people, the number of days and the number of friends each person on the trip should have in the group.
46
+
47
+ The i-th (1 ≤ i ≤ m) of the next m lines contains two integers x and y (1≤ x, y≤ n, x≠ y), meaning that persons x and y become friends on the morning of day i. It is guaranteed that x and y were not friends before.
48
+
49
+ Output
50
+
51
+ Print exactly m lines, where the i-th of them (1≤ i≤ m) contains the maximum number of people that can go on the trip on the evening of the day i.
52
+
53
+ Examples
54
+
55
+ Input
56
+
57
+ 4 4 2
58
+ 2 3
59
+ 1 2
60
+ 1 3
61
+ 1 4
62
+
63
+
64
+ Output
65
+
66
+ 0
67
+ 0
68
+ 3
69
+ 3
70
+
71
+
72
+ Input
73
+
74
+ 5 8 2
75
+ 2 1
76
+ 4 2
77
+ 5 4
78
+ 5 2
79
+ 4 3
80
+ 5 1
81
+ 4 1
82
+ 3 2
83
+
84
+
85
+ Output
86
+
87
+ 0
88
+ 0
89
+ 0
90
+ 3
91
+ 3
92
+ 4
93
+ 4
94
+ 5
95
+
96
+
97
+ Input
98
+
99
+ 5 7 2
100
+ 1 5
101
+ 3 2
102
+ 2 5
103
+ 3 4
104
+ 1 2
105
+ 5 3
106
+ 1 3
107
+
108
+
109
+ Output
110
+
111
+ 0
112
+ 0
113
+ 0
114
+ 0
115
+ 3
116
+ 4
117
+ 4
118
+
119
+ Note
120
+
121
+ In the first example,
122
+
123
+ * 1,2,3 can go on day 3 and 4.
124
+
125
+
126
+
127
+ In the second example,
128
+
129
+ * 2,4,5 can go on day 4 and 5.
130
+ * 1,2,4,5 can go on day 6 and 7.
131
+ * 1,2,3,4,5 can go on day 8.
132
+
133
+
134
+
135
+ In the third example,
136
+
137
+ * 1,2,5 can go on day 5.
138
+ * 1,2,3,5 can go on day 6 and 7.
139
+ ```
140
+ solutions
141
+ ```
142
+ ```python
143
+ from collections import deque
144
+
145
+ def solve(adj, m, k, uv):
146
+ n = len(adj)
147
+ nn = [len(a) for a in adj]
148
+ q = deque()
149
+ for i in range(n):
150
+ if nn[i] < k:
151
+ q.append(i)
152
+ while q:
153
+ v = q.popleft()
154
+ for u in adj[v]:
155
+ nn[u] -= 1
156
+ if nn[u] == k-1:
157
+ q.append(u)
158
+ res = [0]*m
159
+ nk = len([1 for i in nn if i >= k])
160
+ res[-1] = nk
161
+ for i in range(m-1, 0, -1):
162
+ u1, v1 = uv[i]
163
+
164
+ if nn[u1] < k or nn[v1] < k:
165
+ res[i - 1] = nk
166
+ continue
167
+ if nn[u1] == k:
168
+ q.append(u1)
169
+ nn[u1] -= 1
170
+ if not q and nn[v1] == k:
171
+ q.append(v1)
172
+ nn[v1] -= 1
173
+
174
+ if not q:
175
+ nn[u1] -= 1
176
+ nn[v1] -= 1
177
+ adj[u1].remove(v1)
178
+ adj[v1].remove(u1)
179
+
180
+ while q:
181
+ v = q.popleft()
182
+ nk -= 1
183
+ for u in adj[v]:
184
+ nn[u] -= 1
185
+ if nn[u] == k - 1:
186
+ q.append(u)
187
+ res[i - 1] = nk
188
+ return res
189
+
190
+ n, m, k = map(int, input().split())
191
+ a = [set() for i in range(n)]
192
+ uv = []
193
+ for i in range(m):
194
+ u, v = map(int, input().split())
195
+ a[u - 1].add(v - 1)
196
+ a[v - 1].add(u - 1)
197
+ uv.append((u-1, v-1))
198
+
199
+ res = solve(a, m, k, uv)
200
+ print(str(res)[1:-1].replace(' ', '').replace(',', '\n'))
201
+ ```
202
+ ```