結果
問題 |
No.8015 アンチローリングハッシュ
|
ユーザー |
|
提出日時 | 2020-05-06 17:20:17 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 590 bytes |
コンパイル時間 | 2,793 ms |
コンパイル使用メモリ | 196,920 KB |
最終ジャッジ日時 | 2025-01-10 07:15:20 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; unsigned long long get_hash(string s, unsigned long long a, unsigned long long b){ unsigned long long hash = 0; for(int i = 0; i < s.size(); i++){ hash = (hash * a + s[i]) % b; } return hash; } random_device seed_gen; mt19937 rng(seed_gen()); int main(){ int a,b; cin>>a>>b; vector<string> H(b); while(1){ string s; rep(i,30) s+='a'+rng()%26; int h=get_hash(s,a,b); if(H[h].empty()){ H[h]=s; } else if(H[h]!=s){ cout<<H[h]<<'\n'<<s<<'\n'; break; } } return 0; }