日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

BZOJ - 3578: GTY的人类基因组计划2

發(fā)布時間:2025/3/19 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 BZOJ - 3578: GTY的人类基因组计划2 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

3578: GTY的人類基因組計劃2

第一次居然hash被卡了。改了改rd()就A了。

題解:咱給每個人都隨機一個數,幾個人就是把他們的數異或起來,用set判重。再開一個set記錄合法的房間。

1 #include<set> 2 #include<cstdio> 3 #include<bitset> 4 #include<cstdlib> 5 #include<iostream> 6 using namespace std; 7 inline char nc() { 8 static char b[1<<16],*s=b,*t=b; 9 return s==t&&(t=(s=b)+fread(b,1,1<<16,stdin),s==t)?-1:*s++; 10 } 11 inline void read(int &x) { 12 char b = nc(); x = 0; 13 for (; !isdigit(b); b = nc()); 14 for (; isdigit(b); b = nc()) x = x * 10 + b - '0'; 15 } 16 inline int op() { 17 char b = nc(); for (; b != 'C' && b != 'W'; b = nc()); return b == 'C'; 18 } 19 typedef unsigned long long ull; 20 typedef ull bt; 21 int n, m, q, p[100005], c[100005]; 22 const ull ULL_MAX = -1; 23 bt a[100005], b[100005]; 24 inline ull rd() { 25 return ull(rand()) * rand() * rand(); 26 } 27 set < bt > h; 28 set < int > s; 29 int main() { 30 read(n); read(m); read(q); srand(89513255); s.insert(1); 31 for (int i = 1; i <= n; ++i) a[i] = rd(), p[i] = 1; 32 for (int i = 1; i <= n; ++i) b[1] ^= a[i]; c[1] = n; 33 for (int l, r, o, i = 0; i < q; ++i) { 34 o = op(); read(l); read(r); 35 if (o) { 36 if (p[l] == r) continue; 37 s.erase(p[l]); s.erase(r); 38 b[p[l]] ^= a[l]; --c[p[l]]; 39 if (!h.count(b[p[l]])) s.insert(p[l]); 40 b[r] ^= a[l]; ++c[r]; p[l] = r; 41 if (!h.count(b[r])) s.insert(r); 42 } else { 43 int ans = 0; static set < int > :: iterator it; it = s.lower_bound(l); 44 for (; it != s.end() && *it <= r; it = s.lower_bound(l)) { 45 h.insert(b[*it]); ans += c[*it]; s.erase(it); 46 } printf("%d\n", ans); 47 } 48 } 49 return 0; 50 }

?

轉載于:https://www.cnblogs.com/p0ny/p/8243714.html

總結

以上是生活随笔為你收集整理的BZOJ - 3578: GTY的人类基因组计划2的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。