답안 #1020838

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1020838 2024-07-12T10:22:41 Z FIFI_cpp XORanges (eJOI19_xoranges) C++17
55 / 100
1000 ms 5712 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <fstream>
#include <iterator>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <cctype>
#include <string>
#include <cassert>
#include <set>
#include <bitset>
#include <unordered_set>
using ll = int64_t;
#define pb push_back
#define all(a) a.begin(),a.end()
#define ppi pair<pair<int,int>,int>
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//#define int int64_t
// xcode cant include bits/stdc++.h
using namespace std;
//ifstream fin ("sleepy.in");
//ofstream fout ("sleepy.out");
/*   /\_/\
*   (= ._.)
*   / >  \>
*/
// encouraging cat
const int INF = 10000000000000000;
const int mod = 1000000007;
int32_t main() {
    int n,q;
    cin >> n >> q;
    vector<int> a(n);
    for (int i = 0;i < n;i++)
        cin >> a[i];
    bool ok = true;
    for (int i = 0;i < n;i++)
    {
        if (a[i] != i + 1)
            ok = false;
    }
    assert(!ok);
    while (q--)
    {
        int t;
        cin >> t;
        if (t == 1)
        {
            int i,v;
            cin >> i >> v;
            i--;
            a[i] = v;
        }
        else
        {
            int l,r;
            cin >> l >> r;
            l--;
            r--;
            if ((l - r + 1) % 2 == 0)
            {
                cout << 0 << '\n';
                continue;
            }
            else if (l - r + 1 == 2)
            {
                int cr = a[l];
                cr ^= a[r];
                cout << cr << '\n';
                continue;
            }
            int res = 0;
            for (int i = l;i <= r;i += 2)
            {
                res ^= a[i];
            }
            cout << res << '\n';
        }
    }
    return 0;
}

Compilation message

xoranges.cpp:32:9: warning: "/*" within comment [-Wcomment]
   32 | /*   /\_/\
      |          
xoranges.cpp:37:17: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000000000' to '1874919424' [-Woverflow]
   37 | const int INF = 10000000000000000;
      |                 ^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 2 ms 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 440 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 11 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Correct 17 ms 348 KB Output is correct
14 Correct 15 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1076 ms 5712 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 440 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 2 ms 440 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 11 ms 348 KB Output is correct
12 Correct 7 ms 348 KB Output is correct
13 Correct 17 ms 348 KB Output is correct
14 Correct 15 ms 604 KB Output is correct
15 Execution timed out 1076 ms 5712 KB Time limit exceeded
16 Halted 0 ms 0 KB -