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
Vjudge Topic link
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; }