for every element I iterate over different value of omega and iterate over different gcd of element and form each gcd I iterate over different multiples of gcd ..why it didnot get tle ?? it passed in 1218 ms.
for every element I iterate over different value of omega and iterate over different gcd of element and form each gcd I iterate over different multiples of gcd ..why it didnot get tle ?? it passed in 1218 ms.
How many ways to draw non-crossing lines (chords) between any subset of n <= 1e6 points on a circle, such that:
1 - Lines do not cross each other.
2 - Multiple lines may share a common endpoint (i.e., chords can share points).
3 - Some points may remain unused
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)
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
How I can Find smallest Odd Prime factor of n n<=10^18
we have test cases 10^5
[D. Min Cost String](https://mirror.codeforces.com/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
hi..
how I can find the problems that based on grid and construct them, manipulate..
like these problems
1- G.(A/B Matrix)->https://mirror.codeforces.com/contest/1360/problem/G
2-D.(Grid-00100)->https://mirror.codeforces.com/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