思路:直接暴力判断就OK了

 #include<bits/stdc++.h>

 using namespace std;
#define int long long signed main(){
int _;cin>>_;
while(_--){
string str;
cin>>str;
if(str.size()==){
if(str[]!='?'){
cout<<str<<'\n';
}else{
printf("a\n");
}
continue;
}
int flag=;
for(int i=;i<str.size();i++){
if(str[i]=='?'){
int temp1=;int temp2=;
if(i->=){
if(str[i-]=='a'){
temp1=;
}else if(str[i-]=='b'){
temp1=;
}else if(str[i-]=='c'){
temp1=;
}else{
temp1=-;
}
}
if(i+<str.size()){
if(str[i+]=='a'){
temp2=;
}else if(str[i+]=='b'){
temp2=;
}else if(str[i+]=='c'){
temp2=;
}else{
temp2=-;
}
}
if(temp1==-&&temp2==-){
str[i]='a';
}else if(temp1==temp2){
if(temp1==){
str[i]='b';
}else if(temp1==){
str[i]='a';
}else if(temp1==){
str[i]='a';
}
}else{
map<int,int> vis;
vis[temp1]=;
vis[temp2]=;
int F=;
for(int i=;i<=;i++){
if(!vis[i]){
F=i;
break;
}
}
if(F==){
str[i]='a';
}else if(F==){
str[i]='b';
}else if(F==){
str[i]='c';
}
}
}
}
for (int i=;i<str.size()-;i++){
if(str[i]==str[i+]){
flag=;
break;
}
}
if(flag){
cout<<"-1"<<'\n';
continue;
}else{
cout<<str<<'\n';
}
}
return ;
}

思路:经过观察发现,排序后只要每个数对应的id是连续的就符合条件。

 #include<bits/stdc++.h>
#include<queue>
using namespace std;
#define int long long
#define N 1005000
#define inf 0x3f3f3f3f3f3f
struct str{
int num;
int id;
}st[N];
int ans[N];
bool cmp(str a,str b){
return a.num<b.num;
}
deque<int> q; // 维护最小值和最大值
signed main(){
int _;
cin>>_;
while(_--){
int n;
cin>>n;
ans[]=;
ans[n]=;
for(int i=;i<=n;i++){
scanf("%lld",&st[i].num);
st[i].id=i;
}
sort(st+,st++n,cmp);
/*
for(int i=1;i<=n;i++){
printf("%lld %lld\n",st[i].num,st[i].id);
}
*/
int minx=inf;
int maxn=(-)*inf;
minx=min(st[].id,minx);
maxn=max(maxn,st[].id);
for(int i=;i<n;i++){
minx=min(st[i].id,minx);
maxn=max(maxn,st[i].id);
int dis=;
dis=maxn-minx+;
if(i==dis){
ans[i]=;
}else{
ans[i]=;
} }
for(int i=;i<=n;i++) printf("%lld",ans[i]);
printf("\n");
for(int i=;i<=n+;i++){
ans[i]=;
st[i].id=;st[i].num=;
}
}
return ;
}

思路:题目对于g有大小限制而s和b之间没有,则我们让g尽可能小就好了,即选解题数最高的那一组选手全部发金牌,然后发银牌,直到g>s,剩下的选手全部发铜牌,直到发的牌数恰好小于n/2即可,做不到则不可行。【模拟一下】

 #include<bits/stdc++.h>

 using namespace std;
#define int long long
#define N 1050025
#define inf 0x3f3f3f3f3f
int arr[N];
signed main(){
int _;cin>>_;
while(_--){
int n;
cin>>n;
int g=,s=,b=;
for(int i=;i<=n;i++){
scanf("%lld",&arr[i]);
}
if(n<){
cout<<"0 0 0\n";
continue;
}
int maxn_sum=n/;
int avg=maxn_sum/;
int sum_g=;int sum_s=;int sum_b=;
int now=;
for(int i=;i<=n&&i<=maxn_sum;i++,now++){
if(arr[i]==arr[i+]){
sum_g++;
}else{
break;
}
}
g=sum_g;
for(int i=now+;i<=n&&i<=maxn_sum;i++,now++){
if(sum_s<=sum_g){
sum_s++;
}else{
if(arr[i]==arr[i+]){
sum_s++;
}else{
break;
}
}
}
s=sum_s;
sum_b=maxn_sum-g-s;
b=sum_b;
if(sum_b<=g){
printf("0 0 0\n");
continue;
}
if(arr[maxn_sum]==arr[maxn_sum+]){
for(int i=maxn_sum;i>=;i--){
if(arr[i]==arr[i-]){
b--;
}else{
b--;
break;
}
}
}
if(b<=g||b<=||s<=||g<=||s<=g){
printf("0 0 0\n");
continue;
}else{
printf("%lld %lld %lld\n",g,s,b);
} }
return ;
}

D题待补。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。

Codeforces Round #604 (Div. 2) A,B,C【D题待补】的更多相关文章

  1. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  2. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  3. Codeforces Round #604(Div. 2,

    // https://codeforces.com/contest/1265/problem/D /* 感觉像是遍历的思维构造题 有思路就很好做的 可以把该题想象成过山车或者山峰...... */ # ...

  4. Codeforces Round #604 (Div. 2) E. Beautiful Mirrors

    链接: https://codeforces.com/contest/1265/problem/E 题意: Creatnx has n mirrors, numbered from 1 to n. E ...

  5. Codeforces Round #604 (Div. 2) D. Beautiful Sequence(构造)

    链接: https://codeforces.com/contest/1265/problem/D 题意: An integer sequence is called beautiful if the ...

  6. Codeforces Round #604 (Div. 2) C. Beautiful Regional Contest

    链接: https://codeforces.com/contest/1265/problem/C 题意: So the Beautiful Regional Contest (BeRC) has c ...

  7. Codeforces Round #604 (Div. 2) B. Beautiful Numbers

    链接: https://codeforces.com/contest/1265/problem/B 题意: You are given a permutation p=[p1,p2,-,pn] of ...

  8. Codeforces Round #604 (Div. 2) A. Beautiful String

    链接: https://codeforces.com/contest/1265/problem/A 题意: A string is called beautiful if no two consecu ...

  9. Codeforces Round #604 (Div. 2) E. Beautiful Mirrors 题解 组合数学

    题目链接:https://codeforces.com/contest/1265/problem/E 题目大意: 有 \(n\) 个步骤,第 \(i\) 个步骤成功的概率是 \(P_i\) ,每一步只 ...

  10. Codeforces Round #604 (Div. 2) 部分题解

    链接:http://codeforces.com/contest/1265 A. Beautiful String A string is called beautiful if no two con ...

随机推荐

  1. Detecting GAN-generated Imagery using Color Cues

    Abstract     论文创新点:分析流行GAN网络结构得知,GAN网络生成得图片在颜色处理与真实摄像机拍摄的照片存在不同,主要表现在两方面.     实验结果:证明了两种线索能够有效区分GAN生 ...

  2. ORACLE存储过程,循环语法和游标

    1.定义所谓存储过程(Stored Procedure),就是一组用于完成特定数据库功能的SQL语句集,该SQL语句集经过编译后存储在数据库系统中.在使用时候,用户通过指定已经定义的存储过程名字并给出 ...

  3. java之struts2的数据处理

    这里的数据处理,指的是页面上的数据与Action中的数据的处理. struts2中有3种方式来接收请求提交的数据.分别是:属性驱动方式.对象驱动方式.模型驱动方式 1. 属性驱动方式 要求页面中的表单 ...

  4. 移动端vue2.5去哪儿项目-常见问题整理

    一.项目中遇到的问题.难点及解决方式 1. 移动端开发中的1px边框问题,由于在不同设备屏幕上,可能会使得1px实际在移动端显示不是1px,怎么解决? 2. 移动端click点击事件,会延迟300ms ...

  5. django AJAX 的应用

    目录 AJAX 的使用 AJAX简介 AJAX常见应用情景 AJAX的优缺点 jQuery实现的AJAX JS实现AJAX AJAX请求如何设置csrf_token Form表单上传文件 AJAX上传 ...

  6. Matlab相关函数使用

    1.cat:拼接两个数组.

  7. iOS pushViewController 和 presentViewController的区别 详解

    pushViewController 导航控制器入栈的方式切换页面presentViewController 模态切换的方式切换页面 1:用 UINavigationController 的时候用 p ...

  8. 【hadoop】MapReduce分布式计算框架原理

    PS:实操部分就省略了哈,准备最近好好看下理论这块,其实我是比较懒得哈!!! <?>MapReduce的概述 MapReduce是一种计算模型,进行大数据量的离线计算.MapReduce实 ...

  9. oracle 设置归档日模式

    首先关闭ORACLE SQL> shutdown immediate 把ORACLE启动为MOUNT模式 SQL:>startup mount sql:> alter databas ...

  10. spark 机器学习 随机森林 实现(二)

    通过天气,温度,风速3个特征,建立随机森林,判断特征的优先级结果 天气 温度 风速结果(0否,1是)天气(0晴天,1阴天,2下雨)温度(0热,1舒适,2冷)风速(0没风,1微风,2大风)1 1:0 2 ...