7.7日

一、对昨天晚上的cf的c题进行总结

//https://mirror.codeforces.com/contest/1847/problem/C
/*手玩一下可以发现可以取到的值是原序列所有的子段,最最大子段异或和是经典问题,可以用01Trie解决,这里值域很小,暴力即可.*/
/*通过前缀异或和的性质,能发现最大值是数组的子区间异或和,因为笔者最近遇到了一道01tried树求路径异或和,所以联想到了通过01tried求数组区间最大异或和,上网抄一份板子,算是偷了一道题。*/
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
using LL = long long;

int main() {

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int T;
    cin >> T;
    while (T--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        vector<bool> v(256);
        v[0] = true;
        int s = 0, ans = 0;
        for (int i = 0; i < n; i++) {
            s ^= a[i];
            v[s] = true;
            for (int j = 0; j < 256; j++) {
                if (v[j]) {
                    ans = max(ans, s ^ j);
                }
            }
        }
        cout << ans << '\n';
    }

}

二、打算学一下Java的函数部分,并完成三四道练习题。

三、在晚上,七点有牛客练习赛,十点半有cf的div3竞赛。

四、写pta的实验报告。

五、明天打算好好练习算法,再刷科一的题。

posted on 2023-07-07 13:16  临江柔  阅读(33)  评论(0编辑  收藏  举报