#include<bits/stdc++.h>
using namespace std;
struct trie{
trie *fath; int siz;
unordered_map<int,trie*>son;
inline trie(trie *father)
{fath=father; siz=0;}
};
const int maxn=3e5+10;
int a[maxn];
int main(){
int q;scanf("%d",&q);
while(q--){
int n;scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",a+i);
long long ans=0;
trie *root=new trie(NULL);
++root->siz; stack<int>sta;
for(int i=1;i<=n;i++){
if(sta.empty() or a[i]!=sta.top()){
sta.push(a[i]);
root=root->son.emplace(a[i],new trie(root)).first->second;
}
else root=root->fath,sta.pop();
ans+=root->siz++;
}
printf("%lld\n",ans);
}
return 0;
}
为什么 root=root->son.emplace(a[i],new trie(root)).first->second; 这一行中,我不加 .first 就会 CE?
这个 .first 指向什么?