結果
| 問題 |
No.158 奇妙なお使い
|
| コンテスト | |
| ユーザー |
codershifth
|
| 提出日時 | 2015-10-14 23:36:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,214 bytes |
| コンパイル時間 | 1,434 ms |
| コンパイル使用メモリ | 160,524 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-21 15:58:03 |
| 合計ジャッジ時間 | 2,926 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | WA * 27 |
ソースコード
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int (i)=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define RANGE(vec) (vec).begin(),(vec).end()
using namespace std;
const int Mod = (int)1e9+7;
class TrendAndCountermeasures_PineDecorationSequence3 {
public:
array<int,7> high;
array<int,7> low;
// min{ Set(small) } < max{ Set(big) }
// となりかつ Set(small) u Set(big) の要素が全て異なるような組み合わせ
ll calc(int small, int big) {
// dp[x][S] := x 以下の数字をつかって条件を満たすような S を選ぶ選び方
vector<ll> dp(1<<7, 0);
dp[0] = 1;
// 取りうる x 全てを見る
for (int x = 1; x <= 20000; ++x)
{
// dp の更新が S が小さいもの(前の x までの結果)を使って
// 大きい物を更新するので降順
for (int S = (1<<7)-1; S > 0; --S)
{
bool small_done = ((S & small) == small);
bool big_exist = ((S & big) != 0);
if ( !small_done && big_exist )
continue;
REP(i,7)
{
if ( !(S & (1<<i)))
continue;
if ( (small & (1<<i)) && big_exist )
continue;
if (x < low[i] || high[i] < x)
continue;
(dp[S] += dp[S^(1<<i)]) %= Mod;
}
}
}
return dp[(1<<7)-1];
}
void solve(void) {
const int bdf = (1<<1) | (1<<3) | (1<<5);
const int aceg = ((1<<7)-1) ^ bdf;
REP(i,7)
cin>>low[i]>>high[i];
ll res = calc(bdf, aceg) + calc(aceg, bdf);
cout<<res % Mod<<endl;
}
};
#if 1
int main(int argc, char *argv[])
{
ios::sync_with_stdio(false);
auto obj = new TrendAndCountermeasures_PineDecorationSequence3();
obj->solve();
delete obj;
return 0;
}
#endif
codershifth