Crusaders Quest ZOJ - 3983(思维+暴力)

2017CCPC秦皇岛H(二分 + 二分图的最大匹配数) Prime Set Time Limit: 2 Seconds      Memory Limit: 131072 KB Given an array of  integers , we say a set  is a prime set of the given array, if  and  is prime. BaoBao has just found an arr 阅读详情

Crusaders Quest ZOJ - 3983

Crusaders Quest is an interesting mobile game. A mysterious witch has brought great darkness to the game world, and the only hope for your kingdom is to save the Goddesses so that they can unleash their power to fight against the witch.
在这里插入图片描述
In order to save the game world, you need to choose three heroes to fight for victory and use their skills wisely. Nine skill blocks of three different types (three blocks per type) will be presented at the bottom of the screen. If () consecutive blocks are of the same type, you can tap on them and eliminate them, thus triggering the powerful skill they represent. After the elimination, the blocks to their left will be connected with the blocks to their right. Moreover, if consecutive blocks of the same type are eliminated, the powerful skill they unleash will be upgraded to a super skill, which is the most powerful skill of all.

DreamGrid is a newbie in this game, and he wants to trigger the super skill as many times as he can. Given nine skill blocks satisfying the description above, please help DreamGrid calculate the maximum number of times he can trigger the super skill.
Input

There are multiple test cases. The first line of input contains an integer (about 50), indicating the number of test cases. For each test case:

The first line contains a string () consisting of three 'g’s, three 'a’s and three 'o’s, representing the nine skill blocks of three different types. Each type of character represents one type of skill block.
Output
For each test case, output an integer denoting the maximum number of times DreamGrid can trigger the super skill.
Sample Input

7
gggaaaooo
aaoogggoa
googgaaao
agogaooag
goooggaaa
gogogoaaa
gaogaogao

Sample Output

3
3
2
1
3
2
1

Hint

For the first sample test case, DreamGrid can first eliminate “aaa” (one super skill triggered), thus changing the skill blocks to “gggooo”. He can then eliminate “ggg” (another super skill triggered) and finally eliminate “ooo” (a third super skill triggered). So the answer is 3.

For the second sample test case, DreamGrid can first eliminate “ggg” (one super skill triggered), thus changing the skill blocks to “aaoooa”. He can then eliminate “ooo” (another super skill triggered) and finally eliminate “aaa” (a third super skill triggered). So the answer is also 3.

For the third sample test case, DreamGrid can first eliminate “aaa” (one super skill triggered), thus changing the skill blocks to “googgo”. He can then eliminate “oo” to obtain “gggo”, and eliminate “ggg” (another super skill triggered) to obtain “o”. So the answer is 2. It is easy to prove that he cannot trigger the super skill three times under this arrangement of skill blocks.

#include <bits/stdc++.h>
using namespace std;
int getcnt(string &tmp){//先删除原有的连续的三个字符
    int a = 0,t = 0;
    while(tmp.length() && t < 3){
        t++;
        if(tmp.find("aaa",0) != string::npos){
            tmp.erase(tmp.find("aaa",0),3);
            a++;
        }
        else if(tmp.find("ggg",0) != string::npos){
            tmp.erase(tmp.find("ggg",0),3);
            a++;
        }
        else if(tmp.find("ooo",0) != string::npos){
            tmp.erase(tmp.find("ooo",0),3);
            a++;
        }
    }
    return a;
}

int del(char c,string tmp){//假设删去一种字符后,在看是否有连续的可以被消除
    int f = 0;
    int len = tmp.length();
    for(int i = 0; i < len; ){
        if(tmp[i] == c) tmp.erase(i,1), f++;
        else i++;
    }
    if(f){
        int p = getcnt(tmp);
        if(p == 0) return 1;
        else return p;
    }
    else return 0;
}
int main(){
    int t;
    scanf("%d",&t);
    while(t--){
        string s;
        int ans = 0;
        cin >> s;
        ans += getcnt(s);
        if(ans != 3)
            ans += max(max(del('a',s),del('o',s)),del('g',s));
        printf("%d\n",ans);
    }
    return 0;
}

Keras回归实战:波士顿房价预测从数据加载到模型调参 回归任务在机器学习中用于预测连续值,其核心在于最小化预测值与真实值的误差,常用均方误差(MSE)作为损失函数。与分类任务不同,回归输出层无需激活函数,且特征标准化对梯度下降的稳定性至关重要。在工程实践中,回归广泛应用于房价预测、销量预估等场景。以波士顿房价数据集为例,虽因伦理问题被scikit-learn移除,但可通过fetch_openml获取。使用Keras构建回归网络时,需注意输出层设计、损失函数选择及回调机制,如EarlyStopping和ReduceLROnPlateau,以提升模型泛化能力。 阅读详情

相关推荐

安装m_map以及用matlab绘制高精度海岸线地图

#如何用matlab绘制高精度海岸线地图

qq_38512775的博客 1万+

2017秦皇岛CCPC G - Numbers(大数,贪心)

G - Numbers :http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3987 题目描述: 将nnn分成至多mmm个非负整数,a1a1a1 a2a2a2 ......... akakak (k≤m)(k \leq m)(k≤m),使得a1a1a1 ororor a2a2a2 ororor ......... oro...

weixin_41671231的博客 613

ollama环境变量配置:修改ollama的数据路径(安装路径)

ollama安装模型,如果很大,会占用C盘空间,影响系统运行速度,通过设置环境变量,来改变ollama放目录的地址。

正经教主是个热衷于正经学习分享的教主。 1万+

2017 CCPC 秦皇岛 G题

题意 给定非负整数n, m(n ∑i=1mai=n(ai>=0) 且使  a1 or a2 or a3 … or am最小 题解 1.对于任意i in [1, m]  a1 or a2 or a3 … or am >= ai  当n % m == 0时, 只要存在i in [1, m] ai  必存在i in [1, m],ai 

zcc的博客 395

工业数据采集实战:用open62541库读写PLC的OPC UA节点(避坑指南)

本文详细介绍了如何使用open62541库实现工业PLC的OPC UA节点数据采集,涵盖环境搭建、节点读写优化及生产环境故障排查。通过订阅模式和多节点读写技术,显著提升数据采集效率与稳定性,适用于智能制造和工业物联网场景。

weixin_30598225的博客 399

2023年金蝶云星辰初级顾问认证参考试题(1)

最新积累的考试真题,答案只供参考(49分T~T),欢迎大佬们更正,私聊我修改,有新的试题也可以私聊我,日后会完善题库!大家一起努力,预祝大家顺利通过!1.【简单】生产环节中,客户老板希望掌握材料的超发或漏发情况,,以便分析用料情况,对材料浪费进行管控,可以查看什么报表?⒉[中等】客户主营电气柜的生产销售,商品为非标品需定制,又因交期效短,需要边生产边补料,以下哪个功能最适合该客户场景?15.【简单】在给商品设置科目关联时,分别按照单个商品,商品类别,所有商品设置了对应客户,()优先级最高。

MLX00的博客 7974

2017ccpc秦皇岛解题报告

C - Crusaders Quest 题目大意 给你999个字母,其中有333个aaa,333个ggg和333个ooo,你每次可以将相同且相邻的111~333个字母消去,问你消去连续相同且相邻的三个字母的次数最大是多少 Sample Input 7 gggaaaooo aaoogggoa googgaaao agogaooag goooggaaa gogogoaaa gaogaogao Sample Output 3 3 2 1 3 2 1 解题思路 考虑消去的字母的先后顺序为A33=6A_{3}^{

weixin_44211980的博客 604

炼丹-Pyecharts: JupyterLab无法render_notebook

炼丹-Pyecharts: JupyterLab无法render_notebook问题描述Jupyter-Lab 环境下render_notebook显示空白 问题描述Jupyter-Lab 环境下render_notebook显示空白 首先需要使用pyecharts自带的config来申明一下使用pyecharts的运行环境 from pyecharts.globals import Curre...

MichaelZzzzz的博客 4688

2017 CCPC 秦皇岛 C - Crusaders Quest 【暴力||分类】

Crusaders Quest is an interesting mobile game. A mysterious witch has brought great darkness to the game world, and the only hope for your kingdom is to save the Goddesses so that they can unleash thei

Irish_Moonshine的博客 531

《Sigrity SystemSI 2023+LPDDR4仿真自学笔记》(一)创建工程(Part1)

为了加强SystemSI 2023软件的熟悉度,咱们完整的走一个仿真全流程。

weixin_45199544的博客 6334

【Unity程序技巧】Unity中单例模式管理器

单例模式(Singleton Pattern)是 最简单的设计模式之一

秩沅 1657

2017CCPC秦皇岛 C:Crusaders Quest

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3983 签到题: 题意: 给你9个字母,其中'g' 'a' 'o'各三个,你可以选择其中一个字母,然后 ①这个字母和相邻的相同的字母全部消去 ②后面的字母会往前移动 举个例子: aaooggg

zcc的博客 693

【时时三省】vector cast 常见错误解决/vcast常见错误解决

介绍在使用 vector cast/vcast 软件的过程中,遇到的异常问题。其它异常可以私信解决(购买专栏的前提下)。

时时三省的博客 449

2017 CCPC秦皇岛 D

考虑到对于一个联通块,最后一个加的点一定是度数最大的点,并且度数是联通块的siz-1。而把这个点删掉之后的图,因为每个点的度数同减一,依然满足上述性质。于是反过来想可以发现,若有解,则将最终度数从小到大依次加入图的方案一定是一组解。判断这种加点方式是否成立即可。用并查集维护联通性。#include <bits/stdc++.h> using namespace std; const int maxn

ACM, deep love 687

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

ZOJ 3987 Numbers 2017CCPC秦皇岛站G题 大整数 二进制 贪心

题目:https://cn.vjudge.net/problem/ZOJ-3987题意:给出一个数n(不超过4000个十进制数字),将其分成m(不超过10的100次方)个数,要求这m个数的和等于n。求这m个数最小可能的按位或的值。思路:按位或的特点是这m个数如果在某一个二进制位上有一个为1的,那么最终结果在那一位就会是1,所以我们想要尽可能的让高位上没有1,而且只要有一位上确定必须是1,就尽可能利用

Rewriter_huanying的博客 825

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

2017秦皇岛ccpc G(大数除法、取余+均分)

题目链接:传送门 参考文章 题目: 输入一个n,m求出 序列ai,满足Σai = n,最终使序列ai序列或值最小。 思路: 1、考虑将n均分为m个数字 2、考虑特殊情况n = 314,m = 10; 此时如果均分为32,31,但是32|31 = 63,因为从n/m到n/m+1的二进制数字进位了,所以这样分并不能使最终或值最小。 可以对每次的除数x = n/m+1,然后判断x二进制数字是不是等于2^k; (1)如果x == 2^k,分配2 ^ k数字,防止进位导致过大; eg:给314分配(314/32)个3

积少成多,水滴石穿 267

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

ZOJ - 3983 - Crusaders Quest(DFS)

Crusaders Quest Time Limit: 1 Second      Memory Limit: 65536 KB Crusaders Quest is an interesting mobile game. A mysterious witch has brought great darkness to the game world, and the only ho

vloai 392

2017 ccpc 秦皇岛C Crusaders Quest

https://vjudge.net/contest/203034#problem/C 给出一行9个字符,分别是3个g,3个a,3个o,每次操作可以去掉其中的一种字符,并把剩余的字符再连起来,如果去掉的3个字符是连在一起的即算作一次得分,问最多能得多少分。 模拟即可,因为结果只有1,2,3 3种情况,模拟去掉的字符种类即可。 #incl

三水的鱼塘♂ 447

ZOJ 3983[思维/构造]

题目点击打开链接题意给一个字符串,其中只有a,o,g,当三个相同字符连在一起时释放大技能 我们可以消除任意连续数量的字符  问我们最大的释放大技能的数量是多少输入7 gggaaaooo aaoogggoa googgaaao agogaooag goooggaaa gogogoaaa gaogaogao 输出3 3 2 1 3 2 1 先找aaa/ggg/ooo,若没有满足的则从a--o--g,开...

Action_now的博客 598

2017秦皇岛ICPC - C - Crusaders Quest【思维+暴力】

Crusaders QuestTime Limit: 1 Second Memory Limit: 65536 KBCrusaders Quest is an interesting mobile game. A mysterious witch has brought great darkness to the game world, and the only hope for your

nobleman 2511

ZOJ3983+3992+3993

Crusaders Quest Time Limit: 1 Second      Memory Limit: 65536 KB Crusaders Quest is an interesting mobile game. A mysterious witch has brought great darkness to the game world, and the only hope

raptor 5132

zoj-3983

Crusaders QuestTime Limit: 1 Second      Memory Limit: 65536 KBCrusaders Quest is an interesting mobile game. A mysterious witch has brought great darkness to the game world, and the only hope for you...

yu121380的博客 414

2017CCPC秦皇岛(C、E、L、M)

C - Crusaders Quest #include<bits/stdc++.h> using namespace std; #define clr(a) memset(a, 0, sizeof(a)) #define line cout<<"-------------"<<endl typedef long long ll; const int ma...

辞树 676

【个人训练】(ZOJ3983)Crusaders Quest

题意分析 和祖玛类似的那种玩法。不过是限定了九个字符,问最好情况下有几次三连碰。 暴力穷举即可。具体的做法是,先把所有“成块”的字符记录下来,然后一个一个删,再继续这样子递归做下去。考虑到就只有9个字符,内存和时间的占用不会太高。 这里倒是遇到了盲点:之前不清楚erase的用法。 代码 #include <bits/stdc++....

weixin_30553837的博客 219

C - Crusaders Quest (栈和队列的运用)

滴答滴答---题目链接  Crusaders Quest is an interesting mobile game. A mysterious witch has brought great darkness to the game world, and the only hope for your kingdom is to save the Goddesses so that they c...

chen_zan_yu_的博客 452

Crusaders Quest ZOJ - 3983 构造|思维

题意给我们一个字符串 其中只有a,o,g 当三个相同字符连在一起时释放大技能 我们可以消除任意连续数量的字符  问我们最大的释放大技能的数量是多少分析首先答案只能是 1 2 3 如果这个字符串中存在连续三个的我们可以直接消去 删掉 3个的情况就是三个通过删除的过程中可以形成或是已经就是三个的情况 直接删除 当我们在构造一个字符连着的三个时 我们需要删除这个字符中间的字符 那么如果我们要寻

qq_33859479的博客 723
上一篇: Uva12230Crossing Rivers (数学期望)
下一篇: Numbers ZOJ - 3987(二进制思维+贪心)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值