身边找不到人讨论题目...幸好还有这里
原题目:(nthu_oj)
※先声明这不是作业,只是自己的练习
http://acm.cs.nthu.edu.tw/problem.php?pid=7667
这题我的作法是把袜子宣告成一个struct来储存name,size
struct Sock{
string name,size;
}
然后定义operator <(less than operator)
再把struct(袜子)跟int(次数)存到map里
用读进来的name, size建立struct, 插入到map中
如果已经在map中,则次数递增
如果不在,则初始化为1
测试结果是正确的, 但超时...
想请问有什么方法可以做更快?
(不知道他题目中给的hint: O(nlogn)会超时的用意为何...