解題思路
雜湊對映,因為是字串對映字串的,所以容易爆記憶體
要轉換成雜湊值的對映
一開始,我的s1,s2是用結構體的,但是它一直output limit
換成2維就過了
還有scanf的正則真好用
**
#include
#include
#include
#include
#include
using namespace std;
const
int seed =7;
const
int max =
1e9+5;
map<
int,
int> m;
char s1[
100005][
25];char s2[
100005][
85];int
hash
(char
* str,
int l,
int r)
}return
(ans%max);}
char input[
105]
;int
main()
int n;
scanf
("%d"
,&n)
;getchar()
;while
(n--
)else
if(m.
find
(h)==m.
end(
)) cout<<
"what?"
<
else
else}}
return0;
}
Week15實驗 D 瑞瑞愛上字串 模擬
瑞瑞最近迷上了字串,因此決定出乙個字串的題。給定兩個正整數 n k,考慮所有由 n 2 個 a 和 2 個 b 組成的字串,要求輸出其中字典序第 k 小的。例如當 n 5 時,共有如下 10 種組成方式 aaabb aabab aabba abaab ababa abbaa baaab baaba ...
程式設計 Week15 必做題
霍格沃茲!好了進入正題 題意 zjm 為了準備霍格沃茲的期末考試,決心背魔咒詞典,一舉拿下咒語翻譯題 題庫格式 魔咒 對應功能 背完題庫後,zjm 開始刷題,現共有 n 道題,每道題給出乙個字串,可能是 魔咒 也可能是對應功能 zjm 需要識別這個題目給出的是 魔咒 還是對應功能,並寫出轉換的結果,...
Week15 選做部分
採用字典樹的方式來解決字串匹配問題 再插入過程中判斷是否可以匹配 1 最後乙個字元落到已存在的節點 2 經過其他字串的尾部 include include using namespace std struct trie bool insert char str else if flag child ...