답안 #993053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
993053 2024-06-05T09:20:48 Z Ice_man Intergalactic ship (IZhO19_xorsum) C++14
47 / 100
2000 ms 2700 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]--;
    }
}

int pow2[maxn];

void pre()
{
    pow2[0] = 1;
    for(int i = 1; i < maxn; i++)
        pow2[i] = pow2[i - 1] * 2 % mod;
}

void solve()
{
    ll sum = 0;

    for(int bit1 = 0; bit1 <= 6; bit1++)
        for(int bit2 = 0; bit2 <= 6; bit2++)
        {
            for(int i = 0; i < n; i++)
                for(int j = i; j < n; j++)
                {
                    ll cur = 0;
                    int br[2][2];
                    br[0][0] = 0;
                    br[0][1] = 0;
                    br[1][0] = 0;
                    br[1][1] = 0;

                    int c1, c2;
                    for(int k = 0; k < q; k++)
                    {
                        c1 = 0;
                        c2 = 0;

                        if((x[k] >> bit1 & 1) && l[k] <= i && i <= r[k])
                            c1 = 1;

                        if((x[k] >> bit2 & 1) && l[k] <= j && j <= r[k])
                            c2 = 1;
                        br[c1][c2]++;
                    }

                    if(br[1][1] != 0)
                    {
                        if(br[1][0] + br[0][1] != 0)
                            cur += pow2[q - 2];
                        else if((a[i] >> bit1 & 1) == (a[j] >> bit2 & 1))
                            cur += pow2[q - 1];
                    }
                    else
                    {
                        ll pom = 1;

                        if(br[1][0] != 0)
                        {
                            pom *= pow2[br[1][0] - 1];
                        }
                        else if(!(a[i] >> bit1 & 1))
                        {
                            pom = 0;
                        }

                        if(br[0][1] != 0)
                        {
                            pom *= pow2[br[0][1] - 1];
                        }
                        else if(!(a[j] >> bit2 & 1))
                        {
                            pom = 0;
                        }

                        cur += pom % mod * pow2[br[0][0]] % mod;
                    }
                    //cout << cur << endl;

                    if(i == j)
                        sum += cur % mod * (1 << (bit1 + bit2)) % mod * (i + 1) * (n - j) % mod;
                    else
                        sum += 2 * cur % mod * (1 << (bit1 + bit2)) % mod * (i + 1) * (n - j) % mod;
                }


        }


    cout << sum % mod << 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();

    pre();
    read();
    solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 7 ms 2700 KB Output is correct
7 Correct 7 ms 2700 KB Output is correct
8 Correct 7 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2064 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2077 ms 2652 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Correct 2 ms 2652 KB Output is correct
3 Correct 2 ms 2696 KB Output is correct
4 Correct 282 ms 2652 KB Output is correct
5 Correct 280 ms 2648 KB Output is correct
6 Correct 292 ms 2652 KB Output is correct
7 Correct 271 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 7 ms 2700 KB Output is correct
7 Correct 7 ms 2700 KB Output is correct
8 Correct 7 ms 2652 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 2 ms 2696 KB Output is correct
12 Correct 145 ms 2672 KB Output is correct
13 Correct 116 ms 2652 KB Output is correct
14 Correct 143 ms 2652 KB Output is correct
15 Correct 128 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 7 ms 2700 KB Output is correct
7 Correct 7 ms 2700 KB Output is correct
8 Correct 7 ms 2652 KB Output is correct
9 Correct 2 ms 2652 KB Output is correct
10 Correct 2 ms 2652 KB Output is correct
11 Correct 2 ms 2696 KB Output is correct
12 Correct 282 ms 2652 KB Output is correct
13 Correct 280 ms 2648 KB Output is correct
14 Correct 292 ms 2652 KB Output is correct
15 Correct 271 ms 2652 KB Output is correct
16 Correct 145 ms 2672 KB Output is correct
17 Correct 116 ms 2652 KB Output is correct
18 Correct 143 ms 2652 KB Output is correct
19 Correct 128 ms 2652 KB Output is correct
20 Execution timed out 2009 ms 2648 KB Time limit exceeded
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2652 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 7 ms 2700 KB Output is correct
7 Correct 7 ms 2700 KB Output is correct
8 Correct 7 ms 2652 KB Output is correct
9 Execution timed out 2064 ms 2652 KB Time limit exceeded
10 Halted 0 ms 0 KB -