atcoder_official's blog

By atcoder_official, history, 27 hours ago, In English

We will hold KAJIMA CORPORATION CONTEST 2025 (AtCoder Beginner Contest 394).

We are looking forward to your participation!

  • Vote: I like it
  • +15
  • Vote: I do not like it

»
12 hours ago, # |
  Vote: I like it +43 Vote: I do not like it

If this ABC as shit as the last ABC, I will ban you.

  • »
    »
    5 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    lol

  • »
    »
    4 hours ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Although you are not the true system user, I still upvote your comment.

  • »
    »
    3 hours ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    I really hope this will come true.

  • »
    »
    91 minute(s) ago, # ^ |
    Rev. 3   Vote: I like it +4 Vote: I do not like it

    As shit as before

»
8 hours ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

it seems blogs of ABC get less and less upvotes even get downvotes.

upd: this round is worse than last one again.

»
7 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Wish no more AI Best Contest plz.

»
5 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

painful

»
94 minutes ago, # |
  Vote: I like it -9 Vote: I do not like it

Why ABC G. is so hard?

»
77 minutes ago, # |
Rev. 2   Vote: I like it +1 Vote: I do not like it

Problem E is very similar to [POI 2009] Bytie-boy's Walk.

In POI, it shows us that E can be solved with time complexity $$$O(n^2V+nm)$$$. ($$$V=26$$$, $$$m$$$ is the number of edges).

»
76 minutes ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Why this gives TLE for E in 2 test cases ?

Code
»
76 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve E?

»
74 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

man how i do the c better than this ? Sorry my english is bad :(

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define f first
#define s second

bool temWA(string str){
    for(int i = 0; i < str.length() - 1; i++){
        if(str[i] == 'W' && str[i+1] == 'A') return true;
    }

    return false;
}


int main(){
    string str; cin >> str;
    
    while(temWA(str)){
        for(int i = 0; i < str.length() - 1; i++){
        if(str[i] == 'W' && str[i+1] == 'A'){
            str[i] = 'A';
            str[i+1] = 'C';
        }
    }
    }

    cout << str << endl;
}

  • »
    »
    73 minutes ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    iterate from right to left if WA is found replace it with AC

»
73 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

I don't know if problems like A and B should be even in a beginner contest! Atcoder became more reliant on speed more than anything else. Problem E was pain ngl

»
72 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Anyone could please provide a testcase for my submissión for problem D? I failed just two cases :')

My submission

Thanks in advance

»
72 minutes ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

after contest i tried with o3-mini it solves E in one shot after giving my intuition. my TLE code : https://atcoder.jp/contests/abc394/submissions/63054891 o3-mini code: https://atcoder.jp/contests/abc394/submissions/63064525

today's problem set was nice but D was way more easier than C for me

  • »
    »
    59 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Disagree!! C was the easiest one.

  • »
    »
    52 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I'm surprised to see the o3-mini code passing the time limit. The complexity is $$$O(n^4)$$$ and it takes 8s on a max test.

»
70 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Why is this wrong for F Alkane?

Code
  • »
    »
    50 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I had the same idea and i can't figure out what's wrong either...

  • »
    »
    42 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    This is wrong because you can take the nodes which have degree > 4 in the original graph to be the part of the subgraph. You just need to ensure that in the subgraph the degree is exactly 4.

    E.g. case:

    6
    1 2
    1 3
    1 4
    1 5
    1 6
    

    Here in the original graph, the degree of node 1 is 5, your solution will ignore the node 1. But you can take nodes 1, 2, 3, 4, 5 and create an alkane out of them.

    • »
      »
      »
      39 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      OH Yes you are right , i mistakenly thought that given inputs are having degree of any node at max 4

»
61 minute(s) ago, # |
  Vote: I like it +2 Vote: I do not like it

The problems in ABC contests are becoming increasingly easier, making rankings largely dependent on the speed of coding.

e.g. slower 10 min will get nearly 1000 rank down

»
59 minutes ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Me,too. Why is this wrong for F Alkane?

I use Tree dp and classification discussion,but WA;

Who can give me a sample ,or find my mistake.

Thanks!

#include<bits/stdc++.h>
using namespace std;
#define ll long long 
vector<ll> v[200050];
ll du[200050];
vector<ll> st[200050];
map<ll,ll> mp[200050];
bool cmp(ll c,ll d)
{
	return c>d;
}
ll dfs(ll fa,ll now)
{
	if(mp[fa].count(now))
	{	
		return mp[fa][now];
	}
	if(du[now]>=4)
	{
		st[now].clear();
		for(ll it:v[now])
		{
			if(it!=fa)
			{
				ll k=dfs(now,it);
				st[now].push_back(k);
			}	
		}
		sort(st[now].begin(),st[now].end(),cmp);
		ll res=0;
		ll m=st[now].size();
		for(ll i=0;i<=m-1&&i<=3;i++)
		{
			res+=st[now][i];
		}
		return mp[fa][now]=res+1;
	}
	else
	{
		return mp[fa][now]=1;
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll x,y;
	for(ll i=1;i<=n-1;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
		du[x]++;
		v[y].push_back(x);
		du[y]++;
	}
	ll maxx=-1;
	for(ll i=1;i<=n;i++)
	{
		if(du[i]>=4)
		{
			maxx=max(maxx,dfs(0,i));
		}
	}
	cout<<maxx;
	return 0;
}``
»
58 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

For Problem F: My code is working on 1-39 testcases, and WA on 40-59, please find error...

Your code here...
void dfs(ll x, vector<bool>& vis,vector<set<ll>>& graph,ll& c)
{
    c++;
    vis[x]=true;
    for(ll i:graph[x])
    {
        if(!vis[i])
        {
            dfs(i,vis,graph,c);
        }
    }
}

void solve()
{
    ll n;
    cin>>n;
    vector<set<ll>> num(n+1);
    for(ll i=1; i<n; i++)
    {
        ll a,b;
        cin>>a>>b;
        num[a].insert(b);
        num[b].insert(a);
    }

    queue<ll> q;
    for(ll i=1; i<=n; i++) if(num[i].size()==1) q.push(i);

    ll ans=0;

    while(!q.empty())
    {
        ll x = q.front();
        q.pop();
        ll p = *num[x].begin();
        ll s = num[p].size();
        if(s==1)
        {
            num[x].erase(p);
            num[p].erase(x);
        }else if(s==2)
        {
            num[x].erase(p);
            num[p].erase(x);
            q.push(p);
        }else if(s==3)
        {
            num[x].erase(p);
            num[p].erase(x);
        }else if(s>4)
        {
            num[x].erase(p);
            num[p].erase(x);
        }
    }
    vector<bool> vis(n+1,false);
    for(ll i=1; i<=n; i++)
    {
        if(num[i].size()==0) continue;
        else
        {
            ll c=0;
            dfs(i,vis,num,c);
            cout<<c<<"\n";
            return;
        }
    } 
    cout <<"-1\n";

} 
»
55 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

Problems suddenly got considerably hard starting from E. I breezed through A~D in 20 minutes, and spent 60 minutes to solve E.

  • »
    »
    36 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    This is just the serious problem in ABC.

    For coders can only solve A~D, they should code very fast to get good ranks.

»
46 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

How to solve G? I figured that the optimal route will pass through a floor f such that when considering only buildings with heights >=f, the source and destination would belong to same connected component.

To find this value of f for each query, I thought I could do a binary search but then maintaining the UnionFind structure would take O(N) per query, which is too slow. Another approach I thought of was to solve offline by adding each building one-by-one in decreasing order but then needing to check all Q queries after each addition is again too slow.

  • »
    »
    41 minute(s) ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    consider small to large

  • »
    »
    33 minutes ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    You can construct a minimum spanning tree and then use binary lifting to find the minimal edge weight on the path between nodes.

    • »
      »
      »
      24 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I suppose the edge weights when constructing MST are simply the heights of building in each cell? Then I have a follow-up question:

      Let's say that there are two nodes A and B and minimum wt edge on the path A->B in MST is X. How do I know that there is not another path (not covered by the MST) that contains Y (>X) and also connect A and B? It's possible that going from source to dest using this Y edge would be cheaper, isn't it?

»
45 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

In ABC394 I played this match in the same room as CHI_LI I went to the toilet after making the E question He stole my code and made almost no changes Don't ban me I'm also a victim

  • »
    »
    35 minutes ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    My AtCoder's name is Huang_Barry.I'm Chinese,My English ability is not good.

  • »
    »
    30 minutes ago, # ^ |
      Vote: I like it +2 Vote: I do not like it

    I am CHI_li, I surrender myself and I admit to what 'HuangBarry' said. I am very sorry for this. Because I was on a whim, I shouldn't have plagiarized. After he came back and found out that I had plagiarized, he told me the rules, which would result in my account being banned. I was afraid that my teacher would..., I promise that I will never violate the rules in the future.

    • »
      »
      »
      19 minutes ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I implore the authorities not to block my account.

      I made the biggest mistake of my life, and I'm really scared.Really, I've never been so scared before.

      (I am also Chinese, and my English is not very good)

»
40 minutes ago, # |
  Vote: I like it 0 Vote: I do not like it

G is not good. Extremely straightforward idea, but pain in the ass to implement, not what I expect from atcoder contests. Rest of the problems were alright tbh.

»
21 minute(s) ago, # |
  Vote: I like it 0 Vote: I do not like it

Is there some easier to understand solution for E compared to the editorial ?