結果
| 問題 |
No.941 商とあまり
|
| コンテスト | |
| ユーザー |
emthrm
|
| 提出日時 | 2019-12-05 01:28:38 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,396 bytes |
| コンパイル時間 | 1,614 ms |
| コンパイル使用メモリ | 128,452 KB |
| 最終ジャッジ日時 | 2025-01-08 08:36:13 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 WA * 2 |
| other | AC * 68 WA * 36 |
ソースコード
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
// dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
struct IOSetup {
IOSetup() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(20);
cerr << fixed << setprecision(10);
}
} iosetup;
/*-------------------------------------------------*/
void output(const vector<bool> &ans) {
for (bool e : ans) cout << e;
cout << '\n';
exit(0);
}
int main() {
int n, x; cin >> n >> x;
vector<int> a(n); REP(i, n) cin >> a[i];
vector<bool> ans(x, false);
if (n == 1) {
if (a[0] <= x) ans[a[0] - 1] = true;
output(ans);
}
if (n >= 19) output(ans);
long long lb = 1;
REP(i, n) {
lb *= a[i] + 1;
if (x < lb - 1) output(ans);
}
if (count(ALL(a), 1) > 0) {
FOR(i, lb - 1 - 1, x) ans[i] = true;
output(ans);
}
vector<int> p(n + 1, 1);
FOR(i, 1, n + 1) p[i] = p[i - 1] * 3;
vector<vector<bool> > dp(1 << n);
REP(i, 1 << n) dp[i].assign(x / p[n - __builtin_popcount(i)], false);
REP(i, n) {
if (a[i] < dp[1 << i].size()) dp[1 << i][a[i]] = true;
}
FOR(i, 1, 1 << n) REP(j, n) {
if (i >> j & 1) continue;
int nx_i = i | (1 << j);
vector<bool> tmp(dp[nx_i].size(), false);
REP(k, dp[i].size()) {
if (dp[i][k]) {
long long par = (1LL + k) * (a[j] + 1) - 1;
if (par < tmp.size()) tmp[par] = true;
}
}
REP(k, tmp.size()) {
if (tmp[k]) {
dp[nx_i][k] = true;
if (k + a[j] < tmp.size()) tmp[k + a[j]] = true;
}
}
}
FOR(j, 1, x + 1) ans[j - 1] = dp[(1 << n) - 1][j];
output(ans);
}
emthrm