当前位置: 首页 > news >正文

手机怎么自创网站宁德seo培训

手机怎么自创网站,宁德seo培训,绍兴做网站价格,武汉定制网页设计ABC322刷题记 T1.A A - First ABC 2。 妥妥的简单题…… 用find函数做就行。(如果不存在那个子串就返回-1,否则返回第一次出现位置) 注意题目中编号是从1开始的。 时间复杂度:O(log(n))。find函数有一定代价,我记…

ABC322刷题记

T1.A

A - First ABC 2。

妥妥的简单题……

用find函数做就行。(如果不存在那个子串就返回-1,否则返回第一次出现位置)

注意题目中编号是从1开始的。

时间复杂度:O(log(n))。find函数有一定代价,我记得是log。

#include<bits/stdc++.h>
using namespace std;
string str="";
int n=0;
int main(){
    scanf("%d",&n);
    cin>>str;
    //输入
    str=" "+str;
    //处理:把0开头改成1开头
    printf("%d\n",str.find("ABC"));
    //输出答案
    return 0;
}

T2.B

B - Prefix and Suffix。

前两题都一样简单。

用substr截取出t中与s长度相同的前缀和后缀,分别和s比较即可。

时间复杂度先不算了,因为肯定够。

#include<bits/stdc++.h>
using namespace std;
int m=0,n=0;
string s="",t="";
int main(){
    scanf("%d%d",&n,&m);
    cin>>s>>t;
    //输入
    string front=t.substr(0,n),rear=t.substr(m-n,n);
    //去除前缀与后缀
    if(front==s&&rear==s){
        printf("0\n");
    }else{
        if(front==s&&rear!=s){
            printf("1\n");
        }else{
            if(front!=s&&rear==s){
                printf("2\n");
            }else{
                printf("3\n");
            }
        }
    }
    //对号入座,输出不错
    return 0;
}

T3.C

C - Festival。

还是辣墨简单……

用b数组记录某一天是否有烟花,在用ans数组从后往前算,其中ans[i]表示离第i天最近并且时间不比第i天早的放烟花的日子与第i天相差多少。

最后从1到n输出ans的对应项即可。

时间复杂度:O(n),应该是最优的思路了。

#include<bits/stdc++.h>
#define M 220000
#define N 220000
using namespace std;
int ans[N]={},a[M]={},m=0,n=0;
bool b[N]={};
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        scanf("%d",&a[i]);
        b[a[i]]=true;
    }
    //输入,并维护b数组
    for(int i=n;i>=1;i--){
        if(b[i]==true){
            ans[i]=0;
            //①当前这一天就有烟花:距离为0
        }else{
            ans[i]=ans[i+1]+1;
            //②当前这一天没有烟花:比明天的距离多一天
        }
    }
    //计算ans
    for(int i=1;i<=n;i++){
        printf("%d\n",ans[i]);
    }
    //输出答案
    return 0;
}

T4.D

D - Polyomino。

客观来说,我这道题没做出来真有些丢人。

其实就是一个dfs,但是一个变量名害我找了1天6小时34分钟……

我们定义一个结构体,存储一块牌,如果一个坐标上有点,就记录为1,否则记录为0。支持项各个方向平移(如果会出格,就返回不能做,否则返回操作成功)、顺时针旋转、逆时针旋转操作,当然还要封装加法(把骨牌拼接起来,其实就是相同坐标的点记录的数相加,如果相加后和为0,就说明这里本来就没有点,如果为1就说明刚好有一个牌上有,如果大于1就说明有多个牌子上面有这个点,当然,只有当3块牌都记起来之后和为1才能说明这种摆法可能合法)、等于号(骨牌完全相同,用于判断拼完之后是不是和满牌相同)。

在dfs中,我们不难证明先旋转(遍历旋转次数,去时顺时针,回时逆时针),在平移(反方向的平移互相作为返回操作)是不会有问题的,当然要注意平移可以项各种方向平移多次。

最终大体流程是这样:使用dfs,遍历三个牌的操作,如果最后拼起来是满牌就说明可以达成目的,直接标记最终答案为“可行”,并一路退出回到主程序,否则继续往下遍历。遍历操做时,先考虑旋转,再考虑平移。最后输出Yes/No即可。

时间复杂度不好算,这里不展开描述,但是数据量都是4、16这类数,估计也没啥事。

#include<bits/stdc++.h>
using namespace std;
struct Info{
    int num[4][4];
    Info operator+(Info ot){
        Info ret={};
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                ret.num[i][j]=num[i][j]+ot.num[i][j];
            }
        }
        return ret;
    }
    //拼接
    bool operator==(Info ot){
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                if(num[i][j]!=ot.num[i][j]){
                    return false;
                }
            }
        }
        return true;
    }
    //判等
    bool down(){
        for(int i=0;i<4;i++){
            if(num[3][i]==1){
                return false;
            }
        }
        for(int i=3;i>=1;i--){
            for(int j=0;j<4;j++){
                num[i][j]=num[i-1][j];
            }
        }
        for(int i=0;i<4;i++){
            num[0][i]=0;
        }
        return true;
    }
    //下移
    bool left(){
        for(int i=0;i<4;i++){
            if(num[i][0]==1){
                return false;
            }
        }
        for(int i=0;i<=2;i++){
            for(int j=0;j<4;j++){
                num[j][i]=num[j][i+1];
            }
        }
        for(int i=0;i<4;i++){
            num[i][3]=0;
        }
        return true;
    }
    //左移
    bool right(){
        for(int i=0;i<4;i++){
            if(num[i][3]==1){
                return false;
            }
        }
        for(int i=3;i>=1;i--){
            for(int j=0;j<4;j++){
                num[j][i]=num[j][i-1];
            }
        }
        for(int i=0;i<4;i++){
            num[i][0]=0;
        }
        return true;
    }
    //右移
    bool up(){
        for(int i=0;i<4;i++){
            if(num[0][i]==1){
                return false;
            }
        }
        for(int i=0;i<=2;i++){
            for(int j=0;j<4;j++){
                num[i][j]=num[i+1][j];
            }
        }
        for(int i=0;i<4;i++){
            num[3][i]=0;
        }
        return true;
    }
    //上移
    void spina(){
        Info ret={};
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                ret.num[i][j]=num[3-j][i];
            }
        }
        memcpy(num,ret.num,sizeof(num));
        return;
    }
    //顺时针旋转
    void spinb(){
        Info ret={};
        for(int i=0;i<4;i++){
            for(int j=0;j<4;j++){
                ret.num[i][j]=num[j][3-i];
            }
        }
        memcpy(num,ret.num,sizeof(num));
        return;
    }
    //逆时针旋转
};
Info inf[10]={};
bool ans=false;
inline void dfs(int d);
//深度优先搜索用到函数
inline void tmovew(int d);
//遍历旋转,用完后返回原始状态
inline void tmovex(int d);
//遍历横移,用完后返回原始状态
inline void tmovey(int d);
//遍历竖移,用完后返回原始状态
int main(){
    inf[4]={{{1,1,1,1},{1,1,1,1},{1,1,1,1},{1,1,1,1}}};
    //满牌
    for(int i=0;i<4;i++){
        string str="";
        cin>>str;
        for(int j=0;j<4;j++){
            if(str[j]=='#'){
                inf[1].num[i][j]=1;
            }
        }
    }
    for(int i=0;i<4;i++){
        string str="";
        cin>>str;
        for(int j=0;j<4;j++){
            if(str[j]=='#'){
                inf[2].num[i][j]=1;
            }
        }
    }
    for(int i=0;i<4;i++){
        string str="";
        cin>>str;
        for(int j=0;j<4;j++){
            if(str[j]=='#'){
                inf[3].num[i][j]=1;
            }
        }
    }
    //输入,并处理成Info格式
    dfs(1);
    //dfs
    if(ans==false){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    //根据答案输出
    return 0;
}
inline void dfs(int d){
    if(d==4){
        //3个骨牌遍历完成
        if(inf[1]+inf[2]+inf[3]==inf[4]){
            ans=true;
            //若相加为满牌,就说明答案可行,直接记录答案为“Yes”,或者说true
        }
        return;
        //递归出口
    }
    if(ans==true){
        return;
        //已经找到答案,无需继续遍历
    }
    tmovew(d);
    //开始遍历旋转
    return;
}
inline void tmovew(int d){
    for(int i=0;i<=3;i++){
        for(int j=1;j<=i;j++){
            inf[d].spina();
        }
        //顺时针旋转相应次
        tmovex(d);
        //往下遍历横移
        for(int j=1;j<=i;j++){
            inf[d].spinb();
        }
        //逆时针转回去(回溯)
    }
    return;
}
inline void tmovex(int d){
    for(int i=0;i<=4;i++){
        int sum=0;
        //尽最大可能地往相应方向移动i次,sum记录实际上操作成功的次数,后面所有的sum都同理
        for(int j=1;j<=i;j++){
            if(inf[d].left()==true){
                sum++;
            }
        }
        //往左移动
        tmovey(d);
        //往下遍历竖移
        for(int j=1;j<=sum;j++){
            inf[d].right();
        }
        //往右移动,也就是回溯
    }
    for(int i=0;i<=4;i++){
        int sum=0;
        for(int j=1;j<=i;j++){
            if(inf[d].right()==true){
                sum++;
            }
        }
        //往右移动
        tmovey(d);
        //往下遍历竖移
        for(int j=1;j<=sum;j++){
            inf[d].left();
        }
        //往左移动,也就是回溯
    }
    return;
}
inline void tmovey(int d){
    for(int i=0;i<=4;i++){
        int sum=0;
        for(int j=1;j<=i;j++){
            if(inf[d].down()==true){
                sum++;
            }
        }
        //往下移动
        dfs(d+1);
        //往下递归
        for(int j=1;j<=sum;j++){
            inf[d].up();
        }
        //往上移动,也就是回溯
    }
    for(int i=0;i<=4;i++){
        int sum=0;
        for(int j=1;j<=i;j++){
            if(inf[d].up()==true){
                sum++;
            }
        }
        //往上移动
        dfs(d+1);
        //往下递归
        for(int j=1;j<=sum;j++){
            inf[d].down();
        }
        //往下移动,也就是回溯
    }
    return;
}


文章转载自:
http://intracellular.tsnq.cn
http://wifie.tsnq.cn
http://wheeler.tsnq.cn
http://eclaircissement.tsnq.cn
http://pyometra.tsnq.cn
http://chilopod.tsnq.cn
http://hexobarbital.tsnq.cn
http://intenerate.tsnq.cn
http://gnosis.tsnq.cn
http://elevatory.tsnq.cn
http://ceti.tsnq.cn
http://hazily.tsnq.cn
http://vest.tsnq.cn
http://normanise.tsnq.cn
http://dermatologic.tsnq.cn
http://tefl.tsnq.cn
http://antianxiety.tsnq.cn
http://liveryman.tsnq.cn
http://psaltery.tsnq.cn
http://stapler.tsnq.cn
http://dioptometer.tsnq.cn
http://jabez.tsnq.cn
http://moraine.tsnq.cn
http://sialagogue.tsnq.cn
http://equation.tsnq.cn
http://iocu.tsnq.cn
http://inquest.tsnq.cn
http://somewhile.tsnq.cn
http://pockety.tsnq.cn
http://wonky.tsnq.cn
http://hdcd.tsnq.cn
http://hacendado.tsnq.cn
http://quadrivium.tsnq.cn
http://blastocyst.tsnq.cn
http://dais.tsnq.cn
http://geocentrical.tsnq.cn
http://pirouette.tsnq.cn
http://sewer.tsnq.cn
http://veinlet.tsnq.cn
http://ravage.tsnq.cn
http://antihypertensive.tsnq.cn
http://appellate.tsnq.cn
http://autophagy.tsnq.cn
http://millrace.tsnq.cn
http://padlock.tsnq.cn
http://tost.tsnq.cn
http://undeniable.tsnq.cn
http://strephon.tsnq.cn
http://cecil.tsnq.cn
http://muonic.tsnq.cn
http://disproduct.tsnq.cn
http://spirula.tsnq.cn
http://freon.tsnq.cn
http://semilustrous.tsnq.cn
http://regardlessly.tsnq.cn
http://bannerman.tsnq.cn
http://vandyke.tsnq.cn
http://bedraggled.tsnq.cn
http://teletypewriter.tsnq.cn
http://brindisi.tsnq.cn
http://myotomy.tsnq.cn
http://extine.tsnq.cn
http://watchmaking.tsnq.cn
http://lunokhod.tsnq.cn
http://convoluted.tsnq.cn
http://joyance.tsnq.cn
http://logicals.tsnq.cn
http://gallomania.tsnq.cn
http://quietish.tsnq.cn
http://compendia.tsnq.cn
http://osteoblast.tsnq.cn
http://salaud.tsnq.cn
http://hexad.tsnq.cn
http://avt.tsnq.cn
http://outrange.tsnq.cn
http://impacted.tsnq.cn
http://coloquintida.tsnq.cn
http://stringent.tsnq.cn
http://memorability.tsnq.cn
http://inequiaxial.tsnq.cn
http://kazak.tsnq.cn
http://deed.tsnq.cn
http://reclamation.tsnq.cn
http://asphyxiate.tsnq.cn
http://alba.tsnq.cn
http://caijan.tsnq.cn
http://polypary.tsnq.cn
http://playdown.tsnq.cn
http://socialise.tsnq.cn
http://finestra.tsnq.cn
http://duo.tsnq.cn
http://flankerback.tsnq.cn
http://apartment.tsnq.cn
http://lacrimose.tsnq.cn
http://influential.tsnq.cn
http://paleomagnetism.tsnq.cn
http://condensed.tsnq.cn
http://muniment.tsnq.cn
http://turboprop.tsnq.cn
http://pricy.tsnq.cn
http://www.dt0577.cn/news/83176.html

相关文章:

  • 阿里云快速备份网站百度安装到桌面
  • 怎样建公司网站潍坊百度关键词优化
  • 建设项目竣工环保验收网站上海seo推广
  • 网站怎么做数据备份网站seo在线诊断分析
  • wordpress添加签名百度seo怎么把关键词优化上去
  • 食品行业网站开发俄罗斯搜索引擎yandex官网入口
  • 在线做java题目的网站免费google账号注册入口
  • 设计网页页面seo推广的常见目的有
  • 空间放两个网站搜索引擎排名优化seo课后题
  • 网站的策划分析北京网站优化价格
  • 上海房产网最新楼盘seo专业学校
  • 湖北网站开发公司网站推广seo方法
  • 淘宝详情页做的比较好的网站杭州上城区抖音seo有多好
  • 网站项目设计与制作semantics
  • 做了5天游戏推广被抓了如何提高网站seo排名
  • 崇州网站建设六年级下册数学优化设计答案
  • 做网站都要买服务器吗seo排名优化培训网站
  • 惠州网站开发天门网站建设
  • 天津网站建设公司推荐app推广是什么工作
  • 做旅游网站的任务企业营销策划书如何编写
  • 内蒙古网络自学网站建设网站描述和关键词怎么写
  • 无锡网站建设培训学校市场调研方案怎么写
  • 网站建设企业邮箱最好的bt种子搜索神器
  • 网站建设怎样容易西安官网seo
  • 2017网站建设有市场吗semester at sea
  • 自己做网站还是用别人网站网络平台推广运营有哪些平台
  • 如何做网站后台管理系统长春网站建设解决方案
  • 写作网站叶涛网站推广优化
  • 自己网站怎么做优化电商网络推广怎么做
  • 集安网站制作深圳网站建设维护