(Subscribe for more such videos) Code : #include using namespace std; #define ll long long int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
@@haste291 😄aree bhai idhar push_back ho rha hai , vector in c++ ka property hai push_back karne se element attach ho jata hai last mein vector k. Tum ek bar vector in c++ ka video dekh lo samajh jawoge.
hey can you explain what's wrong with my code, it gives WA at some hidden test case #include using namespace std; #define int long long #define pairs pair #define vll vector #define vps vector #define ip(arr) for(int i = 0; i < arr.size(); i++) cin >> arr[i]; #define op(arr) for(int i = 0; i < arr.size(); i++) { cout k; vll curr; while(k--){ int temp; cin>>temp; curr.push_back(temp); } arr.push_back(curr); } bool ans1 = solve(arr); reverse(all(arr)); bool ans2 = solve(arr); bool ans = ans1||ans2; cout
If I consider all n elements , then after remaining 1 element, the chances of OR value remaining same is more. Eg : if n = 10, so in one subsequence I take all 10 elements and in another I take 5 elements. Now, I remove one same element from both subsequence. Now, chances of subsequence having 9 elements and OR value same is more then subsequence having 4 elements. There are 5 more elements in bigger subsequence to fulfill the requirement of the set bits of the element which is removed. I hope you got my point.
I Have applied the same logic but it gives TLE On Test 5 .Here is the code : #include using namespace std; #define ll long long int const int N = 2e5+10; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif int t;cin>>t; while(t--){ int arr[N]; memset(arr,0,sizeof(arr)); arr[0] = 1; ll q ;cin>>q; ll qq = q; int ff =0; vectorbits[q]; for(ll j= 0;j>n; for(ll i = 0;i>y; bits[j].push_back(y); arr[y]++; }
@@siddhantnigam2015 Hare Krishna PrabhuJi. It gives TLE because memset(arr) is done by running a loop of 10^5 . so doing it again and again for each test case will give TLE
(Subscribe for more such videos)
Code :
#include
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t, f, i, j, n, p;
string ans;
cin>>t;
for(;t--;)
{
cin>>n;
unordered_map mp;
ll k[n];
vector bits[n];
for(i=0; i>k[i];
for(j=0; j>p;
if(mp.find(p)==mp.end()){
mp[p]=1;
}else{
mp[p]++;
}
bits[i].push_back(p);
}
}
ans="NO";
for(i=0; i
sir how to store whole bits in one index
in this line bits[i].push_back(p);
@@haste291 😄aree bhai idhar push_back ho rha hai , vector in c++ ka property hai push_back karne se element attach ho jata hai last mein vector k. Tum ek bar vector in c++ ka video dekh lo samajh jawoge.
Thanks for the amazing explanation .You are doing a great work
hey can you explain what's wrong with my code, it gives WA at some hidden test case
#include
using namespace std;
#define int long long
#define pairs pair
#define vll vector
#define vps vector
#define ip(arr) for(int i = 0; i < arr.size(); i++) cin >> arr[i];
#define op(arr) for(int i = 0; i < arr.size(); i++) { cout k;
vll curr;
while(k--){
int temp;
cin>>temp;
curr.push_back(temp);
}
arr.push_back(curr);
}
bool ans1 = solve(arr);
reverse(all(arr));
bool ans2 = solve(arr);
bool ans = ans1||ans2;
cout
Great Explanation sir
Great Explanation sir.
Any specific reason for taking the subsequence of size n(the total numbers) and not k(
If I consider all n elements , then after remaining 1 element, the chances of OR value remaining same is more. Eg : if n = 10, so in one subsequence I take all 10 elements and in another I take 5 elements. Now, I remove one same element from both subsequence. Now, chances of subsequence having 9 elements and OR value same is more then subsequence having 4 elements. There are 5 more elements in bigger subsequence to fulfill the requirement of the set bits of the element which is removed.
I hope you got my point.
nice explanation!!
thank you so much
Thank you! 😊🙏🏻
Sir apni codeforces id bataiye !
sir aap please koi example leke samjha diya kariye.
aise jyada nahi samajh aata.
+1
I Have applied the same logic but it gives TLE On Test 5 .Here is the code :
#include
using namespace std;
#define ll long long int
const int N = 2e5+10;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int t;cin>>t;
while(t--){
int arr[N];
memset(arr,0,sizeof(arr));
arr[0] = 1;
ll q ;cin>>q;
ll qq = q;
int ff =0;
vectorbits[q];
for(ll j= 0;j>n;
for(ll i = 0;i>y;
bits[j].push_back(y);
arr[y]++;
}
}
for(vectorx:bits){
int f = 1;
for(ll i= 0;i
Use unordered map instead of arr....
@@codingcommunitynewtonschoo8582 Yes is got accepted by using map. Thanku PrabhuJi for replying 🙏🌸
@@codingcommunitynewtonschoo8582 why does it give TLE?
@@siddhantnigam2015 Hare Krishna PrabhuJi. It gives TLE because memset(arr) is done by running a loop of 10^5 . so doing it again and again for each test case will give TLE