Блог пользователя chokudai

Автор chokudai, история, 6 лет назад, По-английски

We will hold AtCoder Beginner Contest 166.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

  • Проголосовать: нравится
  • +77
  • Проголосовать: не нравится

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

Thank you atcoder for the wonderful weekend !!

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I wish it will be a good round!

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why so easy A,B,C,D,E?

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится +1 Проголосовать: не нравится

Why so much hate in this world cry

Get AC on A, B, C, D, E and WA only on the last of the 60 tests of the F...

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

![ ]()

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +26 Проголосовать: не нравится

How to solve F!

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve problem E?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

why greedy for F fails? anyone Please?

  • »
    »
    6 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    What do you do when both A and B are equal and next event is AB?

    For example: A = 1, B = 1 and C = 0 and event is AB.

    You need to check if next event is BC or AC and work accordingly. Can't just make anyone of it +1 and other -1.

    • »
      »
      »
      6 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Yeah for this I did offline thing. At every stage I checked if both are equal then which is having more query remaining. So the one with higher no of query remaining I add to it(give it priority)

      • »
        »
        »
        »
        6 лет назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится

        You should give priority to the next closest move, not to the most frequent among remaining. For example A = 1, B = 1, C = 0, and the sequence of moves is AB, AC, BC, BC, BC. On move AB you should add 1 to A, to make move AC possible, not to B, even though BC is more frequent.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

this F is not very hard,i think,but has a number of details to deal with.

i finally got accepted after 5 tries with a loooooooooooooong code.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Got 457 lines of code in F)

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

E anyone?

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I had a lot of TLEs with my solutions for this contest. For example, here is my code for problem E (C++):

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
		int N, count=0;
		cin>>N;
		int att[N];
		
		for(int i=0; i<N; i++){
			cin>>att[i];
		}
		
		for(int i=0; i<N-1; i++){
			
			for(int j=i+1; j<N; j++){

				if(abs((i+1)-(j+1))==(att[i]+att[j])){
					count++;
				}
			}
		}
		
		cout<<count;
	}
	

I got AC for half of the test cases, and TLE for the other half. Can anyone tell me why?

Also, if someone can tell me what might generally be the case when AtCoder grading returns a TLE, please let me know. Thanks in advance!

»
6 лет назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

What is the approach for F?

I tried defining each of the 8 choice possibilities (For AB choose A first or B if both remain, similary for AC and BC) at the start and check if it works. Do you have to do something like this at each step and maintain an 8 * n DP or something like that?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +24 Проголосовать: не нравится

For F I did complete search using recursion and it passed. Can anybody explain why?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

can someone help me in problem D ?

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

English Editorail of F

Three Variables Game • When A + B + C = 0, N is 1 or more, so the answer is No. • When A + B + C = 1, at least one of the two variables is zero at any time, so the action on each turn is uniquely determined. • When A + B + C> = 2, the answer is No if the variables added and subtracted in the first turn are both zero, otherwise the answer is Yes. In the latter case, you can keep one of the variables being added positive by taking the following strategy each turn. {When one of the variables to add and subtract is zero and the other is positive, add one to the one that is zero and subtract one from the other. (A + B + C = 2, the variables to add and subtract are both 1, and when the character string of the next turn and the character string of the current turn are different, not the last turn, the character addition and subtraction of the next turn is performed. Add 1 to the variable you plan to do and subtract 1 from the other. {Otherwise, select appropriately

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What wrong in my code for the problem D

x=int(input())
value=0
index=0
hashmap=dict()
while value<int(1e9)+1:
    value=pow(index,5)
    hashmap[value]=index
    index+=1
#print(hashmap)    

for i in range(1,64):
    b1=x+int(pow(i,5))
    b2=x+int(pow(-i,5))
    if hashmap.get(b1)!=None:
        print(hashmap[b1],i)
        break
    if hashmap.get(abs(b2))!=None:
        print(hashmap[abs(b2)],-i)
        break     
»
6 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

the language of D and E was so clear still couldn't solve it, got WA on last test case of E and TLE on D. I like atcoder's format easy language difficult task .makes these problems more approachable. Thanks Atcoder

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Please help me with problem E and F

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

Yay I full solved all 6 problems with 0 incorrect attempts!

Timing was slow though :(

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

I thought the problem statement on B was not clearly defined. Otherwise, it was such a great contest! got WA on both D and E because I did not take long. Feel like killing myself :( Gonna upsolve F now.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

I solved D by expressing A^5 — B^5 as (a − b)(a^4 + a^3*b + a^2*b^2 + a*b^3 + b^4).

At this point, I iterated over all possible divisors. Since a-b < (the term consisting of all positives), I only had to check the divisors less than sqrt(X). Then, once a-b was set, I binary searched to find the value of b (if any) to satisfy the expression.

My final runtime: optimized O(sqrt(X)*log(X))

»
6 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

In codeforces https://codeforces.me/contest/1345/problems we get list of all problems, how to do the same in atcoder, like all the task they appear in the same page. If anyone knows please comment the link of that page where all task appear on one page.

»
6 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I overkilled F with dp, followed by 14-15 RTE's :(

PS: Atcoder could really work to differentiate between MLE and RTE.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Solution in simple words:

A. Just check the input string.

B. Compute the food each person has. One can use a frequency array to do this.

C. Iterate through all paths. Each path makes one observatory non-peak (or two, if they have same height).

D. Since $$$a^5 - b^5 = X \gt 0$$$, we have $$$a \gt b$$$, that is $$$b \leq a - 1$$$. So $$$a^5 - (a - 1)^5 \geq a^5 - b^5 = X$$$. Obviously $$$f(x) = x^5 - (x - 1)^5$$$ is increasing when $$$x \gt 1$$$ and decreasing when $$$x \lt 0$$$, so we can find the upper and lower bound of $$$a$$$ from $$$X$$$. Simply enumerate all possible $$$a$$$'s and check if $$$a^5 - X$$$ is the fifth power of some integer. This can be done with precomputing all fifth powers in the potential range. In practice we can use a looser bound to estimate the range of $$$a$$$.

E. Consider the number of pairs $$$(i, j)$$$ satisfying $$$i \lt j$$$ and $$$A_i + A_j = j - i$$$. Fix $$$j$$$, the number of $$$i$$$'s pairing with $$$j$$$ satisfying $$$A_i + i = j - A_j$$$. Just iterate from left to right and keep the frequencies of all $$$A_i + i$$$.

F. In each operation we can greedily take $$$1$$$ from the greater number and add $$$1$$$ to the smaller one. The only exception is there being two $$$1$$$'s and one $$$0$$$ and we are going to operate on the $$$1$$$'s. We have to create another $$$0$$$ in this operation, so we need to consider the next operation in order to make it doable. The answer is No if any operation creates a negative number.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My python solution12793022

I am getting WA for one test case (killer_05.txt). Can somebody please tell me what am I missing? Thank you.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

https://atcoder.jp/contests/abc166/submissions/12803726 i am getting wrong ans on killer test 5 Can somebody help me out. It is for problem F atcoder 166

  • »
    »
    6 лет назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    I read it a bit fast but I think your mistake is in this case: "if(a[id1]==a[id2] && a[id1]==1 && a[id3]==0)".

    You are not taking into consideration the other special case where a[id2]=1 and a[id3]=0. Also the way you are searching for the future cases is wrong because you assign a char variable to a string one.

    Generally, I think that you only need to check for equality and increase the a[id], which is the one that will participate in a future choice sooner than the other.

»
6 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For D — detail explanation and reduced range of searching with code Here

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

For problem E, I found an interesting solution. Let's imagine there are n persons standing on n consecutive cells in a row, the question ask for how many pairs of them can reach each other if they lay down to the left or to the right, formally it 's number of pairs which have sum of their heights equal to their distance. So we just let each person lay down to the left and to the right and mark these points. Then we iterate all marked points and add $$$from\_left[point]*from\_right[point]$$$ to the answer, check my code