Submission #70172570


Source Code Expand

// To scale the heights, one must embrace the fall.
#include <bits/stdc++.h>
#define fi first
#define se second
#define int long long
#define pb emplace_back
#define F(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i >= (b); --i)
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 400005, B = 5000, mod = 998244353;
int n, a[N], s[1 << 20], f[1 << 20];
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    cin >> n;
    // n = 400000;
    F(i, 1, n) {
        // a[i] = 1;
        cin >> a[i];
    }
    // nB + (n/B)*20*2^20
    int lst = 1;
    fill(s, s + (1 << 20), 1);
    fill(f, f + (1 << 20), 1);
    F(i, 1, n) {
        if (i % B == 0) {
            F(j, lst, i) f[a[j]] = f[a[j]] * a[j] % mod;
            memcpy(s, f, sizeof f);
            F(j, 0, 19) F(k, 1, (1 << 20) - 1) 
                if (k >> j & 1) s[k] = s[k] * s[k ^ (1 << j)] % mod;
            lst = i + 1;
        }
        int ans = s[a[i]];
        F(j, lst, i) {
            if ((a[j] | a[i]) == a[i]) {
                ans = ans * a[j] % mod;
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

Submission Info

Submission Time
Task E - Subset Product Problem
User zhutianrui
Language C++ 20 (gcc 12.2)
Score 700
Code Size 1242 Byte
Status AC
Exec Time 5420 ms
Memory 24592 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 59
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 02_small_00.txt, 02_small_01.txt, 02_small_02.txt, 02_small_03.txt, 02_small_04.txt, 02_small_05.txt, 02_small_06.txt, 03_random_00.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt, 03_random_13.txt, 03_random_14.txt, 03_random_15.txt, 03_random_16.txt, 03_random_17.txt, 03_random_18.txt, 03_random_19.txt, 03_random_20.txt, 03_random_21.txt, 03_random_22.txt, 03_random_23.txt, 03_random_24.txt, 03_random_25.txt, 03_random_26.txt, 03_random_27.txt, 03_random_28.txt, 03_random_29.txt, 03_random_30.txt, 03_random_31.txt, 03_random_32.txt, 03_random_33.txt, 03_random_34.txt, 03_random_35.txt, 03_random_36.txt, 03_random_37.txt, 03_random_38.txt, 03_random_39.txt, 03_random_40.txt, 03_random_41.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 19 ms 19784 KiB
00_sample_01.txt AC 7 ms 19800 KiB
00_sample_02.txt AC 7 ms 19760 KiB
01_handmade_00.txt AC 7 ms 19764 KiB
01_handmade_01.txt AC 5415 ms 23932 KiB
01_handmade_02.txt AC 2329 ms 22976 KiB
01_handmade_03.txt AC 5402 ms 22992 KiB
01_handmade_04.txt AC 5409 ms 23960 KiB
01_handmade_05.txt AC 5420 ms 23884 KiB
01_handmade_06.txt AC 5417 ms 23948 KiB
02_small_00.txt AC 10 ms 19888 KiB
02_small_01.txt AC 7 ms 19868 KiB
02_small_02.txt AC 8 ms 19780 KiB
02_small_03.txt AC 11 ms 19892 KiB
02_small_04.txt AC 36 ms 19828 KiB
02_small_05.txt AC 45 ms 19780 KiB
02_small_06.txt AC 11 ms 20020 KiB
03_random_00.txt AC 7 ms 19960 KiB
03_random_01.txt AC 1912 ms 22820 KiB
03_random_02.txt AC 241 ms 20216 KiB
03_random_03.txt AC 352 ms 20360 KiB
03_random_04.txt AC 1480 ms 21908 KiB
03_random_05.txt AC 2272 ms 23932 KiB
03_random_06.txt AC 2270 ms 23884 KiB
03_random_07.txt AC 2280 ms 23908 KiB
03_random_08.txt AC 2271 ms 23936 KiB
03_random_09.txt AC 2273 ms 23948 KiB
03_random_10.txt AC 2435 ms 23920 KiB
03_random_11.txt AC 2435 ms 23892 KiB
03_random_12.txt AC 2429 ms 23120 KiB
03_random_13.txt AC 2233 ms 23072 KiB
03_random_14.txt AC 2282 ms 23884 KiB
03_random_15.txt AC 4481 ms 23888 KiB
03_random_16.txt AC 4479 ms 23876 KiB
03_random_17.txt AC 4232 ms 23936 KiB
03_random_18.txt AC 4211 ms 23964 KiB
03_random_19.txt AC 3443 ms 23928 KiB
03_random_20.txt AC 3398 ms 23936 KiB
03_random_21.txt AC 4471 ms 22932 KiB
03_random_22.txt AC 4459 ms 23072 KiB
03_random_23.txt AC 4390 ms 22956 KiB
03_random_24.txt AC 4394 ms 22984 KiB
03_random_25.txt AC 3435 ms 23040 KiB
03_random_26.txt AC 3435 ms 22988 KiB
03_random_27.txt AC 4262 ms 23920 KiB
03_random_28.txt AC 4280 ms 23900 KiB
03_random_29.txt AC 4467 ms 23912 KiB
03_random_30.txt AC 4466 ms 23884 KiB
03_random_31.txt AC 4487 ms 24020 KiB
03_random_32.txt AC 4496 ms 24032 KiB
03_random_33.txt AC 4039 ms 22956 KiB
03_random_34.txt AC 4040 ms 23008 KiB
03_random_35.txt AC 4193 ms 24164 KiB
03_random_36.txt AC 4212 ms 24404 KiB
03_random_37.txt AC 4210 ms 24592 KiB
03_random_38.txt AC 4214 ms 23956 KiB
03_random_39.txt AC 4483 ms 22848 KiB
03_random_40.txt AC 4248 ms 23896 KiB
03_random_41.txt AC 3398 ms 24440 KiB