結果
問題 | No.1355 AND OR GAME |
ユーザー |
![]() |
提出日時 | 2021-01-17 15:53:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 942 bytes |
コンパイル時間 | 1,072 ms |
コンパイル使用メモリ | 84,088 KB |
最終ジャッジ日時 | 2025-01-18 01:25:10 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 MLE * 2 |
other | AC * 45 TLE * 25 MLE * 25 |
ソースコード
#include <iostream>#include <vector>#include <map>using namespace std;typedef long long ll;ll a[200010];vector<int> ans,p;map<ll,bool> dp[200010];void dfs(int i,int n,ll x, ll y){//cout << i << " " << n << " " << x << " " << y << " " << p.size() << endl;if(i>n || dp[i].find(x)!=dp[i].end()) return;dp[i][x] = true;if(p.size()==n && x==y){ans = p; return;}if(false){//p.push_back(1);//dfs(i,x);}else{p.push_back(1);dfs(i + 1,n,x&a[i],y);p.pop_back();p.push_back(2);dfs(i + 1,n,x|a[i],y);p.pop_back();p.push_back(3);dfs(i + 1,n,a[i],y);p.pop_back();}}int main(){ll i,j,n,x,y; cin >> n >> x >> y;for(i=0;i<n;i++) cin >> a[i];dfs(0,n,x,y);if(ans.size()==n){for(int x:ans) cout << x << " ";cout << endl;}else{cout << -1 << endl;}}