답안 #564103

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
564103 2022-05-18T14:47:59 Z Stickfish Intergalactic ship (IZhO19_xorsum) C++17
0 / 100
2000 ms 2304 KB
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

const int MAXN = 1008;
const ll MOD = 1000000007;
int a[MAXN];

vector<int> updt(vector<int>& cnts, int t) {
    vector<int> ans = cnts;
    for (int i = 0; i < 128; ++i) {
        ans[i ^ t] += cnts[i];
        if (ans[i ^ t] >= MOD)
            ans[i ^ t] -= MOD;
    }
    return ans;
}

bool in(pair<int, int> sg, int i) {
    return sg.first <= i && i < sg.second;
}

signed main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int q;
    cin >> q;
    vector<pair<pair<int, int>, int>> qrs(q);
    for (int i = 0; i < q; ++i) {
        cin >> qrs[i].first.first >> qrs[i].first.second >> qrs[i].second;
        --qrs[i].first.first;
    }
    ll ans = 0;
    //for (int i = 0; i < n; ++i) {
        //vector<int> cnts(128);
        //cnts[a[i]] = 1;
        //for (auto [sg, x] : qrs) {
            //if (in(sg, i))
                //cnts = updt(cnts, x);
        //}
        //for (int x = 0; x < 128; ++x) {
            //ans += 1ll * (i + 1) * (n - i) * x * x % MOD * cnts[x];
            //ans %= MOD;
        //}
    //}
    for (int i = 0; i < n; ++i) {
        for (int j = i; j < n; ++j) {
            vector<int> cntsi(128);
            vector<int> cntsj(128);
            vector<int> cntsij(128);
            cntsi[a[i]] = cntsj[a[j]] = cntsij[0] = 1;
            for (auto [sg, x] : qrs) {
                bool ini = in(sg, i);
                bool inj = in(sg, j);
                if (ini && !inj)
                    cntsi = updt(cntsi, x);
                else if (!ini && inj)
                    cntsj = updt(cntsj, x);
                else if (ini && inj)
                    cntsij = updt(cntsij, x);
            }
            ll ans0 = ans;
            ll addans = 0;
            for (int xi = 0; xi < 128; ++xi) {
                if (cntsi[xi] == 0)
                    continue;
                for (int xj = 0; xj < 128; ++xj) {
                    if (cntsj[xj] == 0)
                        continue;
                    for (int xij = 0; xij < 128; ++xij) {
                        if (cntsij[xij] == 0)
                            continue;
                        if (i != j)
                            addans += 2ll * (xi ^ xij) * (xj ^ xij) * cntsi[xi] % MOD * cntsj[xj] % MOD * cntsij[xij];
                        else
                            addans += 1ll * (xi ^ xij) * (xj ^ xij) * cntsi[xi] % MOD * cntsj[xj] % MOD * cntsij[xij];
                        addans %= MOD;
                    }
                }
            }
            addans *= (i + 1) * (n - j);
            ans += addans;
            ans %= MOD;
            //cout << i << ' ' << j << ": " << ans - ans0 << endl;
        }
    }
    cout << ans << endl;
}

Compilation message

xorsum.cpp: In function 'int main()':
xorsum.cpp:65:16: warning: unused variable 'ans0' [-Wunused-variable]
   65 |             ll ans0 = ans;
      |                ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2075 ms 2304 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1092 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Incorrect 1 ms 300 KB Output isn't correct
4 Halted 0 ms 0 KB -