前段时间做的题,当时没完全通过,今早上想到一种情况,试了一下通过了,题目没问题,就是解释的不够清楚
题中说的那个同样的分词算作一个包括 : hello world = hello+world = hello world 这种情况,,,
方法就是 map 映射
(注:博客作为交流使用,切勿抄袭应付作业)
这是完全通过的代码:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100000+7, INF = 0x7f7f7f7f;
int n;
char s[147];
string t;
set<string> ans, cur;
map<string, int> mp;
struct node {
string name;
int cnt;
}a[maxn];
bool cmp(node a, node b) {
if(a.cnt == b.cnt) return a.name < b.name;
return a.cnt > b.cnt;
}
void work(int len) {
cur.clear();
for(int i = 0; i < len; ++i) {
if(s[i] == '#') {
int j = i+1;