首页 > 其他分享 >Ice and Fire

Ice and Fire

时间:2023-07-22 10:33:11浏览次数:37  
标签:temperature players Fire Ice environment player value test

Ice and Fire time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output

Little09 and his friends are playing a game. There are n players, and the temperature value of the player i is i.

The types of environment are expressed as 00 or 11. When two players fight in a specific environment, if its type is 00, the player with a lower temperature value in this environment always wins; if it is 11, the player with a higher temperature value in this environment always wins. The types of the n−1−1 environments form a binary string s with a length of n−1−1.

If there are x players participating in the game, there will be a total of x−1−1 battles, and the types of the x−1−1 environments will be the first x−1−1 characters of s. While there is more than one player left in the tournament, choose any two remaining players to fight. The player who loses will be eliminated from the tournament. The type of the environment of battle i is si.

For each x from 22 to n, answer the following question: if all players whose temperature value does not exceed x participate in the game, how many players have a chance to win?

Input

Each test contains multiple test cases. The first line contains a single integer t (1≤t≤1031≤≤103)  — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer n (2≤n≤2⋅1052≤≤2⋅105)  — the number of players.

The second line of each test case contains a binary string s with a length n−1−1.

It is guaranteed that the sum of n over all test cases does not exceed 3⋅1053⋅105.

Output

For each test case output n−1−1 integers  — for each x from 22 to n, output the number of players that have a chance to win.

Example input Copy 2 4 001 4 101 output Copy
1 1 3 
1 2 3 
Note

In the first test case, for x=2=2 and x=3=3, only the player whose temperature value is 11 can be the winner. For x=4=4, the player whose temperature value is 2,3,42,3,4 can be the winner.

#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+10,mod=1e9+7;
string s;
int n,t,a[N],f[N],res,num,ans,m;
bool vis[N];
signed main()
{
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>t;
    while(t--){
        cin>>n>>s;
        int one=0,zero=0,res=1;
        for(int i=0;i<s.size();i++){
            if(s[i]=='1') one++,zero=0;
            else one=0,zero++;
            cout<<i+2-max(one,zero)<<" ";
        }
    }
    return 0;
}

 

标签:temperature,players,Fire,Ice,environment,player,value,test
From: https://www.cnblogs.com/o-Sakurajimamai-o/p/17572945.html

相关文章

  • SQL SERVER ANALYSIS SERVICES决策树、聚类、关联规则挖掘分析电商购物网站的用户行为
    全文链接:http://tecdat.cn/?p=32118最近我们被客户要求撰写关于电商购物网站的用户行为的研究报告,包括一些图形和统计输出。假如你有一个购物类的网站,那么你如何给你的客户来推荐产品呢? ( 点击文末“阅读原文”获取完整文档、数据 )这个功能在很多电商类网站都有,那么,通过SQLS......
  • renice
    renice修改正在运行的进程的调度优先级补充说明renice命令可以修改正在运行的进程的调度优先级。预设是以程序识别码指定程序调整其优先权,您亦可以指定程序群组或用户名称调整优先权等级,并修改所有隶属于该程序群组或用户的程序的优先权。只有系统管理者可以改变其他用户程序......
  • Android No space left on device
    Android设备上的“无可用空间”问题在使用Android设备时,你可能会遇到一个常见的问题:设备上的存储空间不足。当你尝试安装或更新应用程序、拍摄照片、录制视频或下载文件时,你可能会收到一个错误消息:“无可用空间”。本文将解释这个问题的原因,并提供一些解决方案。原因Android设备......
  • Vue+springboot集成PageOffice实现在线编辑Word、excel文档
    说明:PageOffice是一款在线的office编辑软件,帮助Web应用系统或Web网站实现用户在线编辑Word、Excel、PowerPoint文档。可以完美实现在线公文流转,领导批阅,盖章。可以给文件添加水印,在线安全预览防止用户下载和复制文件等一、环境要求前端Vue项目:Node.js10及以上版本(当前集成方式......
  • 避免在Service层写脆弱的测试
     1、简述有很多方法可以测试Service层。本文的目标是展示一种隔离的测试方式:将于数据库交互的整个逻辑都Mock掉。示例使用了Spring作为依赖注入、JUnit、Hamcrest、Mockito。 2、分层典型的Javaweb应用都在DAO/DAL层之上有一个服务层,DAO/DAL层负责调用原生的持久层逻辑。 Servi......
  • service
    service控制系统服务的实用工具补充说明service命令是RedhatLinux兼容的发行版中用来控制系统服务的实用工具,它以启动、停止、重新启动和关闭系统服务,还可以显示所有系统服务的当前状态。语法service(选项)(参数)选项-h:显示帮助信息;--status-all:显示所服务的状态。参......
  • 转载:PageOffice 在线打开 word 文件实现痕迹保留、键盘批注、手写批注
    一、痕迹保留Word中的痕迹一般指的是审阅文档的用户对文档所做的修改(插入和删除)操作。在PageOffice的强制留痕模式下,用户对文档所做的任何修改都会以痕迹的形式保留下来,不同用户对文档做的修订会自动用不同的颜色标记;用户不能接受、拒绝其他用户对此文档所做的任何修订;修......
  • golang slice (切片) 扩容机制详解(1.18版本后)
    slice源码定义:typeslicestruct{ arrayunsafe.Pointer//指向底层数组的指针 lenint//切片长度 capint//切片容量}growslice()方法:用于slice的扩容funcgrowslice(et*_type,oldslice,capint)slice{//...... newcap:=old.cap doubleca......
  • docker “no space left on device”
     1、先使用dockerinfo查看docker的信息dockerinfo可以看到docker的根路径是 /var/lib/docker  2、查看docker根路径的磁盘占用率df-Th/var/lib/docker3、清理docker 方法一:删除所有未运行的容器(已经运行的删除不了,未运行的就一起被删除了)dockerrm$(docker......
  • firewalld防火墙设置
    #!/bin/bash#基础信息hostname=`hostname`date=`date"+%Y-%m-%d%H:%M:%S"`#输入处理-判断端口check_newport(){while[[true]];doread-p"请输入开放端口(1-65535):"newport;if[[-n$newport]];thenifgrep'^[[:digit:]]*$'......