# bitset+string+ Shutdown Stream synchronization optimization Oleg and Little ponies ural-2108__bitset

Source: Internet
Author: User
Tags bitset

Do you:
1 Knowledge Points: "bitset+string+ off Stream sync"
2: Line 1th Enter N, m, line 2nd to the m+1 line input m to the length of n 01 string bt[i][j], the first line of m+2 input length of n 01 string bi, the following steps:
(1) Looking for bt[i][0] bt[i][0] is the "substring" of the BT string (Bt[i][0]&bi = = bt[i][0), and the end is not found
(2) through (1) have been found I,bi = Bi | BT[I][1]
Output the last state of BI can
3 Problem Solving Ideas:
(1) Bitset enumeration judgment, string control output format, turn off stream synchronization to speed up data reading, printing

The following is the accepted code

``` #include <bits/stdc++.h> using namespace std;
int vis[4014];

Bitset<1014> bt[4014][2], bi;
int main () {Std::ios::sync_with_stdio (false);
int n, M, I, J; while (CIN >> n >> m) {for (i = 0; i < M. i++) {for (j = 0; J < 2; J +) {cin >> bt[
I][J];
} cin >> Bi;
memset (Vis, 0, sizeof (VIS));
while (true) {bool flag = false;
for (i = 0; i < m i++) {if (vis[i]) continue;
if ((bi&bt[i][0]) = = Bt[i][0]) {Vis[i] = 1, flag = true;
Bi |= bt[i][1];
} if (!flag) break;
} String st = Bi.to_string ();
cout << St.substr (st.size ()-N, St.size ()) << Endl;
return 0; }
```
Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.