CF1774C Ice and Fire
CF1774C Ice and Fire
题目描述
Little09 and his friends are playing a game. There are players, and the temperature value of the player is .
The types of environment are expressed as or . When two players fight in a specific environment, if its type is , the player with a lower temperature value in this environment always wins; if it is , the player with a higher temperature value in this environment always wins. The types of the environments form a binary string with a length of .
If there are players participating in the game, there will be a total of battles, and the types of the environments will be the first characters of . 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 is .
For each from to , answer the following question: if all players whose temperature value does not exceed participate in the game, how many players have a chance to win?
分析
这道题需要手玩数据。
我们发现,01 串结尾的连续个相同字符,并不影响游戏结果,也就是不会增加可能的人数。因为场地是按顺序使用的,设结尾连续长度为 ,我们经过前 场比赛之后的剩余人数为 集合,那么剩下的连续字符一定会选出 中的最大值或最小值。
那么可能情况的改变就在连续段之前,如果最后连续段是 最后会选出最小值,则前面需要删掉最小值才能改变最终结果。
#include <bits/stdc++.h>
#define rei register int
#define ll long long
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i, s, n, c) for (register int i = s; i <= n; i+=c)
#define repd(i, s, n, c) for (register int i = s; i >= n; i-=c)
#define CHECK cout<<"WALKED"<<endl;
inline int read(){int x=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0' && ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();return x*f;}
#define pb push_back
#define ls id<<1
#define rs id<<1|1
const int INF = INT_MAX;
long long binpow(long long a, long long b, ll mod){long long res = 1; while (b > 0){if (b & 1) res = res * a % mod;a = a * a % mod; b >>= 1; } return res;}
using namespace std;
int main()
{
int T = read();
while (T--) {
int n, k = 1; string s;
cin >> n >> s;
s = "**" + s;
cout << 1 << " ";
for (int i = 3; i < (int)s.size(); i++) {
if (s[i] == s[i - 1])
k++;
else
k = 1;
printf("%d ", i - k);
}
printf("\n");
}
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!