编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#5457 #1046. 城市道路 Runtime Error 50 738 ms 28560 K C++ 17 / 1.2 K t330026124 2024-04-27 16:09:15
显示原始代码
// G
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int maxn = 2e5 + 5, maxm = 1e6 + 5, Mod = 998244353;
int n, idx, head[maxn], a[maxn], sum[maxn];
struct Edge {
    int nxt, to, w;
} e[maxm];

void add(int u, int v, int w) {
    e[++idx] = { head[u], v, w };
    head[u] = idx;
}

signed main() {
    int t;
    cin >> t;
    while (t--) {
        cin >> n;
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                if (__builtin_popcount(a[i] & a[j])) {
                    add(i, j, __builtin_popcount(a[i] & a[j]));
                }
            }
        }
        sum[1] = 1;
        for (int u = 1; u <= n; u++) {
            for (int i = head[u]; i; i = e[i].nxt) {
                int v = e[i].to;
                sum[v] = (sum[v] + sum[u] * e[i].w % Mod) % Mod;
            }
        }
        cout << sum[n] << endl;
        idx = 0;
        for (int i = 1; i <= n; i++) {
            head[i] = 0;
            sum[i] = 0;
            a[i] = 0;
        }
        for (int i = 1; i <= n * (n - 1) / 2; i++) {
            e[i] = { 0, 0, 0 };
        }
    }
    return 0;
}
子任务 #1
Runtime Error
得分:50
测试点 #1
Accepted
得分:100
用时:6 ms
内存:384 KiB

输入文件(1.in

5
4
3 3 3 5
4
5 7 5 5
5
7 7 6 7 7
4
5 3 4 3
4
6 3 4 5

答案文件(1.out

9
18
112
3
3

用户输出

9
18
112
3
3

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:3 ms
内存:384 KiB

输入文件(2.in

5
4
6 5 6 5
5
6 7 5 5 7
5
5 5 5 6 5
3
6 5 5
5
5 5 5 6 6

答案文件(2.out

6
48
27
3
27

用户输出

6
48
27
3
27

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:69 ms
内存:11924 KiB

输入文件(3.in

5
992
974621722 1070849912 1024770314 1061714194 1063827651 1006682360 982695007 977204295 1066405
<53160 bytes omitted>

答案文件(3.out

778443053
150196926
279110252
720373133
81825995

用户输出

778443053
150196926
279110252
720373133
81825995

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:56 ms
内存:12028 KiB

输入文件(4.in

5
1000
1073741814 1073741817 1073741820 1073741823 1073741819 1073741813 1073741813 1073741817 107
<54825 bytes omitted>

答案文件(4.out

470614593
825689290
810424588
225499651
332080001

用户输出

470614593
825689290
810424588
225499651
332080001

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:53 ms
内存:12080 KiB

输入文件(5.in

5
998
1073741823 1073741823 1073741821 1073741821 1073741822 1073741822 1073741823 1073741823 1073
<54868 bytes omitted>

答案文件(5.out

989108000
933449660
534929925
874863392
783659486

用户输出

989108000
933449660
534929925
874863392
783659486

系统信息

Exited with return code 0
测试点 #6
Runtime Error
得分:0
用时:105 ms
内存:28560 KiB

输入文件(6.in

5
199995
1073741252 1073741803 1073741392 1073741206 1073741155 1073741773 1073741331 1073741306 1
<10999772 bytes omitted>

答案文件(6.out

983096127
364807666
47214227
144443274
288450476

系统信息

Killed: Segmentation fault
测试点 #7
Runtime Error
得分:0
用时:102 ms
内存:28544 KiB

输入文件(7.in

5
199998
1067253359 996256051 1045037927 614106317 991618988 249947064 602669502 998657161 7181591
<9965097 bytes omitted>

答案文件(7.out

47943747
686442205
392008007
468191791
24454134

系统信息

Killed: Segmentation fault
测试点 #8
Runtime Error
得分:0
用时:133 ms
内存:28536 KiB

输入文件(8.in

5
199998
951940730 1058356106 989745273 1040051616 594283879 570729590 617546154 232397972 1063918
<9965041 bytes omitted>

答案文件(8.out

69363956
379688823
300837179
727735848
799715349

系统信息

Killed: Segmentation fault
测试点 #9
Runtime Error
得分:0
用时:109 ms
内存:28536 KiB

输入文件(9.in

5
199999
561481717 819398622 839750385 463844251 244702539 356859284 246642270 827720823 220361906
<9965875 bytes omitted>

答案文件(9.out

69498265
869490899
586069227
753924040
462927283

系统信息

Killed: Segmentation fault
测试点 #10
Runtime Error
得分:0
用时:102 ms
内存:28504 KiB

输入文件(10.in

5
199996
969618274 279383602 595053246 1032967902 1016616932 682077984 563699700 637142145 3349721
<9965286 bytes omitted>

答案文件(10.out

967209796
772106892
350513313
766239553
2381591

系统信息

Killed: Segmentation fault