身邊找不到人討論題目...幸好還有這裡
原題目:(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)會超時的用意為何...