QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#843891 | #9921. Yelkrab | Zawos | RE | 0ms | 0kb | C++23 | 1.6kb | 2025-01-05 06:31:19 | 2025-01-05 06:31:20 |
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';
}
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
2 5 aa ab ab ac d 1 aaaaa