Boshkash_Hates_CP's blog

By Boshkash_Hates_CP, 25 hours ago, In English

Hello codeforces ,

i'm brand new to dfs and i have spend like 4 hours trying to find a solution for The Tag Game problem.

what i have tried:

bob wants to maxmizes the solution , alice wants to minimize , so bob need to reach the deepest node , when bob reaches it alice will move to catch him , but bob has the choice to stay in the node (each of them has that option but i guess only bob will use it) i can't handle this choice of staying as a move, this is my code:


const int N_=10e5+6,M=2*10e5+6; const int NOT_VISITED = 0 , IN_PROGRESS = 1 , VISITED = 2; int m,n,u,v; vector<int> adj[N_]; vector<pair<int,int>> dxdy = {{-1,0},{1,0},{0,1},{0,-1}}; // vector<vector<bool>> vis; bool vis[N_]; int c; // bool isValid(int x , int y , vector<STR>&grid){ // if(x < 0 || x > n-1 || y <0 || y>m-1) return false; // if(vis[x][y] || grid[x][y] == '#') return false; // return true; // } int md = 0 , fn=0; void dfs(int u,int depth){ vis[u] =true; if(depth > md){ md = depth; fn = u; } c++; for(auto x : adj[u]){ if(!vis[x]){ dfs(x,depth+1); } } } void solve() { cin >> n>>m; for(int x = 0 ;x < n-1 ; x++){ cin >>u >>v; adj[u].push_back(v); adj[v].push_back(u); } dfs(m,0); int ans = md; memset(vis,false,sizeof(vis)); md=0; c=0; dfs(1,0); c-=2; cout << ans+c+md; }

Full text and comments »

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

By Boshkash_Hates_CP, history, 5 weeks ago, In English

Hello CF , First thing first , happy new year , May this year bring you health , happiness and successes in all you do !

i have struggled to understand Palindrome Pairs solution "in terms of bitmasks" , as i'm newbie.

i didn't thought about the iterative solution as it will be o(n^2) which will case TLE ,so i was trying to get a better solution and i wasn't able to , so i saw the solution which is something like this:

int main()
{
   FastIO;
   ll n ;cin >>n;
   map<ll,ll> mp;
   ll ans = 0;
   while(n--)
   {
      STR s;cin>>s;
      ll m = 0;
      for(auto x : s)
      {
         ll v = x-'a';
         m ^= (1 << v);
      }
      ans += mp[m];
      for(int x = 0 ; x < 26 ; x++)
      {
         m ^= (1 << x);
         ans += mp[m];
         m ^= (1 << x);
      }
      mp[m]++;
   }
   cout << ans;
}

i don't get it , i mean i know to check if a string is a Palindrome or not we get it's mask and check it's power of 2 or not by XOR'ing the values of each char ....help

Full text and comments »

By Boshkash_Hates_CP, history, 2 months ago, In English

Hello codeforces, as i have learned a new datastructure , i would like to solve some problems on it , so suggest some problems i can solve on binary search trees.

Full text and comments »

By Boshkash_Hates_CP, history, 3 months ago, In English

Hello , Recently i was trying to solve this problem 932B which was kinda tricky as it requires prefix sum to avoid TLE , it required 2d-prefix sum , so what's that and why i could need it , suggest some problems to get familiar with it.

Full text and comments »

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

By Boshkash_Hates_CP, history, 3 months ago, In English

Hello , suggest any problem (or set of problems) that can be solved using recursion and it's grid based , problems like go from s to e , or find the shortest path .... etc

Full text and comments »

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

By Boshkash_Hates_CP, history, 3 months ago, In English

Hello codeforces , a few days ago i started learning more about recursion , and i indeed tried to solve some very basic problems on it , however , when it comes to tricky problems i cannot think how to implement a recursive function to solve the problem , another thing makes me wondring is when should i implement a recursive function and when i use the iterative function, so if anyone has some ideas about the previous questions , write it below.

thanks.

Full text and comments »

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

By Boshkash_Hates_CP, history, 3 months ago, In English

Hello , when solving problems on binary search, i solve them because i know that i'm solving problems on Binary search topic , but if i come to a problem statement i don't know how or even if I should use binary search or not ... so my question is , how to make sure you're solving a binary search problem?

Full text and comments »

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

By Boshkash_Hates_CP, history, 4 months ago, In English

Hello codeforces , i just have learned the backtracking technique , i want to practice and put my hands on , i want some biggener freindly problems

Full text and comments »

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

By Boshkash_Hates_CP, history, 4 months ago, In English

Hello , Could some one please suggest a set of problems i can solve to put my hands on the "Coordinates Compression" technique ?

Full text and comments »

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