CF1767D Playoff(递推)

Playoff - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

Problem - D - Codeforces

读入n,代表有2^n个队伍参加比赛,每次相邻的两个队比赛,字符串中0->分低的胜利,1->分高的胜利路
对于a<b<c<d;字符串是01或者10,可以发现都只有b,c可以赢得比赛,字符串中01的顺序对答案没有影响
1的个数x->使得前[1,2^x)都会被淘汰掉
0的个数y->使得后面(2^n-2^y+1,2^n]都被淘汰掉
最终留下[2^x,2^n - 2^y +1 ]
#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值