結果
問題 |
No.3253 Banned Product
|
ユーザー |
|
提出日時 | 2025-09-05 22:45:36 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,578 bytes |
コンパイル時間 | 3,073 ms |
コンパイル使用メモリ | 274,960 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-09-05 22:45:40 |
合計ジャッジ時間 | 3,839 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 9 |
ソースコード
#include <bits/stdc++.h> #define int long long using namespace std; const int inf=1e18; signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n,m;cin>>n>>m; int ans=0; // vector<int>now,lst; // auto dfs=[&](auto dfs)->void { // if(now.size()==n){ // int xsum=0,sum=0;; // for(int i:now){ // xsum^=i; // sum+=i; // } // if(xsum==0&&sum>=ans)ans=max(ans,sum),lst=now;; // return; // } // else{ // for(int i=0;i<=m;i++){ // now.push_back(i); // dfs(dfs); // now.pop_back(); // } // } // }; // dfs(dfs); if(n%2==0){ cout<<n*m<<endl; }else{ if(n==1){ cout<<0<<endl; } else{ ans+=m*(n-2); int one=0,two=0; for(int i=40;i>=0;i--){ if(m&(1LL<<i)){ if(one<two){ one+=(1LL<<i); ans+=(1LL<<i); } else{ two+=(1LL<<i); ans+=(1LL<<i); } }else{ if(max(one,two)+(1LL<<i)<=m){ one+=(1LL<<i); two+=(1LL<<i); ans+=2*(1LL<<i); } } } cout<<ans<<endl; // cout<<one<<" "<<two<<endl; } } }