题目大意
读入 ,代表有 个队伍参加比赛,每次相邻的两个队比赛,字符串中 0 表示分低的胜利,1 表示分高的胜利。
解题思路
对于 :字符串是 01 或者 10,可以发现都只有 可以赢得比赛,字符串中 01 的顺序对答案没有影响。
1的个数 :使得前 都会被淘汰掉;0的个数 :使得后面 都被淘汰掉;
最终留下 。
AC 代码
#include <bits/stdc++.h>
#define x first
#define int long long
#define y second
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<char,int> PCI;
typedef pair<LL,LL> PLL;
//typedef __int128 i128;
typedef unsigned long long ULL;
const int N=2e5+10,INF = 1e9 ,mod = 1e9 + 7 ,P = 131;
const double eps = 1e-7;
int p[N],q[N];
vector<int> pos[N];
int n;
void solve()
{
string s;
cin >> n >> s ;
int k = count(s.begin(),s.end(),'1');
for(int x = 1 << k ;x <= (1<<n) - (1<<(n-k)) + 1;x ++ )
cout << x << " ";
}
signed main()
{
// freopen("1.txt","r",stdin);
ios
LL T=1;
// cin>>T;
while(T -- )
{
solve();
}
return 0;
}