Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stack>
- #include <math.h>
- #include <iostream>
- #include <algorithm>
- #include <string.h>
- #include <string>
- #include <set>
- #include <memory.h>
- #include <vector>
- #include <map>
- #include <queue>
- #include <iomanip>
- #include <ctime>
- #include <cassert>
- #define forn(i, n) for (int i = 0; i < (n); i++)
- using namespace std;
- const int N = 1000 * 100;
- const int p = 31;
- long long myHash(const string &s) {
- long long res = 0, p_pow = 1;
- for (int i = s.size() - 1; i >= 0; i--) {
- res += (s[i] - 'a' + 1) * p_pow;
- p_pow *= p;
- }
- assert(res < N);
- return res;
- }
- int main() {
- freopen("output.txt", "w", stdout);
- srand(time(NULL));
- int cnt[N];
- memset(cnt, 0, sizeof(cnt));
- map <long long, string> myHashs;
- forn (i, N) {
- string s = "";
- forn (j, 3)
- s += 'a' + (rand() % 26);
- myHashs[myHash(s)] = s;
- cnt[myHash(s)]++;
- }
- forn (i, N)
- if (cnt[i] != 0)
- while (cnt[i]--)
- cout << myHashs[i] << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement