题解 | #压缩二维码#
压缩二维码
https://www.nowcoder.com/practice/1150d36c2cd64df9bf373988486c6723
#include <bits/stdc++.h> #include <vector> const int N = 2e5 + 10; const int inf = 0x3f3f3f3f; using namespace std; using ull = unsigned long long int; using ll = long long int; int f(string x){ int res=0; for(int i=0;i<4;i++){ res+=(x[i]=='#')*(1<<(3-i)); } return res; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin>>n; n=(1<<n); string ans; for(int i=0;i<n;i++){ string a; cin>>a; ans+=a; } n=n*n; for(int i=0;i<ans.size();i+=4){ string x; x+=ans[i]; x+=ans[i+1]; x+=ans[i+2]; x+=ans[i+3]; cout<<f(x)<<" "; } return 0; }
二维字符压缩成一维然后每四个字符算一下转二进制的数输出