結果
問題 | No.2071 Shift and OR |
ユーザー | 👑 Nachia |
提出日時 | 2022-09-16 22:51:00 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 967 bytes |
コンパイル時間 | 724 ms |
コンパイル使用メモリ | 83,408 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-21 22:12:42 |
合計ジャッジ時間 | 2,420 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <bitset> #include <atcoder/modint> using namespace std; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; #define rep(i,n) for(int i=0; i<(int)(n); i++) using Modint = atcoder::static_modint<998244353>; int main(){ int N; cin >> N; if(N >= 16){ cout << ((1<<16)-1) << '\n'; return 0; } vector<int> A(N); rep(i,N) cin >> A[i]; vector<bool> dp(1<<16); dp[0] = true; for(int a : A){ vector<bool> tmp(1<<16); rep(q,16){ a = (a>>1) | ((a%2)<<15); rep(i,1<<16) if(dp[i]) tmp[i|a] = true; } swap(dp,tmp); } int ans = 0; rep(i,1<<16) if(dp[i]) ans = i; cout << ans << '\n'; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;