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

Автор atcoder_official, история, 2 месяца назад, По-английски

We will hold AtCoder Beginner Contest 465.

We are looking forward to your participation!

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

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

It's difficult!!! I just pass A to E.

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

$$$E$$$ is a mammoth of a digit DP problem right? We compute digit DP's of all combinations of the 3 conditions and do inclusion-exclusion right?

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

How to solve E ?

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

Second AtCoder Contest. Improved from only solving A to B to being able to solve C (even though I joined 30 minutes late)! Hopefully I can solve A-C faster next time to start tackling D.

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

has anyone used trie in F, or its just not possible?

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

It has a unorginal problem.

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

First ABC. solved A, B quickly but got stuck for a bit on C. Couldn't grasp D and finished with 600.

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

I am such an idiot ,i solved A,B,E , couldn't solve c and d , for d i was trying to do bfs by keepign ranges of y , but i got tle,mle and wa

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

Can anyone tell me how to approach c, I guess it's a prefix computation problem because of given time constraints but I got struck...

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

    Try with a deque , i solved it with deque.

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

    you can try using two pointers.

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

    It's actually extremely simple once you get the pattern. You don't need a prefix sum for it.

    First of all notice that you shouldn't be checking the string from 'left to right' but actually from 'right to left.' That's because inversions at the beginning doesn't give any hint to the final positions of the number at those positions, since you don't know how many times you'll be inverting later on.

    But if you start from the last characters of the string 'right to left', if there's an inversion you can immediately tell that N (last number) should be placed at the beginning of the number array. That's because number N is unaffected by any of the inversions before it and is only inverted by the last character. This is recursively true for number N — 1.

    So you read the string from 'right to left' and interchange between right side and left side of the number array as you place the numbers from N to 1, and you'll get the answer in O(N) time.

    You can check my solution here (it's very short and I didn't use anything complicated): https://atcoder.jp/contests/abc465/submissions/77213807

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

    look at the alternating sum from the end like :

    // i goes to k + 1 - i if we reverse prefix of length k (all 1-based)
    // k are the points where s[k] == 'o'
    // for index i all k's to its right affect it
    // so just keep doing : [k3 + 1 - {k2 + 1 - (k1 + 1 - i)}], see the brackets .. [{()}]
    // or, (k3+1) - (k2+1) + (k1+1) - i
    // alt_sum = (k3+1) - (k2+1) + (k1+1) ... 
    
    int alt_sum = 0, sign = 1;
    for(int i = n; i >= 1; --i){
        if(s[i] == 'o'){
            alt_sum += sign * (i + 1);
            sign *= -1;
        }
        ans[alt_sum + sign * i] = i;
    }
    
  • »
    »
    2 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    i have implemented using 2 pointers in the below way.

    # Code:
    n = int(input())
    s = input()
    
    res = [0]*n
    
    l , r = 0 , n-1
    
    cnt = 0
    for i in range(n-1,-1,-1):
        cnt += (s[i] == 'o')
        if cnt % 2 == 1:
            res[l] = i+1
            l += 1
        else:
            res[r] = i+1
            r -= 1
    
    for r in res:
        print(r,end=" ")
    
    
  • »
    »
    2 месяца назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Maybe you can use a deque ,and exchange its head and tail with the char .Finally think about how to output it

    I'm sorry about my bad English,if you can't understand ,just ask me:)

    void solve(){
    	int n;
    	cin>>n;
    	string s;
    	cin>>s;
    	int t=0,q=1;
    	//t=0尾插 t=1头插
            //if t==0 push back the num, else push front the num
    	deque<int > a;
    	a.push_back(1);
    	
    	for(int i=1;i<n;i++){
    		if(s[i]=='x'){
    			if(!t)
    			a.push_back(++q);
    			else a.push_front(++q);
    		}
    		else{
    			if(!t)
    			a.push_back(++q);
    			else a.push_front(++q);
    			if(t)t=0;
    			else t=1;
    		}
    	}
    	if(t){
    		int x=a.size();
    		for(int i=x-1;i>=0;i--) cout<<a[i]<<" ";
    	}
    	else for(auto i:a) cout<<i<<" ";
    }
    
»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can some one tell me how to solve D ?

Facts That I came to know:
X -> (X / K) 
X -> (K * X + r) {r >= 0 & r < K} 

are the possible transformation's that we could do.

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

    Hey, the approach I took is, find the least common ancestor of X and Y. Bring down both values to 0 and check where they meet. special cases are when one number is itself included in other one.

    My solution: https://atcoder.jp/contests/abc465/submissions/77223657

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

    You need to observe that applying 1st operation after 2nd operation to $$$x$$$ will yield the same value $$$x$$$. So we have to apply 1st operation before 2nd one. Instead of applying 2nd operation to x, you can apply 1st operation to y. So LCA of operation 1 on x and y gives the answer.

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

    start BFS from X and Y , on each step the next node is X/K and Y/K,


    void solve() { ll x,y,k;cin>>x>>y>>k; using pll=pair<ll,ll>; priority_queue<pll,vector<pll>,greater<pll>>pq; pq.push({0ll,x}); pq.push({0ll,y}); map<ll,ll>mp; ll ans=-1; while(!pq.empty()){ auto [step,num]=pq.top(); pq.pop(); if(mp.count(num)){ ans=mp[num]+step; mp[num]=step; break; } mp[num]=step; if(num!=0) pq.push({step+1,num/k}); } cout<<ans<<endl; }
»
2 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

i got blank today don't know why

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

Anyone can help me with D? I think I can use some kind of graph, X / K operation can lead to multiple values of X (upto K — 1 variations) that give same result. But apart from that I am not able to proceed further?

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

I solved A and C (with a Treap ;//). IDK why B and D didn’t get accepted. I am yet to solve E and F.

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

I participated in virtual contest this morning, was able to solve A, B, C. Specifically C is a lovely problem. Upsolved D by some hints, now stuck in E, sunday started well.

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

C can also be solved using doubly linked list. All the reversals can be done in O(1)

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

Problem C is simpler than the previous ones, and the difficulty may be only 1200.

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

Digit circus is a hilarious reference

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

D had a really good logic. I did not get it, I wonder how I can get good at these!

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

May I ask hoe to do question E