답안 #958663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958663 2024-04-06T10:01:40 Z M_SH_O XORanges (eJOI19_xoranges) C++14
55 / 100
29 ms 2140 KB
#pragma GCC optimize("O3")
#pragma GCC optimization("Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include<bits/stdc++.h>
#define ll long long
#define dou long double
#define str string
#define pb push_back
#define fr first
#define se second
#define vll vector<ll>
#define vpll vector<pair<ll, ll>>
#define pll pair<ll, ll>
#define endl "\n"

using namespace std;

ll n;
ll a[100000];     
/*ll tree[400004];  
void build_tree(int v, int tl, int tr) {
    if (tl == tr) 
    {
        if(tl % 2 == 0) tree[v] = a[tl];
        else tree[v] = 0;
    } else {
        int tm = (tl + tr) / 2;
        build_tree(v * 2, tl, tm);
        build_tree(v * 2 + 1, tm + 1, tr);
        tree[v] = tree[v * 2] ^ tree[v * 2 + 1];
    }
}
int get_sum(int l, int r, int v, int tl, int tr) {
    if (l <= tl && tr <= r) {
        return tree[v];
    }

    if (tr < l || r < tl) {
        return 0;
    }

    int tm = (tl + tr) / 2;
    ll k = get_sum(l, r, v * 2,     tl,     tm)
         ^ get_sum(l, r, v * 2 + 1, tm + 1, tr);
    return k;
}
void update(int idx, int val, int v, int tl, int tr) 
{
    if (idx <= tl && tr <= idx) 
    {
        a[idx] = val;
        tree[v] = val;
        return;
    }

    if (tr < idx || idx < tl) {
        return;
    }

    int tm = (tl + tr) / 2;
    update(idx, val, v * 2,     tl,     tm);
    update(idx, val, v * 2 + 1, tm + 1, tr);
    tree[v] = tree[v * 2] ^ tree[v * 2 + 1];
}
*/

int main()
{
    ll n, q, k, x, l, r;
    cin >> n >> q;
    for(int i = 0; i < n; i ++)
    {
        cin >> a[i];
    }
    //build_tree(1, 0, n-1);
    for(; q > 0; q --)
    {
        cin >> x >> l >> r;
        if(x == 1)
        {
            a[l-1] = r;
        }
        else
        {
            k = 0;
            if((r-l+1) % 2 == 1)
            {
                for(int i = l-1; i < r; i += 2)
                {
                    k ^= a[i];
                }
            }
            
            cout << k << endl;
            
        }
    }
    
}

Compilation message

xoranges.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization("Ofast,unroll-loops")
      |
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 2 ms 452 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 448 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 2 ms 452 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 8 ms 600 KB Output is correct
12 Correct 10 ms 464 KB Output is correct
13 Correct 11 ms 604 KB Output is correct
14 Correct 11 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 2140 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 1 ms 448 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 448 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 600 KB Output is correct
8 Correct 2 ms 452 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 8 ms 600 KB Output is correct
12 Correct 10 ms 464 KB Output is correct
13 Correct 11 ms 604 KB Output is correct
14 Correct 11 ms 580 KB Output is correct
15 Runtime error 29 ms 2140 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -