Submission #992940

# Submission time Handle Problem Language Result Execution time Memory
992940 2024-06-05T08:27:58 Z NValchanov Intergalactic ship (IZhO19_xorsum) C++17
17 / 100
2000 ms 5164 KB
#include <bits/stdc++.h>

#define endl '\n'

using namespace std;

typedef long long ll;

const ll MAXN = 1e3 + 10;
const ll MOD = 1e9 + 7;
const ll MAXLOG = 10;

struct upd
{
    ll left, right;
    ll val;

    upd()
    {
        left = right = 1;
        val = 0;
    }

    upd(ll _left, ll _right, ll _val)
    {
        left = _left;
        right = _right;
        val = _val;
    }
};

ll n, q;
ll a[MAXN];
ll cur[MAXN];
vector < upd > updates;

ll ans = 0;

void read()
{
    cin >> n;
    for(ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    cin >> q;
    for(ll i = 0; i < q; i++)
    {
        ll left, right;
        ll x;

        cin >> left >> right >> x;

        upd u = upd(left - 1, right - 1, x);

        updates.push_back(u);
    }
}

ll calc()
{
    ll qni = 0;
    ll sum = 0;
    ll sumsum = 0;

    for(ll i = 0; i < n; i++)
    {
        sum = (sum + cur[i]) % MOD;
        sumsum = (sumsum + sum) % MOD;
        qni = (qni + (sum * sum) % MOD) % MOD;
    }

    return (( qni * (n + 1) ) % MOD - (sumsum * sumsum) % MOD + MOD) % MOD;
}

void solve()
{
    for(ll mask = 0; mask < (1 << q); mask++)
    {
        for(ll i = 0; i < n; i++)
        {
            cur[i] = a[i];
        }

        for(ll j = 0; j < q; j++)
        {
            ll left = updates[j].left;
            ll right = updates[j].right;
            ll val = updates[j].val;

            if(mask & (1 << j))
            {
                for(ll i = left; i <= right; i++)
                {
                    cur[i] ^= val;
                }
            }
        }

        ans = (ans + calc()) % MOD;
    }

    cout << ans << endl;
}

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    read();
    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 5164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2058 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 327 ms 344 KB Output is correct
2 Correct 334 ms 596 KB Output is correct
3 Correct 329 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 327 ms 344 KB Output is correct
2 Correct 334 ms 596 KB Output is correct
3 Correct 329 ms 352 KB Output is correct
4 Incorrect 5 ms 604 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 327 ms 344 KB Output is correct
10 Correct 334 ms 596 KB Output is correct
11 Correct 329 ms 352 KB Output is correct
12 Incorrect 9 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 327 ms 344 KB Output is correct
10 Correct 334 ms 596 KB Output is correct
11 Correct 329 ms 352 KB Output is correct
12 Incorrect 5 ms 604 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 15 ms 5164 KB Output isn't correct
10 Halted 0 ms 0 KB -