6342.Problem K. Expression in Memories

这个题就是把?变成其他的使得多项式成立并且没有前导零

官方题解:

没意思,好想咸鱼,直接贴一篇别人的博客,写的很好,比我的垃圾好多了。。。

HDU 6342(模拟)

贴一下一个队友的代码:

 //1011-6342-模拟
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;
typedef long long ll; const double PI=acos(-1.0);
const double eps=1e-;
const ll mod=1e9+;
const int inf=0x3f3f3f3f;
const int maxn=1e5+;
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0); int a[maxn];
char c[maxn]; int main()
{
int t;
scanf("%d",&t);
while(t--){
int flag=;
scanf("%s",c+);
int n=strlen(c+);
for(int i=;i<=n;i++){
if(c[i]>=''&&c[i]<='')
a[i]=;
else if(c[i]=='?')
a[i]=;
else
a[i]=;
if(i!=){
if(a[i]==&&a[i-]==){//++
flag=;
break;
}
}
}
if(c[]==''&&a[]==&&n>){//
if(c[]=='?'){
if(n>&&a[]==)
c[]='+',a[]=;
else
flag=;
}
else
flag=;
}
if(a[n]==||a[]==)//1+ +1
flag=;
for(int i=;i<=n;i++){
if(a[i-]==&&c[i]==''&&a[i+]==&&i>&&i<n){
if(c[i+]!='?'){//
flag=;
break;
}
else if(c[i+]=='?'&&i+>=n){//0?
flag=;
break;
}
}
if(a[i-]==&&c[i]==''&&c[i+]=='?'&&i>&&i+<n){
if(a[i+]==){//0?0
c[i+]='+';
a[i+]=;
}
else{//0?+
flag=;
break;
}
}
}
if(flag)
printf("IMPOSSIBLE\n");
else{
for(int i=;i<=n;i++){
if(c[i]=='?')
c[i]='';
printf("%c",c[i]);
}
cout<<endl;
}
}
}

我发现我的模拟题都写得相当垃圾。。。

垃圾滚了。。。

HDU 6342.Problem K. Expression in Memories-模拟-巴科斯范式填充 (2018 Multi-University Training Contest 4 1011)的更多相关文章

  1. 2018 Multi-University Training Contest 4 Problem K. Expression in Memories 【模拟】

    任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6342 Problem K. Expression in Memories Time Limit: 200 ...

  2. 杭电多校第四场 Problem K. Expression in Memories 思维模拟

    Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262 ...

  3. HDU6342-2018ACM暑假多校联合训练4-1011-Problem K. Expression in Memories

    Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262 ...

  4. @hdu - 6329@ Problem K. Transport Construction

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定 n 个点,第 i 个点位于 (xi, yi). 在第 i ...

  5. hdu 3038 How Many Answers Are Wrong(种类并查集)2009 Multi-University Training Contest 13

    了解了种类并查集,同时还知道了一个小技巧,这道题就比较容易了. 其实这是我碰到的第一道种类并查集,实在不会,只好看着别人的代码写.最后半懂不懂的写完了.然后又和别人的代码进行比较,还是不懂,但还是交了 ...

  6. 2015 Multi-University Training Contest 8 hdu 5390 tree

    tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...

  7. 2015 Multi-University Training Contest 7 hdu 5379 Mahjong tree

    Mahjong tree Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  8. Western Subregional of NEERC, Minsk, Wednesday, November 4, 2015 Problem K. UTF-8 Decoder 模拟题

    Problem K. UTF-8 Decoder 题目连接: http://opentrains.snarknews.info/~ejudge/team.cgi?SID=c75360ed7f2c702 ...

  9. 2017 Multi-University Training Contest - Team 9 1004&&HDU 6164 Dying Light【数学+模拟】

    Dying Light Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Tot ...

随机推荐

  1. javasisst & JAVA8

    今天在服务器上启动tomcat7的时候,提示如下异常: java.io.IOException: invalid constant type: 15 具体看是javasisst抛出来的. 系统运行环境 ...

  2. hdu 1598 find the most comfortable road (并查集)

    find the most comfortable road Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

  3. BZOJ 3262: 陌上花开 CDQ

    这个题大部分人用了离散然后水之,然而.....作为一只蒟蒻我并没有想到离散,而是直接拿两个区间一个对应n,一个对应k来搞,当然这两个区间是对应的,我把第一维排序,第二维CDQ,第三维树状数组,然而由于 ...

  4. BZOJ 4777 Usaco2017 Open Switch Grass Kruskal+替罪羊树+权值线段树

    这道题首先可以看出答案一定是一条边,而且答案一定在最小生成树上,那么我们就可以在这个最小生成树上维护他与异色儿子的边最小值,所以我们就可以已通过Kruskal和一棵平衡树来解决,时间复杂度是O(n*l ...

  5. OpenJudge百炼-2747-数字方格-C语言-枚举

    描述:如上图,有3个方格,每个方格里面都有一个整数a1,a2,a3.已知0 <= a1, a2, a3 <= n,而且a1 + a2是2的倍数,a2 + a3是3的倍数, a1 + a2 ...

  6. xiaoluo同志Linux学习之CentOS6.4

    小罗同志写的不错,弄个列表过来啊   Linux学习之CentOS(三十六)--FTP服务原理及vsfptd的安装.配置 xiaoluo501395377 2013-06-09 01:04 阅读:56 ...

  7. 1、linux下mysql5.5.20安装过程报错汇总

    1.Access denied for user 'root'@'localhost' (using password: YES) 这个提示是因为root帐户默认不开放远程访问权限,所以需要修改一下相 ...

  8. 播放video

    <html> <head> <title> four in one vedio</title> <style type="text/cs ...

  9. LOJ 6057 - [HNOI2016]序列 加强版再加强版

    Description 给定一个长度为 \(n\le 3*10^6\) 的序列 \(q\le 10^7\) 次询问每次求区间 \([l,r]\) 的所有子区间的最小值的和 询问随机 Solution ...

  10. 【BZOJ2338】【HNOI2011】数矩形 [计算几何]

    数矩形 Time Limit: 20 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description 最近某歌手在研究自己的全国巡回演出, ...