結果

問題 No.122 傾向と対策:門松列(その3)
ユーザー sugim48sugim48
提出日時 2015-01-09 00:55:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 1,352 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 92,276 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-03 22:47:52
合計ジャッジ時間 1,607 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
4,380 KB
testcase_01 AC 28 ms
4,380 KB
testcase_02 AC 51 ms
4,380 KB
testcase_03 AC 36 ms
4,380 KB
testcase_04 AC 26 ms
4,376 KB
testcase_05 AC 48 ms
4,384 KB
testcase_06 AC 22 ms
4,380 KB
testcase_07 AC 19 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;
int INF = INT_MAX / 2;

int aceg = 85, bdf = 42;

int solve(vector<int>& lb, vector<int>& ub, int mask1, int mask2) {
	vector<ll> dp(1 << 7);
	dp[0] = 1;
	for (int x = 0; x < 20000; x++) {
		vector<ll> _dp = dp;
		for (int S = 0; S < (1 << 7); S++) {
			if ((S & mask1) != mask1 && (S & mask2)) continue;
			for (int i = 0; i < 7; i++)
				if (!(S & (1 << i)) && x >= lb[i] && x < ub[i]) {
					int T = S | (1 << i);
					_dp[T] = (_dp[T] + dp[S]) % MOD;
				}
		}
		dp = _dp;
	}
	return dp[(1 << 7) - 1];
}

int main() {
	vector<int> lb(7), ub(7);
	for (int i = 0; i < 7; i++) {
		cin >> lb[i] >> ub[i];
		lb[i]--;
	}
	cout << (solve(lb, ub, aceg, bdf) + solve(lb, ub, bdf, aceg)) % MOD << endl;
}
0