Submission #2152614


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define F(i, s, t) for (int i = (s), _ = (t); i <= _; i ++)
#define Fo(i, s, t) for (int i = (s), _ = (t); i < _; i ++)
#define LL long long
const int N = 20;
const int S = 40000;
const int P = 1000000007;
int n, m, gr[N];
int p2[N*N], fu, cnt[S], edc[N][S];
int f[S];
int rd() {
	int x = 0; char c;
	do { c = getchar(); } while (!isdigit(c));
	do { x = x*10+c-'0', c = getchar(); } while (isdigit(c));
	return x;
}
int Ju(int s) { return (s & 3) == 0 || (s & 3) == 3; }
int main() {
	#ifndef ONLINE_JUDGE
		freopen("F.in", "r", stdin);
	#endif
	n = rd(), m = rd();
	F(i, 1, m) {
		int x = rd(), y = rd();
		gr[x] |= (1 << y-1);
	}
	p2[0] = 1;
	F(i, 1, n*n) p2[i] = p2[i-1] * 2 % P;
	fu = 1 << n;
	Fo(i, 1, fu) cnt[i] = cnt[i - (i & -i)] + 1;
	F(i, 1, n)
		Fo(s, 0, fu)
			edc[i][s] = cnt[gr[i] & s];
	f[0] = 1;
	Fo(s, 1, fu) if (Ju(s)) {
		for (int a = (s-1) & s; ; a = (a-1) & s) if (Ju(a) && f[a]) {
			int b = s-a, m = 1;
			F(i, 1, n)
				if (a >> i-1 & 1)
					m = (LL)m * (p2[edc[i][b]] - 1) % P;
			F(i, 1, n)
				if (b >> i-1 & 1)
					m = (LL)m * p2[edc[i][a]] % P;
			f[s] = (f[s] + (LL)f[a] * m) % P;
			if (!a) break;
		}
	}
	cout << (p2[m] - f[fu-1] + P) % P << endl;
	return 0;
}

Submission Info

Submission Time
Task F - Games on DAG
User Sdchr
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1290 Byte
Status TLE
Exec Time 5259 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:21:30: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   freopen("F.in", "r", stdin);
                              ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1600
Status
TLE × 4
TLE × 40
Set Name Test Cases
Sample 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt
All 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt
Case Name Status Exec Time Memory
0_00.txt TLE 5255 ms 256 KB
0_01.txt TLE 5255 ms 256 KB
0_02.txt TLE 5255 ms 256 KB
0_03.txt TLE 5255 ms 256 KB
1_00.txt TLE 5255 ms 256 KB
1_01.txt TLE 5259 ms 256 KB
1_02.txt TLE 5255 ms 256 KB
1_03.txt TLE 5255 ms 256 KB
1_04.txt TLE 5255 ms 256 KB
1_05.txt TLE 5255 ms 256 KB
1_06.txt TLE 5255 ms 256 KB
1_07.txt TLE 5255 ms 256 KB
1_08.txt TLE 5255 ms 256 KB
1_09.txt TLE 5255 ms 256 KB
1_10.txt TLE 5255 ms 256 KB
1_11.txt TLE 5255 ms 256 KB
1_12.txt TLE 5255 ms 256 KB
1_13.txt TLE 5255 ms 256 KB
1_14.txt TLE 5255 ms 256 KB
1_15.txt TLE 5255 ms 256 KB
1_16.txt TLE 5255 ms 256 KB
1_17.txt TLE 5255 ms 256 KB
1_18.txt TLE 5255 ms 256 KB
1_19.txt TLE 5255 ms 256 KB
1_20.txt TLE 5255 ms 256 KB
1_21.txt TLE 5255 ms 256 KB
1_22.txt TLE 5255 ms 256 KB
1_23.txt TLE 5255 ms 256 KB
1_24.txt TLE 5255 ms 256 KB
1_25.txt TLE 5255 ms 256 KB
1_26.txt TLE 5255 ms 256 KB
1_27.txt TLE 5255 ms 256 KB
1_28.txt TLE 5255 ms 256 KB
1_29.txt TLE 5255 ms 256 KB
1_30.txt TLE 5255 ms 256 KB
1_31.txt TLE 5255 ms 256 KB
1_32.txt TLE 5255 ms 256 KB
1_33.txt TLE 5255 ms 256 KB
1_34.txt TLE 5255 ms 256 KB
1_35.txt TLE 5255 ms 256 KB