题解 | 压缩二维码
压缩二维码
https://www.nowcoder.com/practice/1150d36c2cd64df9bf373988486c6723
//活动地址: 牛客春招刷题训练营 - 编程打卡活动
#pragma clang diagnostic push
#pragma ide diagnostic ignored "cppcoreguidelines-narrowing-conversions"
#pragma ide diagnostic ignored "hicpp-signed-bitwise"
#pragma GCC optimize ("Ofast,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<pdd> vpdd;
typedef vector<vd> vvd;
#define yn(ans) printf("%s\n", (ans)?"Yes":"No");
#define YN(ans) printf("%s\n", (ans)?"YES":"NO");
template<class T> bool chmax(T &a, T b) {
if (a >= b) return false;
a = b; return true;
}
template<class T> bool chmin(T &a, T b) {
if (a <= b) return false;
a = b; return true;
}
#define FOR(i, s, e, t) for ((i) = (s); (i) < (e); (i) += (t))
#define REP(i, e) for (int i = 0; i < (e); ++i)
#define REP1(i, s, e) for (int i = (s); i < (e); ++i)
#define RREP(i, e) for (int i = (e); i >= 0; --i)
#define RREP1(i, e, s) for (int i = (e); i >= (s); --i)
#define all(v) v.begin(), v.end()
#define pb push_back
#define qb pop_back
#define pf push_front
#define qf pop_front
#define maxe max_element
#define mine min_element
ll inf = 1e18;
#define DEBUG printf("%d\n", __LINE__); fflush(stdout);
template<class T> void print(vector<T> &v, bool withSize = false) {
if (withSize) cout << v.size() << endl;
REP(i, v.size()) cout << v[i] << " ";
cout << endl;
}
mt19937_64 rng((unsigned int) chrono::steady_clock::now().time_since_epoch().count());
int __FAST_IO__ = []() {
std::ios::sync_with_stdio(0);
std::cin.tie(0);
std::cout.tie(0);
return 0;
}();
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
typedef long long ll;
#define int long long
inline ll read() // void int &n
{
ll s=0,f=1;
char c=getchar();
while(c>'9'||c<'0')
{
if(c=='-')
f=-1;
c=getchar();
}
while(c>='0'&&c<='9')
{
s=(s<<1)+(s<<3)+c-'0';
c=getchar();
}
return s*f;
}
inline void write(int n)
{
if(n<0)
{
putchar('-');
n=-n;
}
if(n>10) write(n/10);
putchar(n%10+'0');
}
int jiechen(int n)
{
int sum = 1;
for (int i = 2; i <= n; i++)
sum = sum * i % mod;
return sum % mod;
}
int qsm(ll a, ll p)
{
ll s=1;
while(p)
{
if(p&1)
s=s*a%mod;
a=a*a%mod;
}
return s;
}
ll isprime(ll x)
{
if(x<2)
return 0;
for(int i=2;i<=x/i;i++)
if(x%i==0)
return 0;
return 1;
}
bool cmp(int x, int y){
return x>y;
}
const int N=3e6+10;
const int M =100000;
string a[N];
int ans[N];
char m[1050][1050];
void solve(){
int n,x;
string str,s=" ";
cin>>x;
n=1<<x;
// cout<<n;
// 把所有的的字符 放在一起
for(int i=1;i<=n;i++){
cin>>str;
s+=str; // 注意审题 是每四个字符为一组 把其输出
// cin>>a[i];
// int sum=0;
// for(int j=1;j<=n;j++){
// if(a[i][j]=='.')
// a[i][j]='0';
// else a[i][j]='1';
// if(a[i][j]=='1'){
// sum+=1<<(n+1-i);
// }
// }
// cout<<sum<<" ";
// //ans[i]=sum;
}
// cout<<s;
int len=s.size(); // 求出总的长度
// cout<<len;
for(int i=1;i<=len-1;i+=4){
int sum=0;
// cout<<s[i]<<" ";
sum+=(s[i]=='#')*(1<<3)+(s[i+1]=='#')*(1<<2)+(s[i+2]=='#')*(1<<1)+(s[i+3]=='#')*(1<<0);
cout<<sum<<" ";
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int _=1;
//cin>>_;
while(_--)
{
solve();
}
return 0;
}
// 活动地址: 牛客春招刷题训练营 - 编程打卡活动
上海得物信息集团有限公司公司福利 1166人发布
查看13道真题和解析