| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3611 |
| 4 | jiangly | 3583 |
| 5 | strapple | 3515 |
| 6 | tourist | 3470 |
| 7 | Radewoosh | 3415 |
| 8 | Um_nik | 3376 |
| 9 | maroonrk | 3361 |
| 10 | XVIII | 3345 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 162 |
| 2 | adamant | 148 |
| 3 | Um_nik | 146 |
| 4 | Dominater069 | 143 |
| 5 | errorgorn | 141 |
| 6 | cry | 138 |
| 7 | Proof_by_QED | 136 |
| 8 | YuukiS | 135 |
| 9 | chromate00 | 134 |
| 10 | soullless | 133 |
|
0
Just try out a few cases , you will realize your mistake |
|
0
bro we need to find maximum absolute path sum |
|
0
Actually it is an interview problem so no link available. |
|
0
Auto comment: topic has been updated by --n-- (previous revision, new revision, compare). |
|
0
is there any such relation for more than 2 numbers? |
|
0
What is the logic behind it? |
|
0
someone please explain problem C |
|
-37
include <bits/stdc++.h>using namespace std; define ll long longint main() { ll n,m,ans=0; cin>>n>>m; ll A[n],B[m], dp[n][m]; for(int i=0;i<n;i++){ cin>>A[i]; } for(int i=0;i<m;i++){ cin>>B[i]; } ll smallest = 10000000000000; ll maxi = 0; for(int i=0;i<n;i++){ smallest = 10000000000000; for(int j=0;j<m;j++){ if( smallest > (A[i]&B[j]) ) smallest = (A[i]&B[j]); dp[i][j] = (A[i]&B[j]); } maxi = max(maxi,smallest); } ans = maxi; for(int i=0;i<n;i++){ smallest = 10000000000000; for(int j=0;j<m;j++){ if(smallest > (ans|dp[i][j]) ) smallest = (ans|dp[i][j]); } ans = smallest; } cout<<ans<<endl; return 0; } Someone please explain the complete logic of the above program. I saw same thing in many accepted codes. |
|
0
Which test case? |
|
0
How can you say that answer will be atleast mx? |
|
-8
int main() { ios_base :: sync_with_stdio(false); cin.tie(NULL); auto startTime = curTime(); int n,m;
cin>>n>>m;
vi a(n);
vi b(m);
rep(i,n) cin>>a[i];
rep(i,m) cin>>b[i];
ll mx=0;
rep(i,n)
{
ll mn = inf;
rep(j,m)
{
mn = min(mn, a[i]&b[j]);
}
mx = max(mx,mn);
}
ll ans=0;
rep(i,n)
{
ll mn = inf;
rep(j,m)
{
mn = min(mn, mx|(a[i]&b[j]));
}
mx=mn;
ans = max(ans,mn);
}
cout<<ans<<endl;Can anyone explain the logic of this solution? I saw same thing in many accepted solutions. |
| Name |
|---|


