답안 #651195

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
651195 2022-10-18T02:26:07 Z BrineTw Intergalactic ship (IZhO19_xorsum) C++14
17 / 100
2000 ms 2212 KB
#include <bits/stdc++.h>

using namespace std;

const int M = 1e9 + 7;

struct Update {
    int l, r, x;
};

int mAdd(const int a, const int b) {
    if (a + b >= M) return a + b - M;
    if (a + b < 0) return a + b + M;
    return a + b;
}

int calculate(vector<int> v, vector<Update>& update, int i) {
    int sum = 0;

    for (int j = 0; i; j++, i >>= 1) {
        if (i & 1) {
            for (int k = update[j].l; k < update[j].r; k++) {
                v[k] ^= update[j].x;
            }
        }
    }

    for (int i = 0; i < v.size(); i++) {
        int currentTotal = 0;
        for (int j = i; j < v.size(); j++) {
            currentTotal += v[j];
            sum = mAdd(sum, currentTotal * currentTotal % M);
        }
    }

    return sum;
}

int main() {
    int length;
    cin >> length;

    vector<int> v(length);
    for (auto& n: v) cin >> n;

    int query;
    cin >> query;

    vector<Update> update(query);
    for (auto& [l, r, x]: update) {
        cin >> l >> r >> x;
        --l;
    }

    int sum = 0;
    for (int i = 0; i < (1 << query); i++) {
        sum = mAdd(sum, calculate(v, update, i));
    }

    cout << sum << '\n';
}

Compilation message

xorsum.cpp: In function 'int calculate(std::vector<int>, std::vector<Update>&, int)':
xorsum.cpp:28:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i = 0; i < v.size(); i++) {
      |                     ~~^~~~~~~~~~
xorsum.cpp:30:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int j = i; j < v.size(); j++) {
      |                         ~~^~~~~~~~~~
xorsum.cpp: In function 'int main()':
xorsum.cpp:50:16: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   50 |     for (auto& [l, r, x]: update) {
      |                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 13 ms 300 KB Output is correct
7 Correct 16 ms 300 KB Output is correct
8 Correct 14 ms 300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 2212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2073 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1425 ms 280 KB Output is correct
2 Correct 1467 ms 280 KB Output is correct
3 Correct 1524 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1425 ms 280 KB Output is correct
2 Correct 1467 ms 280 KB Output is correct
3 Correct 1524 ms 292 KB Output is correct
4 Incorrect 3 ms 340 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 13 ms 300 KB Output is correct
7 Correct 16 ms 300 KB Output is correct
8 Correct 14 ms 300 KB Output is correct
9 Correct 1425 ms 280 KB Output is correct
10 Correct 1467 ms 280 KB Output is correct
11 Correct 1524 ms 292 KB Output is correct
12 Incorrect 59 ms 296 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 13 ms 300 KB Output is correct
7 Correct 16 ms 300 KB Output is correct
8 Correct 14 ms 300 KB Output is correct
9 Correct 1425 ms 280 KB Output is correct
10 Correct 1467 ms 280 KB Output is correct
11 Correct 1524 ms 292 KB Output is correct
12 Incorrect 3 ms 340 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 300 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 13 ms 300 KB Output is correct
7 Correct 16 ms 300 KB Output is correct
8 Correct 14 ms 300 KB Output is correct
9 Incorrect 61 ms 2212 KB Output isn't correct
10 Halted 0 ms 0 KB -