Submission #992900

# Submission time Handle Problem Language Result Execution time Memory
992900 2024-06-05T08:14:02 Z Ice_man Intergalactic ship (IZhO19_xorsum) C++14
17 / 100
2000 ms 2648 KB
/**
 ____    ____    ____    __________________    ____    ____    ____
||I ||  ||c ||  ||e ||  ||                ||  ||M ||  ||a ||  ||n ||
||__||  ||__||  ||__||  ||________________||  ||__||  ||__||  ||__||
|/__\|  |/__\|  |/__\|  |/________________\|  |/__\|  |/__\|  |/__\|

*/

#include <iostream>
#include <chrono>
#include <stack>
#include <vector>

#define endl '\n'
#define maxn 100005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define mod (int)(1e9 + 7)
#define endl '\n'
#define pb(x) push_back(x)
#define X first
#define Y second
#define control cout<<"passed"<<endl;

#pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math")
#pragma GCC target("avx2")

using namespace std;


typedef pair <int, int> pii;
typedef long long ll;
typedef pair <ll, ll> pll;
typedef pair <int, ll> pil;
typedef pair <ll, int> pli;
typedef long double ld;


std::chrono::high_resolution_clock::time_point startT, currT;
constexpr double TIME_MULT = 1;

double timePassed()
{
    using namespace std::chrono;
    currT = high_resolution_clock::now();
    double time = duration_cast<duration<double>>(currT - startT).count();
    return time * TIME_MULT;
}


template <typename T>
T power2(T num)
{
    return num * num;
}



int n, q;
ll a[maxn], pref[maxn];
int l[maxn], r[maxn], x[maxn];
void read()
{
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];

    cin >> q;
    for(int i = 0; i < q; i++)
    {
        cin >> l[i] >> r[i] >> x[i];
        l[i]--;
        r[i]--;
    }
}



void solve()
{
    ll sum = 0;
    for(int mask = 0; mask < (1 << q); mask++)
    {
        for(int bit = 0; bit < q; bit++)
            if(mask & (1 << bit))
            {
                pref[l[bit]] ^= x[bit];
                pref[r[bit] + 1] ^= x[bit];
            }

        for(int i = 1; i < n; i++)
            pref[i] ^= pref[i - 1];

        for(int i = 0; i < n; i++)
            a[i] ^= pref[i];

        ll cur = 0 , pom = 0;
        for(int i = 0; i < n; i++)
        {
            pom = 0;
            for(int j = i; j < n; j++)
            {
                pom += a[j];
                cur += power2(pom);
                cur %= mod;
            }
        }

        sum += cur;
        sum %= mod;

        for(int i = 0; i < n; i++)
        {
            a[i] ^= pref[i];
            pref[i] = 0;
        }
    }

    cout << sum << endl;
}





void combine()
{
    int t;
    cin >> t;
    //while(t--)
        //read_solve();
}


int main()
{

    /**#ifdef ONLINE_JUDGE
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    #endif*/

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    ///startT = std::chrono::high_resolution_clock::now();

    read();
    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 17 ms 2396 KB Output is correct
7 Correct 18 ms 2396 KB Output is correct
8 Correct 18 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 2648 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2045 ms 2392 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1646 ms 2396 KB Output is correct
2 Correct 1657 ms 2488 KB Output is correct
3 Correct 1650 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1646 ms 2396 KB Output is correct
2 Correct 1657 ms 2488 KB Output is correct
3 Correct 1650 ms 2640 KB Output is correct
4 Incorrect 2 ms 2396 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 17 ms 2396 KB Output is correct
7 Correct 18 ms 2396 KB Output is correct
8 Correct 18 ms 2396 KB Output is correct
9 Correct 1646 ms 2396 KB Output is correct
10 Correct 1657 ms 2488 KB Output is correct
11 Correct 1650 ms 2640 KB Output is correct
12 Incorrect 70 ms 2392 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 17 ms 2396 KB Output is correct
7 Correct 18 ms 2396 KB Output is correct
8 Correct 18 ms 2396 KB Output is correct
9 Correct 1646 ms 2396 KB Output is correct
10 Correct 1657 ms 2488 KB Output is correct
11 Correct 1650 ms 2640 KB Output is correct
12 Incorrect 2 ms 2396 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 17 ms 2396 KB Output is correct
7 Correct 18 ms 2396 KB Output is correct
8 Correct 18 ms 2396 KB Output is correct
9 Incorrect 12 ms 2648 KB Output isn't correct
10 Halted 0 ms 0 KB -