题意:
+ ;
];
;
;
], seg[rt << | ]);
)) * fa.setv;
) * fa.setv;
;
], seg[rt << | ], r - l + );
;
, R, rson);
;
) * v;
;
], seg[rt << | ], r - l + );
, R, v, rson);
], seg[rt << | ]);
], seg[rt << | ], r - l + );
, R, v, rson);
], seg[rt << | ]);
; i <= n; ++i) {
scanf( ar[i] = n + ;
}
memset(vis, , idx = ;
build(, n, );
ll ans = query(, n, , n, );
memset(hap, -, memset(nex, -,
; i <= n; ++i) {
)
hap[ar[i]] = i;
nex[hap[ar[i]]] = i;
hap[ar[i]] = i;
}
}
; i <= n - ; ++i) {
)
to = n;
to = nex[i] - ;
update(i, to, ar[i], , n, );
ans = ans + query(i, n, , n, );
}
printf( }
== scanf( == n) work();
}
;
}