题目传送门 题意:询问所有字符串的比较次数和(注意for循环内的比较也算) 分析:将所有字符串插入到字典树上,然后结点信息记录有几个字符串,那么每走到一个结点就能知道比较到此时需要的次数.学习到链表存结点 #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 4e3 + 5; const int M = 1e3 + 5; const int NODE = N * M; struct T…
#include<iostream> #include<algorithm> #include<string> #include<cstring> #include<vector> using namespace std; * + ; int n; long long ans; struct Trie { int head[maxn]; //head[i]为第i个结点的左儿子编号 int next[maxn]; //next[i]为第i个结点的右…
strcmp() Anyone? strcmp() is a library function in C/C++ which compares two strings. It takes two strings as input parameter and decides which one is lexicographically larger or smaller: If the first string is greater then it returns a positive value…