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

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

We will hold Panasonic Programming Contest 2024(AtCoder Beginner Contest 354).

We are looking forward to your participation!

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

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

Hope to ak!

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

Hope to solve ABCDE, and one of F and G!

And, GL&HF(Good Luck and Have Fun)!

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

Do you notice the problems can be read NOW???

UPD: i'm idiot, didn't notice the statements are not in this contest.

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

Hope to solve ABCD, and E/F

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

有中国人吗?

Is there Chinese?

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

swap D and E plz

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

Problem F is similar to a variation of Dijkstra (computing edges on at least one shortest path), for which I recently created a practice problem

I have also added hints for F on CF Step

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

D is created only to give pain and trauma :skull:

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

    It was a great educational problem imo as I struggled for quite some time before landing on a fairly elegant solution. It seemed like a mess at first, but ended up being solvable by repeating a function 8 times which I liked.

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

    I saw geometry and skipped it. Lol, Ended up solving both E and F.

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

Could someone please explain the approach behind problem E to me? I tried using a queue to simulate all possible moves keeping track of available cards but it doesn't seem to be working

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

D without cancer casework how?

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

Solved both C and F using segment Trees. All I see is segment trees now :<

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

Missed F by 2 min because D took all my time.

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

CAN SOMEONE TELL WHY IS THIS WRONG FOR E , IM FRUSTATED

include<bits/stdc++.h>

using namespace std;

define int long long int

define endl '\n'

void solve(){ int a,b,c,d; cin>>a>>b>>c>>d; double arr[2][4]; arr[1][0]=0.5; arr[1][1]=1; arr[1][2]=0.5; arr[1][3]=0; arr[0][0]=1; arr[0][1]=0.5;arr[0][2]=0; arr[0][3]=0.5;

double ans=0;
// cout<<(c-a)<<endl;
// cout<<(c-a)/4<<endl;
int x=(c-a)/4;
int y=(d-b)/2;

ans+=x*y*4;

// cout<<ans<<endl;

int xd=((c-a)%4+4)%4;
int yd=((d-b)%2+2)%2;

int stx=(4+a%4)%4;
int sty=(2+b%2)%2;

//portion 1
double pos1=0;
for(int i=stx;i<stx+xd;i++){
    pos1+=(arr[0][i%4]+arr[1][i%4]);
}
pos1*=y;

//portion 2

double pos2=0;
for(int i=sty;i<sty+yd;i++){
    pos2+=(arr[i%2][0]+arr[i%2][1]+arr[i%2][2]+arr[i%2][3]);
}
pos2*=x;

//portion 3
// cout<<stx<<" "<<sty<<" "<<xd<<" "<<yd<<endl; 
double pos3=0;
for(int i=sty;i<sty+yd;i++){
    for(int j=stx;j<stx+xd;j++){
        pos3+=arr[i%2][j%4];
    }
}

// cout<<ans<<" "<<pos1<<" "<<pos2<<" "<<pos3<<endl;

cout<<(int)(2*(ans+pos1+pos2+pos3))<<endl;

}

int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

//int t;cin>>t;while(t--)
solve();
return 0;

}

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

This is the first time I've paticipated in AtCoder contest. Could someone please say, what is the approximate difficulty of the contest by cf standards?

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

What is the idea behind G once the connection graph is built?

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

I spent soooooo much time on D!!!!!!!!!!! NOOOOOOOOOOO!!!!!!!!!! By the way, I think E is more difficult than F.So how do you guys solve E??

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

Oh! I've ranked 28! I'm so happy!

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

This time I solved problem F much faster than usual(maybe 15 minutes), because I have met a similar one, https://codeforces.me/contest/650/problem/D , during my virtual participation.

This makes me believe again that hard work will pay off sooner or later.

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

Can someone kindly breakdown G's solution for me?

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

My post contest discussion stream

Also, can someone hack my solution for G?
Gentle ping maroonrk because of this

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

I think problem D is not very good and I only solved ABCEF.

»
2 года назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
#include<bits/stdc++.h>
#define int long long
using namespace std;
struct zp
{
    int A,C,p;
};
bool cmp1(zp a,zp b)
{
    if(a.C<=b.C)return true;
    else return false;
}
bool cmp2(zp a,zp b)
{
    if(a.p<=b.p)return true;
    else return false;
}
vector<zp> a;
signed main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int a1,a2;
        cin>>a1>>a2;
        a.push_back({a1,a2,i+1});
    }
    sort(a.begin(),a.end(),cmp1);
    int x=0;
    for(int i=0;i<n-1;i++)
    {
        if(a[i].A>a[i+1].A)
        {
            a[i+1]=a[i];
            a[i].p=-1;
            x++;
        }
    }
    cout<<n-x<<"\n";
    sort(a.begin(),a.end(),cmp2);
    for(int i=0;i<n;i++)
    {
        if(a[i].p!=-1)cout<<a[i].p<<" ";
    }
    return 0;
}

why Re

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

F is similar to https://www.spoj.com/problems/SUPPER/

Even the example is the same.

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

how to solve bonus problem mentioned in F?

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

    SummerSky mentioned the idea in his comment

    There are 2 methods.

    • Calculate the number of LIS ending at $$$i$$$, call it $$$end[i]$$$. Calculate the number of LIS starting at $$$i$$$, call it $$$start[i]$$$. The number of LIS crossing the $$$i-th$$$ element is $$$start[i] \cdot end[i]$$$. If this number is equal to the number of LIS of the entire array, then this index will be included in all LIS. Counts can be exponential, so you can compute it modulo some prime and hope for no collisions.
    • If the length of LIS ending at $$$i$$$ is $$$L$$$, then we know that $$$i-th$$$ element would go into position $$$L$$$ of the final LIS (assuming that it's part of at least one LIS). We can iterate over every index and check if there are other elements that are contesting for position $$$L$$$. If not, then this element will be part of every LIS.
»
2 года назад, скрыть # |
← Rev. 4  
Проголосовать: нравится 0 Проголосовать: не нравится

upd: E not use bitset, it can also AC. I can understand why so many people AC E now.

So many people solve E in the competition. I doubt if some of them using chatgpt. I get AC of problem E using code generated by chatgpt 4o. The code is as follows.

#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

struct Card {
    int front;
    int back;
};

int N;
vector<Card> cards;
unordered_map<int, bool> memo;

bool canWin(int state) {
    if (memo.count(state)) return memo[state];

    // Check all pairs of cards
    for (int i = 0; i < N; ++i) {
        if (!(state & (1 << i))) continue; // Card i is already removed
        for (int j = i + 1; j < N; ++j) {
            if (!(state & (1 << j))) continue; // Card j is already removed
            if (cards[i].front == cards[j].front || cards[i].back == cards[j].back) {
                int newState = state & ~(1 << i) & ~(1 << j);
                if (!canWin(newState)) {
                    memo[state] = true;
                    return true;
                }
            }
        }
    }
    memo[state] = false;
    return false;
}

int main() {
    cin >> N;
    cards.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> cards[i].front >> cards[i].back;
    }

    int initialState = (1 << N) - 1; // All cards are initially on the table
    if (canWin(initialState)) {
        cout << "Takahashi" << endl;
    } else {
        cout << "Aoki" << endl;
    }

    return 0;
}

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

I think F needn't to use Segment Tree, Fenwick is okay. It only needs prefix maxminum.

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

Can anyone please help me with E problem This is my submission I am not able to understand my mistake https://atcoder.jp/contests/abc354/submissions/55748268

Thank you