QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#99733#5089. 环覆盖yllcm0 0ms0kbC++172.0kb2023-04-23 16:23:372023-04-23 16:23:39

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-23 16:23:39]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-04-23 16:23:37]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
using namespace std;
inline int read() {
    int x = 0; bool op = 0;
    char c = getchar();
    while(!isdigit(c))op |= (c == '-'), c = getchar();
    while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return op ? -x : x;
}
const int N = 1e5 + 10;
const int P = 1e9 + 7;
void add(int &a, int b) {a = (a + b) % P;}
void sub(int &a, int b) {a = (a - b + P) % P;}
int ksm(int x, int k) {
    int res = 1;
    for(int pw = x; k; (k & 1) ? res = 1ll * res * pw % P : 0, pw = 1ll * pw * pw % P, k >>= 1);
    return res;
}
int n, m;
int g[N], cnt[N], fac[N], ifac[N];
void dfs(int cur, int S, int now) {
    if(cur >= n)return cnt[now]++, void();
    dfs(cur + 1, S, now);
    dfs(cur + 1, S | (1 << cur), now - 2 * __builtin_popcount(g[cur] & S) + __builtin_popcount(g[cur]));
    return ;
}
void init() {
    fac[0] = ifac[0] = 1;
    for(int i = 1; i < N; i++)fac[i] = 1ll * fac[i - 1] * i % P;
    ifac[N - 1] = ksm(fac[N - 1], P - 2);
    for(int i = N - 2; i; i--)ifac[i] = 1ll * ifac[i + 1] * (i + 1) % P;
    return ;
}
int f[N];
int com(int n, int m) {return n < m || m < 0 ? 0 : 1ll * fac[n] * ifac[m] % P * ifac[n - m] % P;}
int main() { 
    freopen("in.txt", "r", stdin);
    init();
    n = read(); m = read();
    for(int i = 1; i <= m; i++) {
        int u = read() - 1, v = read() - 1;
        g[u] |= (1 << v); g[v] |= (1 << u);
    }
    dfs(0, 0, 0);
    for(int i = 0; i <= m; i++) {
        // printf("cnt:%d %d\n", i, cnt[i]);
        for(int j = 0; j <= m; j++) {
            for(int k = 0; k <= m; k++) {
                int sgn = (j & 1) ? P - 1 : 1;
                add(f[j + k], 1ll * cnt[i] * sgn % P * com(i, j) % P * com(m - i, k) % P);
            }
        }
    }
    for(int i = 0; i <= m; i++)printf("%d ", 1ll * ksm(1 << n, P - 2) * f[i] % P);
    return 0;
}

詳細信息

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

10 9
3 5
3 10
4 7
4 8
5 6
5 9
6 9
7 9
9 10

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Time Limit Exceeded

Test #31:

score: 0
Time Limit Exceeded

input:

25 45
1 6
1 12
1 17
2 3
2 4
2 6
3 6
3 8
4 5
4 12
4 16
5 17
6 21
7 14
7 22
7 23
8 15
8 19
8 24
9 11
9 19
9 23
9 25
10 17
10 18
11 16
11 19
11 22
12 19
13 18
14 19
15 19
16 24
17 19
17 22
17 25
18 19
18 21
18 24
19 23
20 22
21 25
22 23
23 25
24 25

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #2:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%