Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- void solve(){
- int n, m; cin >> n >> m;
- vector<bitset<4000> > top(m + 1), bot(m + 1);
- for(int i = 1; i <= n; i++){
- copy(bot.begin(), bot.end(), top.begin());
- for(int j = 1; j <= m; j++){
- char t; cin >> t; t -= '0';
- bot[j] = bot[j - 1] | top[j];
- if(bot[j] == 0) bot[j] = 1;
- bot[j] <<= t;
- }
- }
- for(int i = 0; i < 4000; i++)
- if(bot[m][i]) cout << i << ' ';
- cout << '\n';
- }
- int main(){
- ios::sync_with_stdio(0); cin.tie(0);
- int T; cin >> T;
- while(T--) solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement