mainnahihoo's blog

By mainnahihoo, history, 3 months ago, In English

why the recent rounds have too much acceptance ration like see yesterday 1076 div 3

again see this div 2 1075

see again 1073 div 2

i don't know the valid reason but seeing that much correct submission make me to post this

Full text and comments »

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

By mainnahihoo, history, 7 months ago, In English

Problem is Link

what my approach is -> i had written a brute force recurion simply trying all possible results i can make and storing the results in pair at the end i can see what the max score achieved by 1st person and the 2nd person

problem is getting wrong answer in large test case i am not able to debug after this .

please helppppppppppppppp

pair<int,int> mpl[2500][2500][2];
int x=0;
pair<int,int> rec(int l,int r,int flag,vector<int>&vec){
    if(l>r) {
        // cout<<"!!!!!!!!!!!!!"<<endl;
        return {0,0};
    }
    if(mpl[l][r][flag].first!=-1 && mpl[l][r][flag].second!=-1) return mpl[l][r][flag];
    x++;
    // cout<<"call for "<<l<<" "<<r<<" "<<flag<<endl;
    pair<int,int> ans={0,0};
    pair<int,int>left,right;
     if(flag){
        pair<int,int> left=rec(l+1,r,!flag,vec);
        pair<int,int> right=rec(l,r-1,!flag,vec);
        left.first+=vec[l];
        right.first+=vec[r];
        ans = (left.first > right.first) ? left : right;
    }
    else{ 
        pair<int,int> left=rec(l+1,r,!flag,vec);
        pair<int,int> right=rec(l,r-1,!flag,vec);
        left.second+=vec[l];
        right.second+=vec[r];
        ans = (left.second > right.second) ? left : right;
    }
    mpl[l][r][flag]=ans;
    return mpl[l][r][flag];
}
void solve() {
    // executing code from here 
    int t=1;
    while (t--) {
        int n;
        cin >> n;
        vi vec(n);
        for (int i = 0; i < n; i++) cin >> vec[i];
        // cout<<a.first<<" "<<a.second<<endl;
        // dbg(x);
        for(int i=0;i<2500;i++){
            for(int j=0;j<2500;j++){
                for(int k=0;k<2;k++){
                    mpl[i][j][k]={-1,-1};
                }
            }
        }
        pair<int,int>a=rec(0,n-1,1,vec);
        cout<<a.first<<endl;
    }
}

Full text and comments »

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

By mainnahihoo, history, 7 months ago, In English

this problem is minimal task Link can be solved by dp, i am using bfs or djikstra u can say , so i made a priority_queue and when first time when my string will be having the size of 2*n-1 means i had reached to end so this will be the answer lexicographically

see the code i am getting TLE no wrong answer i think worst complexity will be O(N^2) ,Please help


struct cmp { bool operator()(const pair<pair<int,int>,string> &x, const pair<pair<int,int>,string> &y) const { return x.second > y.second ; } }; int check(int i,int j,int n){ return i>=0 && j>=0 && i<n && j<n; } string ans; vector<pair<int,int>>dir={{1,0},{0,1}}; string bfs(int i,int j,vector<vector<char>>&vec,vector<vector<int>>&vis,int n){ priority_queue<pair<pair<int,int>,string>,vector<pair<pair<int,int>,string>>,cmp>pq; string s; s+=vec[i][j]; pq.push({{i,j},s}); while(!pq.empty()){ auto it=pq.top();pq.pop(); string temp=it.second; if(it.second.size()==(n*2 - 1)){ return it.second; } for(auto &i:dir){ int new_x=it.first.first+i.first; int new_y=it.first.second+i.second; if(check(new_x,new_y,n) && vis[new_x][new_y]==-1){ vis[new_x][new_y]=1; pq.push({{new_x,new_y},temp+vec[new_x][new_y]}); } } } } void solve() { // executing code from here int t=1; while (t--) { int n; cin >> n; vector<vector<char>> vec(n,vector<char>(n,'.')); vector<vector<int>> vis(n,vector<int>(n,-1)); for (int i = 0; i < n; i++){ for(int j=0;j<n;j++){ cin>>vec[i][j]; } } cout<<bfs(0,0,vec,vis,n)<<endl; } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); // sieve(); solve(); return 0; }

Full text and comments »

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

By mainnahihoo, history, 9 months ago, In English

problem atcoder problem

int dp[(1<<20)];
// int cnt=0;
int rec(int mask,string &s,int n){
	// cout<<"call for "<<mask<<endl;
	if(mask==(1<<n)-1)return 1;
	if(dp[mask]!=-1)return dp[mask];
	int x=0;
	for(int i=0;i<n;i++){
		if(!(mask&(1<<i)) && s[mask|(1<<i)]=='0'){
			x|=rec(mask|(1<<i),s,n);
		}
	}
	// cnt++;
	return dp[mask]=x;
}

void solve() {
	// executing code from here 
	int t;
	cin >> t;
	while (t--) {
		int n;cin >> n;string s;cin>>s;
		memset(dp,-1,sizeof(dp));
		s='0'+s;
		if(rec(0,s,n))cy;
		else cn;
	}
}

I am getting TLE why after dp time complexity should be 2^n*n not n!*n

Full text and comments »

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

By mainnahihoo, history, 10 months ago, In English

this is kind of suggestion when ever some body get skipped solution make it's rating -x where x is the current rating of the user then i think the cheating rate will get down , upvote if you like and else downvote

Full text and comments »

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

By mainnahihoo, history, 12 months ago, In English

Hello respected coders , please tell me approach to solve this at coder question LOGICAL FILLING firstly i was thinking that this question was dp but atleast we need two states for dp and that will be a TLE , how to approach this please help , and 4th question of atcoder is a barrier for me how to cross that .

HELP

Full text and comments »

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

By mainnahihoo, history, 13 months ago, In English

Like in this days i was observing that the div 2 b question language they are making harder that is irrelevant , like see this question 2078B - Vicious Labyrinth and this one also 2075C - Two Colors , like in both question i was not able to know the question propelry how i can get to the correct approach please tell like in this question 2078B - Vicious Labyrinth , there is no mention of how the neighbour is spreading so everybody thinks like just take the max of sum of k+1 element , please reply don't judge me based on my rating please , and sorry for poor english

Full text and comments »

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

By mainnahihoo, history, 13 months ago, In English

in recent contest div 2 that was yesterday 1008 round i was not able to solve single one question i don;t know what was going wrong i had solved 400 problem on codechef please help help

Full text and comments »

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

By mainnahihoo, history, 14 months ago, In English

I think instead of talkig about these cheaters we should try to help codeforces team to make a system no cheat code get accepeted and no ai code get accepted , I think making ML model in this will really helps but the issue is it's accuracy is so high

Full text and comments »

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

By mainnahihoo, history, 14 months ago, In English

Hello, Competitive Programmers!

I've been practicing on Codeforces for a while now, but I feel like my rating is stuck. I'm reaching out to all the young and talented coders here—how do you approach problem-solving to improve your rating consistently?

I would love to hear your insights on:

Training Strategies: How do you practice? Do you follow a schedule or focus on particular topics?

Problem Selection: Do you solve problems based on difficulty, rating, or specific tags?

Contests: How do you prepare for contests, and what is your mindset during live contests?

Resources: What books, websites, or tutorials helped you the most?

Debugging and Learning from Mistakes: How do you analyze and learn from your wrong submissions?

Mental Approach: How do you stay motivated and avoid frustration when stuck at a certain rating?

I’d appreciate any tips, personal experiences, or advice you can share! Let’s help each other grow in competitive programming.

Looking forward to your responses!

Happy Coding!

Full text and comments »

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