Submission #992868

# Submission time Handle Problem Language Result Execution time Memory
992868 2024-06-05T07:58:24 Z Ice_man Intergalactic ship (IZhO19_xorsum) C++14
0 / 100
2000 ms 10840 KB
/**
 ____    ____    ____    __________________    ____    ____    ____
||I ||  ||c ||  ||e ||  ||                ||  ||M ||  ||a ||  ||n ||
||__||  ||__||  ||__||  ||________________||  ||__||  ||__||  ||__||
|/__\|  |/__\|  |/__\|  |/________________\|  |/__\|  |/__\|  |/__\|

*/

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

#define endl '\n'
#define maxn 1000005
#define maxlog 20
#define INF 1000000010
#define LINF 1000000000000000005
#define mod 1000000007
#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;
int a[maxn], pref[maxn];
int l[maxn], r[maxn], x[maxn];
void read()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];

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



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

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

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

        int cur = 0 , pom = 0;
        for(int i = 1; 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 = 1; 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;
}

Compilation message

xorsum.cpp: In function 'void solve()':
xorsum.cpp:82:34: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
   82 |             if(mask & (1 << bit) == 1)
      |                       ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 10840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2049 ms 6492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1775 ms 6600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1775 ms 6600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Incorrect 1 ms 6492 KB Output isn't correct
4 Halted 0 ms 0 KB -