We will hold AtCoder Beginner Contest 275.
- Contest URL: https://atcoder.jp/contests/abc275
- Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20221029T2100&p1=248
- Duration: 100 minutes
- Number of Tasks: 8
- Writer: math957963, nok0, kyopro_friends, m_99
- Tester: leaf1415, physics0523
- Rated range: ~ 1999
The point values will be 100-200-300-400-500-500-600-600. We are looking forward to your participation!
how to solve task d?
By dfs
how? bfs used here?
Just apply recursion and memioze it using map.
Me: Problem C takes more time than E and F combined.
Is there an elegant way to solve C?
I found C a lot harder than E,F as well, so I'm also wondering :)
You can store all pawns and go through all possible 4 pawns('#') and check whether you can form a square using these 4 pawns or not.
Condition to check whether we can form a square:-
A). The set of distances for each point to its 3 neighbors must be the same.
[ [1,2,1], [2,1,1], [1,1,2], [2,1,1] ]
B). The 2 shortest distances among 3 distances must be the same ( In the above example it is 1 ).
My submission:- https://atcoder.jp/contests/abc275/submissions/36069709
Iterate over all the pairs of squares, consider this pair as a side and rotate this 90 degrees (counterclockwise, to do this : note that the slopes of perpendicular lines multiply to -1. so we need to swap dx and dy, multiply dx by -1) twice to get all four coordinates of the square. If all four coordinates have s[i][j] = '#', increase the answer by 1. Final answer will be ans/4 since all 4 sides generate the same square by counterclockwise rotation. Code. I learned this trick from Heno239's submission.
maybe you can try to fixed the "left upper" corner of the square, and enumrate the "top" edge. that's enough and no duplicate.
sample code. note that another point of top edge is relative to the top right of the first point. see inner for loops
math957963 Can you help me out, For Problem B. Why is the following piece of code giving WA. It is exactly the same as editorial.
PS: New to codeforces so don`t know how to wrap a code in block.
The problem is that the priority of * is higher than the one of %.
This is something new I learned today. Thanks alot!!
No. The precedence of the operators
*
and%
are the same (see row 5). The fact is that since they are left-associative,A % P * B % P
is parsed as( (A%P) * B ) % P
. SinceA%P
$$$\sim 10^9$$$ andB
$$$\sim 10^{18}$$$,(A%P) * B
possibly causes an overflow in a 64-bit integer type, resulting in a wrong answer.This is something new I learned today. Thanks a lot!!
How to solve today's C?
Other than check 4 sides are equal, also need to check if 2 adjacent sides are at right angle.
How to do F ?
let dp[i][j] be the minimum no.of operations required on the array A[i..N] to get the sum j. Take the transitions accordingly. Here is the link to my submission
Here provide a different solution of $$$G$$$.
$$$Binary Search$$$
Assume the answer is $$$mid$$$. we need to check if $$$X$$$ exist.
$$$X[i]$$$ is real-valued number.
let $$$P[i]=(c[i] - mid * b[i], c[i] - mid * a[i])$$$. The conditions becomes
let $$$G[i] = (\frac{P[i].y}{P[i].x}, [P[i].x\ge0])$$$. if $$$G[i].y=true$$$ and $$$G[i].x \ge 0$$$, $$$X$$$ exist.
Or we check if
code