mostafaabdelaal_03's blog

By mostafaabdelaal_03, history, 8 months ago, In English
int n;
vector<int>p, v;
int get(int a){
    return p[a] = (a==p[a]) ? a : get(p[a]);   
}
void unin(int a, int b){
    a = get(a);
    b = get(b);
    p[a] = b;
}
I implemented  this code when I was solving problems about Dsu in section Edu..now if I used path compression in get function but I donot Consider the samllest set and larget set in union ..can the comlexity reach O(N)

Full text and comments »

By mostafaabdelaal_03, history, 9 months ago, In English
I get The idea of Problem D Today But I was getting WA and I did not know where is the wrong.. After the contest I discovered that my map donot do sorting to vector of string in it ...
why ???
map<char, vector<string>>mp;
for(auto i:mp){
    sort(i.second.begin(), i.second.end());
}

this is the test that my friend give me after contest:

1

1

D

9H 4H

Full text and comments »

By mostafaabdelaal_03, history, 17 months ago, In English

How I can Find smallest Odd Prime factor of n n<=10^18

we have test cases 10^5

Full text and comments »

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

By mostafaabdelaal_03, history, 2 years ago, In English
[D. Min Cost String](https://codeforces.me/contest/1511/problem/D)
I have an intutive approach but I want to know why he work??I want proof??
suppose we will use the first 5 character..
first: we will put the the characters at even position like that:
`a_b_c_d_e_a_b_c_d_e_a_b_c_d_e`
the the first k chars at even positions we will shift them by 1
and put  the shifted chars at odd positions like that 
`a_b_c_d_e`
`_b_c_d_e_a`
`abbccddeea`
the second k chars at even positions we will shift them by 2
and put  the shifted chars at odd positions like that 
`a_b_c_d_e`
`_c_d_e_a_b`
`acbdcedaeb`
you can say that the char at odd position j is equal to the char at position (j-1) plus number of shifts like s[j]=(s[j-1]+sh)%k;
sorry for my bad english...can someone prove it??

here's my submision

Full text and comments »

By mostafaabdelaal_03, history, 2 years ago, In English
hi..
how I can find the problems that based on grid and construct them, manipulate..
like these problems 
1- G.(A/B Matrix)->https://codeforces.me/contest/1360/problem/G
2-D.(Grid-00100)->https://codeforces.me/problemset/problem/1371/D
I solved them and I got AC..but I want more and more ..I cannot find it in tags of codeforces..
sorry for my bad English

Full text and comments »

By mostafaabdelaal_03, history, 4 years ago, In English