QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#843891#9921. YelkrabZawosRE 0ms0kbC++231.6kb2025-01-05 06:31:192025-01-05 06:31:20

Judging History

你现在查看的是最新测评结果

  • [2025-01-05 06:31:20]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2025-01-05 06:31:19]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using ld=long double;
using vi=vector<int>;
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
//上
const ll N = 1e6+10;
int nxt[N][26];
ll dp[N];
ll temp[500010];
vector<ll> vals[500010];
ll ans = 0;
int p1 = 0;
int p2 = 0;
void rt(){
    FOR(i,0,26) nxt[p2][i] = -1;
    dp[p2] = 1;
    
}
void add_string(string& s){
    p1 = 0;
    for(int i = 0; i < s.size();i++){
        if(nxt[p1][s[i]-'a'] == -1){
            nxt[p1][s[i]-'a'] = ++p2;
            rt();
        }else{
            dp[nxt[p1][s[i]-'a']]++;
        }
        p1 = nxt[p1][s[i]-'a'];
        for(int j = 0;j  <vals[dp[p1]].size();j++){
            ans^=temp[vals[dp[p1]][j]]*vals[dp[p1]][j];
            temp[vals[dp[p1]][j]]++;
            ans^=temp[vals[dp[p1]][j]]*vals[dp[p1]][j];
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    for(int i = 1; i<= 5e5+10; i++){
            for(int j = i; j <= 5e5+10; j+= i) vals[j].push_back(i);
        }
    while(t--){
        int n;
        cin >> n;
        vector<string> v(n);
        FOR(i,0,n){
            cin >> v[i];
            
        }
        FOR(i,0,n+2) temp[i] = 0;
        ans = 0;
        p2 = 0;
        rt();
        for(int i = 0; i < n; i++){
            add_string(v[i]);
            cout <<ans <<" ";
        }cout<<'\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

2
5
aa
ab
ab
ac
d
1
aaaaa

output:


result: