atcoder_official's blog

By atcoder_official, history, 13 months ago, In English

We will hold UNIQUE VISION Programming Contest 2025 Spring (AtCoder Beginner Contest 398).

We are looking forward to your participation!

  • Vote: I like it
  • -27
  • Vote: I do not like it

| Write comment?
»
13 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

why is kenkoooo not working these days?

»
13 months ago, hide # |
 
Vote: I like it +7 Vote: I do not like it

Recent ABC contests are pretty good. Wish another fascinating ABC tonight!

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it +5 Vote: I do not like it

    Oh, this is a speed round.

    More than 1000 people passed A~F.

    Only 6 people passed G.

    I feel speechless about this situation.

    Have a good dream, everybody.

»
13 months ago, hide # |
 
Vote: I like it +4 Vote: I do not like it

The special effect when clicking the left mouse button is quite interesting.

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +37 Vote: I do not like it

Hello AtCoder,

Please stop blocking kenkoooo thanks. Or please add pages like My Submissions or Friends' Submissions on AtCoder. Thank you!

»
13 months ago, hide # |
 
Vote: I like it -6 Vote: I do not like it

F is too standard.

»
13 months ago, hide # |
 
Vote: I like it +14 Vote: I do not like it

what happened to kenkooo? It has been freezing for over a week.

»
13 months ago, hide # |
 
Vote: I like it -21 Vote: I do not like it

D is too hard for me

»
13 months ago, hide # |
 
Vote: I like it +1 Vote: I do not like it
»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

why was tle in c ? this code is n log n , is not ?


#include <bits/stdc++.h> using namespace std; #define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); typedef long long ll; void solve(){ FAST_IO ll n; cin >> n; vector<ll> a(n); multiset<ll> ms; for(ll i = 0; i < n; i++){ cin >> a[i]; ms.insert(a[i]); } bool c = true; vector<pair<ll,ll>> aux; for(ll i = 0; i < n; i++){ if(ms.count(a[i]) == 1){ aux.push_back({a[i],i+1}); c = false; } } if(c){ cout << -1 << endl; return; } ll ans = -1; ll comp = -1; for(ll i = 0; i < aux.size(); i++){ if(aux[i].first > comp){ comp = aux[i].first; ans = aux[i].second; } } cout << ans << endl; return; } int main(){ solve(); }
  • »
    »
    13 months ago, hide # ^ |
    Rev. 2  
    Vote: I like it +1 Vote: I do not like it
    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      the map is lg n too, why is better ? i am confusing

      • »
        »
        »
        »
        13 months ago, hide # ^ |
        Rev. 2  
        Vote: I like it 0 Vote: I do not like it

        Because in fact I uesd unordered_map(https://en.cppreference.com/w/cpp/container/unordered_map),it's just like a hash table.

        There're some features of it:

        std::unordered_map is an associative container that contains key-value pairs with unique keys. Search, insertion, and removal of elements have average constant-time complexity.

        Internally, the elements are not sorted in any particular order, but organized into buckets. Which bucket an element is placed into depends entirely on the hash of its key. Keys with the same hash code appear in the same bucket. This allows fast access to individual elements, since once the hash is computed, it refers to the bucket containing the element.

        • »
          »
          »
          »
          »
          13 months ago, hide # ^ |
           
          Vote: I like it 0 Vote: I do not like it

          i tried and i do this code, is that ?


          #include <bits/stdc++.h> using namespace std; #define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); typedef long long ll; #define f first #define s second void solve(){ FAST_IO ll n; cin >> n; vector<ll> a(n); unordered_map<ll,ll> freq; unordered_map<ll,ll> pos; for(ll i = 0; i < n; i++){ cin >> a[i]; freq[a[i]]++; pos[a[i]] = i + 1; } ll max_value = -1, max_pos = -1; //freq valor,vezes q ele aparece //pos : valor, posicao maior; for(auto b : freq){ if(b.s == 1 && b.f > max_value){ max_value = b.f; max_pos = pos[max_value]; } } cout << max_pos << endl; } int main(){ solve(); }
  • »
    »
    13 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it 0 Vote: I do not like it

    You are wrong. You get TLE is only because count(x) of multiset is $$$O(\log n+K)$$$, Where $$$K$$$ is the number of times the element $$$x$$$ appears in the 'multiset'. If all of the elements in the multiset has the same value, you will get TLE because now the function count of multiset is $$$O(n)$$$.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What a shit contest it is!

problem F is so shit!

»
13 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

For problem C,

#include <bits/stdc++.h>

using namespace std;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int inp, flag=0;
  vector <pair<int, int>> vp;
  for(int i=0; i<n; i++){
    cin >> inp;
    vp.push_back(make_pair(inp, i+1));
  }
  if(n == 1){
    cout << "1\n";
  } else {
    sort(vp.begin(), vp.end());
    for(int i=n-1; i>0; i--){
      if(vp[i-1].first != vp[i].first){
	cout << vp[i].second << "\n";
	flag =1;
	break;
      } else {
	while(vp[i-1].first == vp[i].first || i == 1){
	  i--;
	}
      }
    }
    if(flag==0){
      cout << "-1\n";
    }
  }
}

I can't figure out how this is failing?

»
13 months ago, hide # |
 
Vote: I like it +6 Vote: I do not like it

Absolutely terrible contest.

»
13 months ago, hide # |
Rev. 3  
Vote: I like it +5 Vote: I do not like it

F has no "takahash" substring.(Takahashi, same pronunciation with 它卡哈希 in Chinese which means the problem can't solve by hashing.) So it can be solved easily by hashing :) LOL

More, G is too hard for rated participant :(

  • »
    »
    13 months ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    Sorry, but can anybody explain why I can solve F with a weak hashing. I choosed 10 to be the P in my code which should be an odd number instead of even number 10.

    My F submission

    • »
      »
      »
      13 months ago, hide # ^ |
       
      Vote: I like it 0 Vote: I do not like it

      Well, I choose 35 to be the P, and I also solved it.

      • »
        »
        »
        »
        13 months ago, hide # ^ |
         
        Vote: I like it 0 Vote: I do not like it

        Odd numbers are hard to be hacked, but even ones can be hack, so I was surprised that I got AC.

        Can anyone prove that my solution is hard to be hacked?

»
13 months ago, hide # |
 
Vote: I like it +31 Vote: I do not like it

problem G is well known in India

»
13 months ago, hide # |
Rev. 2  
Vote: I like it +4 Vote: I do not like it

Was it just me who found the statement and samples for C contradicting (somehow or I am just dumb). (I eventually guessed it from samples).

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

What was the answer to problem G

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Louissun used AI in the competition.

»
13 months ago, hide # |
 
Vote: I like it +13 Vote: I do not like it

Problem G is a harder version of Canada MO 2019/5.

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I used Manacher algorithm to solve problem F, and I found it in the Japanese version of editorial. In fact, I just learned this algorithm from Codeforces Round 524 (Div. 2) E. Sonya and Matrix Beauty, maybe several months ago.

This really feels good, and makes me believe that everyone would always benefit from your practice sooner or later :D

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

For the number of connected components where the number of vertices in both parts are both oddeditorial has oeinstead of oo

»
13 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

E is disturbing for such a strict output format.

»
12 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Who can help me with problem E?

#include<bits/stdc++.h>
using namespace std;
int n,cnt1,cnt2,A[105],B[105],ft[105];
vector<int> zi[105];
set<pair<int,int> > s;
void dfs(int u,int fa,int s){
	ft[u]=fa;
	if(s)
		A[++cnt1]=u;
	else
		B[++cnt2]=u;
	for(int i=0;i<zi[u].size();i++){
		int v=zi[u][i];
		if(v==fa)
			continue;
		dfs(v,u,s^1);
	}
}
void solve(){
	while(1){
		set<pair<int,int> >::iterator it=s.begin();
		cout<<(*it).first<<" "<<(*it).second<<endl;
		s.erase(it);
		int u,v;
		cin>>u>>v;
		pair<int,int> p1={u,v},p2={v,u};
		if(u==-1)
			break; 
		set<pair<int,int> >::iterator it1,it2;
		it1=s.find(p1),it2=s.find(p2);
		if(it1==s.end())
			s.erase(it2);
		else
			s.erase(it1);
	}
}
int main(){
	cin>>n;
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		zi[u].push_back(v);
		zi[v].push_back(u);
	}
	dfs(1,0,1);
	int sum=cnt1*cnt2-n+1;
	for(int i=1;i<=cnt1;i++)
		for(int j=1;j<=cnt2;j++){
			int u=A[i],v=B[j];
			if(ft[u]==v||ft[v]==u)
				continue;
			s.insert(make_pair(u,v));
		}
	if(sum%2){
		cout<<"First"<<endl;
		solve();
	}
	else{
		cout<<"Second"<<endl;
		int u,v;
		cin>>u>>v;
		if(u==-1)
			return 0;
		pair<int,int> p1={u,v},p2={v,u};
		set<pair<int,int> >::iterator it1,it2;
		it1=s.find(p1),it2=s.find(p2);
		if(it1==s.end())
			s.erase(it2);
		else
			s.erase(it1);
		solve(); 
	}
	return 0;
}

Thanks!