This is my solution: Solution(Not visible) Check my code below
For question : Question
It is giving TLE on Test 3.
My code
My solution is in O(t.log(p)).
# | User | Rating |
---|---|---|
1 | ecnerwala | 3649 |
2 | Benq | 3581 |
3 | jiangly | 3578 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | tourist | 3565 |
8 | maroonrk | 3531 |
9 | Radewoosh | 3521 |
10 | Um_nik | 3482 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 161 |
4 | TheScrasse | 159 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 152 |
8 | SecondThread | 146 |
8 | orz | 146 |
10 | pajenegod | 145 |
This is my solution: Solution(Not visible) Check my code below
For question : Question
It is giving TLE on Test 3.
void solve(){
int k,i, j, q, x, y;
int h, p;
cin >> h >> p;
auto MS = [&] (int n){
int i = 0;
while(n){
i++;
n >>= 1;
}
i--;
return i;
};
int ms = MS(p)+1;
if(h <= ms){
print(h);
} else{
int ans = ms+((1<< h)-1 - ((1<<ms)-1)+p-1)/p;
print(ans);
}
}
My solution is in O(t.log(p)).
Name |
---|
you solution can't open to other people so can you write your code in spoiler to check it?
Added my code. Thanks in advance
add this line (ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);) to your code and see the result it will fast your input
cout.tie(0) does nothing
i just add the previous line and it give wrong answer instead of TLE
because of ios::sync_with_stdio(false) and cin.tie(0) they actually make ur program faster but cout.tie(0) is useless
upd: thx to -is-this-fft- https://codeforces.com/blog/entry/90775?#comment-791764
What have you written in "int ans="?
That's not my code. That's why you getting WA.
What is mdash?
I have already done that