AtCoder Beginner Contest 350 Announcement
source link: https://codeforces.com/blog/entry/128633
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
We will hold AtCoder Beginner Contest 350.
We are looking forward to your participation!
6 hours ago, # | Best point values i have ever seen!!! |
3 hours ago, # | How to do D? |
-
a very easy approach other than DSU. first thing to observe is that in every connected component, every node will be friend to every other node. this leads us to the conclusion that every connected component should be a complete graph. in a complete graph, the number of edges is given as:
M=n(n−1)2M=n(n−1)2Now the problem is reduced to something very easy. For each connected component, find the number of nodes it has. this will gives us the required number of edges per connected component. After that you can either subtract m at the end or separately count the number of edges in every connected component and subtract it from the number of edges in a complete graph.
My Submission: Link
3 hours ago, # | wtf this tasks |
-
Exactly my thoughts. A-F is criminally bad. Idk about G.
-
What do you find bad about them ?
-
They are trivial and way too standard. I only read G 5 mins ago and it's terrible as well, I can't spoil the solution rn but it's a standard optimization, I regret not reading it earlier.
-
Today, I gave my first atcoder contest and was able to solve 4. How many problems are you able to solve in those contests, generally ? And, how many did you solve today ?
-
-
-
2 hours ago, # | Loved E |
2 hours ago, # | E — Toward 0 Problem Statement: You are given an integer N. You can perform the following two types of operations:Pay X yen to replace N with ⌊ A N ⌋.Pay Y yen to roll a die (dice) that shows an integer between 1 and 6, inclusive, with equal probability. Let b be the outcome of the die, and replace N with ⌊ b N ⌋. i didnt understand this question much but the testcases made it worst :( |
2 hours ago, # | Is G just small to large merging? |
-
Yes. My solution is: For each node I calculated its parent and depth in its component(a tree). Also I used union find to check if two nodes are in the same component. Notice that you can answer each query using calculated values. To merge two nodes, I recalculated the depth and parent of every node in the smaller component out of the two.
-
Could you help me find out why this solution gives RTE, TLE and WA? It seems to be what you described.
-
-
I remember who the parent is for every node + keep a DSU to tell which component is smaller for merging. When merging I update the parents in the smaller tree so that the node from current query becomes its root. The runtime is
24 ms
though, so I'm not sure if it's even necessary to merge small to large here?up: Resubmitted with random swaps and got TLE, so small to large seems necessary.
-
sqrt also passed: split vertices to small an big by current deg. for small store all pairs of neighbours (will be O(nn−−√)O(nn) total) in set.
For question D, I tried to do it with DSU but failed 16 cases don't know why. My implementation was like: long long find_parent(ll u,vector&parent) { if(u == parent[u]) { return parent[u]; } return parent[u] = find_parent(parent[u],parent); // For union void union_set(ll u,ll v,ll parentU,ll parentV,vector&parent,vector&ranks,ll &ans) { ll ru = ranks[parentU]; ll rv = ranks[parentV]; if(ru<rv) { swap(parentU,parentV); swap(rv,ru); } ans = ans + (ru-1)*rv + rv-1; parent[parentV] = parentU; ranks[parentU] += ranks[parentV]; Any idea what wrong I did? |
-
i can't read your code, but there can be more than one connected component, which you may have missed.
-
I considered that case also, and I have updated my code now.
That ans = ans + (ru-1)*rv + rv-1; is handling those cases in which when there are multiple components.
1 is connected with 2,3,4. So, 1's rank will be 4.
6 is connected with 7,8. So, 6's rank will be 3.
Now I want to connect 6 with 1. Now, this formula will do its job.
-
-
I was not able to understand D. In the last sample test case it is showing 12 as answer. can someone please explain how 12? I am getting more than 12. If i make 1 and 3 as friend and 3 and 4 are already are friend then i can make 1 and 4 friend as well.
-
Actually a simple dfs works:- For any connected component find the no of vertices(v) and edges(e) it has. Then the answer is simply incremented by (vC2-e) where vC2=(v*(v-1))/2 for each component.
My Submission https://atcoder.jp/contests/abc350/submissions/52589120
-
Your ideal is similar to mine, When there is a pair in so you have to subtract the answer which is 1. My code https://atcoder.jp/contests/abc350/submissions/52618619.
119 minutes ago, # | How to solve A and B for just 47 seconds? I could not even open the tasks for that time :) |
114 minutes ago, # | how to solve EE? |
-
DP calculating cost to reach 0 from current number. Min of 2 ways:
paying X yen for first way
X + f(num // A)
paying Y yet to throw the dice
(6 * Y + f(x // 2) + f(x // 3) + f(x // 4) + f(x // 5) + f(x // 6)) / 5
You get this from
f(x) = Y + (f(x // 1) + f(x // 2) + f(x // 3) + f(x // 4) + f(x // 5) + f(x // 6)) / 6
To get rid of the infinite recursion, move all f(x)'s to the left
-
The last equation should be —
f(x) = Y + (f(x // 1) + f(x // 2) + f(x // 3) + f(x // 4) + f(x // 5) + f(x // 6)) / 6
Instead of,
f(x) = (Y + f(x // 1) + f(x // 2) + f(x // 3) + f(x // 4) + f(x // 5) + f(x // 6)) / 6
To arrive at the equation —
f(x) = (6 * Y + f(x // 2) + f(x // 3) + f(x // 4) + f(x // 5) + f(x // 6)) / 5
P.S. — You have put Y in bracket and divided by 6 in the last equation.
-
96 minutes ago, # | what is problem with my solution in D? Three test case give me RE
Thanks a lot |
77 minutes ago, # | Since some people are not impressed with the problems, I'd like to counterbalance and say that I quite enjoyed this round. In particular I don't think the tasks being doable and their difficulty curve being smooth is a bad thing for a contest like this, what with it having 'Beginner' in the name and all. :) |
69 minutes ago, # | |
49 minutes ago, # | Is it possible to get banned in Atcoder? |
38 minutes ago, # | Can anyone tell me why this solution for problem F is giving rte? |
Actually, the brute force solution to problem G is correct. For instance, in order to make the brute force solution run most slowly, we can use the following graph and query 2 1 n21n every time: However, the maximum number of queries is 105105, so the best solution (to make the brute force solution run most slowly) is to use 5000050000 queries to build the graph I mentioned, and use the remaining 5000050000 to query 2 1 n21n. We can calculate that the brute force solution will run 50000×25000=1.25×10950000×25000=1.25×109 times at most [1][1]. With a 3s time limit, brute force can pass easily. [1][1]: If we use nn queries to build the graph, and use the remaining 100000−n100000−n to query 2 1 n21n, the brute force solution will run for n2×(100000−n)n2×(100000−n) times. Obviously, this is a quadratic function with a maximum value of 1.25×1091.25×109. |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK