题解

129 条题解

  • 1
    @ 2020-05-08 21:45:47
    #include<bits/stdc++.h>
    using namespace std;
    string s,str,tmp;
    int maxrp,n;
    int main()
    {
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    cin>>s;
    tmp=s;
    if(tmp.find("reioxzsj")==tmp.npos)
    {
    continue;
    }
    while(tmp.find("woc")!=tmp.npos)
    {
    int pos=tmp.find("woc");
    tmp.replace(pos,3,"drib");
    }
    int a=0,b=0,c=0;
    for(int i=tmp.size()-1;i>=0;i--)
    {
    if(tmp[i]=='r')
    {
    a++;
    }
    if(tmp[i]=='p')
    {
    b++;
    if(tmp[i+1]=='r')
    {
    c++;
    }
    }
    }
    int rp=a*5+b*5+c*20;
    if(rp>maxrp)
    {
    maxrp=rp;
    str=s;
    }
    if(rp==maxrp)
    {
    if(s.size()<str.size())
    {
    str=s;
    }
    }
    }
    cout<<str<<endl<<maxrp;
    }
    
  • 1
    @ 2019-07-25 11:23:42

    #include<bits/stdc++.h>
    using namespace std;
    string s,str,tmp;
    int maxrp,n;
    int main()
    {
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    cin>>s;
    tmp=s;
    if(tmp.find("reioxzsj")==tmp.npos)
    {
    continue;
    }
    while(tmp.find("woc")!=tmp.npos)
    {
    int pos=tmp.find("woc");
    tmp.replace(pos,3,"drib");
    }
    int a=0,b=0,c=0;
    for(int i=tmp.size()-1;i>=0;i--)
    {
    if(tmp[i]=='r')
    {
    a++;
    }
    if(tmp[i]=='p')
    {
    b++;
    if(tmp[i+1]=='r')
    {
    c++;
    }
    }
    }
    int rp=a*5+b*5+c*20;
    if(rp>maxrp)
    {
    maxrp=rp;
    str=s;
    }
    if(rp==maxrp)
    {
    if(s.size()<str.size())
    {
    str=s;
    }
    }
    }
    cout<<str<<endl<<maxrp;
    }

  • 1
    @ 2016-11-05 22:15:56

    顺便练习膜法

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    using namespace std;
    char name[501];
    char xn[501];
    int main()
    {
    int i,j,n,rp=0,xrp=0,len,xlen=0;
    scanf("%d",&n);
    for(i=1;i<=n;++i)
    {
    scanf("%s",name);rp=0;len=strlen(name);
    for(j=len-1;j>=0;--j)
    {
    if(name[j]=='r'||name[j]=='p')rp+=5;
    if(j>0)if(name[j]=='r'&&name[j-1]=='p')rp+=20;
    if(j>1)if(name[j]=='c'&&name[j-1]=='o'&&name[j-2]=='w')rp+=5;
    if(j>6)if(name[j]=='j'&&name[j-1]=='s'&&name[j-2]=='z'&&name[j-3]=='x'
    &&name[j-4]=='o'&&name[j-5]=='i'&&name[j-6]=='e'&&name[j-7]=='r'&&rp<19260817)rp+=19260817;
    }
    if(rp>xrp)xlen=len,xrp=rp,strcpy(xn,name);
    else if(rp==xrp&&len<xlen)xlen=len,strcpy(xn,name);
    }
    printf("%s\n%d",xn,xrp-19260817);
    }

    • @ 2018-04-01 16:42:17

      大佬,问下19260817,是为什么?

  • 0
    @ 2021-12-16 20:24:14

    400题咯

  • 0
    @ 2017-10-08 16:38:46
    #include<iostream>
    #include<algorithm>
    #include<cstdio>
    #include<vector>
    #include<queue>
    #include<map>
    #include<iomanip>
    #include<cmath>
    #include<cstring>
    #define maxa 3000+10
    #define inf 300
    #define FOR(i,x,y) for(i=x;i<=y;++i)
    using namespace std;
    string t = "jszxoier";
    struct node
    {
        string s;
        int v;
    }e[maxa];
    bool comp(node a,node b)
    {
        if(a.v!=b.v)
            return a.v>b.v;
        else
        return a.s.length()<b.s.length();
    }
    int main()
    {
        int n;
        vector<node >v;
       cin>>n;
          int i;
             int j;
        FOR(i,1,n)
        {
            cin>>e[i].s;
            int flag = 0;
            string tmp = e[i].s;
            reverse(tmp.begin(),tmp.end());
            if(tmp.find("jszxoier")!=-1)
            {
                int pos = tmp.find("cow");
                while(pos!=-1)
                {
                   tmp.replace(pos,3,"bird");
                    pos = tmp.find("cow",pos+3);
                }
                int b,c;
                b =c = 0;
                FOR(j,0,tmp.size()-1)
                {
                    if(tmp[j]=='r'){
                        b++;
                        if(j+1<=tmp.size()-1&&tmp[j+1]=='p')
                            c++;
                    }
                    else if(tmp[j]=='p')
                    {
                        b++;
                    }
                }
                 e[i].v  =5*b+20*c;
                v.push_back(e[i]);
            }
        }
        sort(v.begin(),v.end(),comp);
        cout<<v[0].s<<endl;
        cout<<v[0].v<<endl;
    }
    
    
  • 0
    @ 2017-01-29 23:53:25

    可以的,大家需要练习C++的特技
    特技特技加特技

    #include<algorithm>
    #include<iostream>
    #include<iomanip>
    #include<cstring>
    #include<cstdlib>
    #include<vector>
    #include<cstdio>
    #include<cmath>
    #include<queue>
    using namespace std;
    int n,Max=-1;
    string tmp,Ans,name;
    int Check(string s,string c) {
    int cnt=0,pos=s.find(c);
    while(pos!=-1) {
    cnt++;
    pos=s.find(c,pos+c.size());
    }
    return cnt;
    }
    int main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1; i<=n; i++) {
    cin>>name;
    tmp=name;
    reverse(tmp.begin(),tmp.end());
    if(tmp.find("jszxoier")!=-1) {
    int pos=tmp.find("cow");
    while(pos!=-1) {
    tmp.replace(pos,3,"bird");
    pos=tmp.find("cow",pos+3);
    }
    int A=Check(tmp,"r"), B=Check(tmp,"p"),C=Check(tmp,"rp");
    if(Max<5*A+5*B+20*C)Max=5*A+5*B+20*C,Ans=name;
    else if(Max==5*A+5*B+20*C&&tmp.size()<Ans.size())Ans=name;
    }
    }
    cout<<Ans<<endl<<Max<<endl;
    return 0;
    }

  • 0
    @ 2015-08-05 17:05:29

    program ggggg;
    var
    i,j,k,l,n,m,ii,jj,kk,ll,ans,mm:longint;
    s,ss,an,qq:ansistring;
    begin
    qq:='reioxzsj';
    readln(n);
    m:=0; mm:=500;
    for j:=1 to n do
    begin
    readln(s);
    ii:=0; jj:=0; kk:=0; ll:=0;
    if (pos(qq,s)<>0) then
    begin
    l:=pos('woc',s);
    while l<>0 do
    begin
    delete(s,l,3);
    // insert('drib',s,l);
    l:=pos('woc',s);
    ll:=ll+5;
    end;
    m:=length(s);
    ss:=s;
    for i:=1 to m do
    begin
    if s[i]='r' then inc(ii);
    if s[i]='p' then inc(jj);
    end;
    k:=pos('pr',s);
    while k<>0 do
    begin
    inc(kk);
    delete(s,k,2);
    k:=pos('pr',s);
    end;
    ll:=ii*5+jj*5+kk*20+ll;
    if (ll>ans)or((ll=ans)and(m<mm)) then
    begin
    ans:=ll;
    an:=ss;
    mm:=m;
    end
    end;
    end;
    writeln(an);
    writeln(ans);
    end.

  • 0
    @ 2015-08-05 16:47:14

    program vijos1454;
    var s,a,b,c,d,e:ansistring;
    n,i,j,t,k,tot,x,y,z:longint;
    function ji(s:ansistring):longint;
    var i,j,k,r,p,rp:longint;
    aa:ansistring;
    begin
    aa:=s;
    r:=0;
    p:=0;
    rp:=0;
    for j:=1 to length(aa) do
    if aa[j]='r' then
    begin
    inc(r);
    if (aa[j-1]='p')and(j-1>0) then inc(rp);
    end
    else if aa[j]='p' then inc(p);
    k:=pos(d,aa);
    while k<>0 do
    begin
    inc(r);
    delete(aa,k,3);
    k:=pos(d,aa);
    end;
    ji:=r*5+p*5+rp*20;
    end;
    begin
    c:='reioxzsj';
    d:='woc';
    e:='drib';
    tot:=0;
    readln(n);
    for i:=1 to n do
    begin
    readln(s);
    k:=pos(c,s);
    if k<>0 then
    begin
    x:=ji(s);
    if x>tot then
    begin
    tot:=x;
    a:=s;
    t:=length(a);
    end else
    if (x=tot)and(length(s)<t) then
    begin
    a:=s;
    t:=length(s);
    end;
    end;
    end;
    writeln(a);
    writeln(tot);
    end.

  • 0
    @ 2012-10-04 12:06:58

    第十六个点类型开小了……

    整型变量全用longint,字符串用ansistring

  • 0
    @ 2012-09-26 16:07:06

    A了好多次才A掉,因为没想到它要求最短的。后面的注意取最短

  • 0
    @ 2012-08-01 12:52:26

    C++毫无优化,AC

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 9ms

    ├ 测试数据 03:答案正确... 41ms

    ├ 测试数据 04:答案正确... 9ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 9ms

    ├ 测试数据 10:答案正确... 0ms

    ├ 测试数据 11:答案正确... 25ms

    ├ 测试数据 12:答案正确... 0ms

    ├ 测试数据 13:答案正确... 0ms

    ├ 测试数据 14:答案正确... 0ms

    ├ 测试数据 15:答案正确... 25ms

    ├ 测试数据 16:答案正确... 0ms

    ├ 测试数据 17:答案正确... 0ms

    ├ 测试数据 18:答案正确... 0ms

    ├ 测试数据 19:答案正确... 9ms

    ├ 测试数据 20:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:127ms

    为了编写方便,我还将字符串逆转了2遍~

    这都能过~

  • 0
    @ 2010-04-01 22:23:55

    第16个点怎么回事??

    我也是比标准输出多了20。

    第16个点的数据是什么??

  • 0
    @ 2009-11-07 11:59:27

    无语啊!

    无数次忘记题目条件

    WA了N次!!!

  • 0
    @ 2009-11-06 17:13:58

    好水的题目!

    但是我交了六遍。

    1~3次变量错了

    4~5次发现“pr”和“p”是重叠的,要重复计算。

    代码不长,就拿出来晒了

    program p1454;

    var

    n,i,rp,s,j,len,l: longint;

    t,rpcow: ansistring;

    begin

    readln(n);

    rp:=0; len:=300;

    for i:= 1 to n do begin

    readln(t);

    if pos('reioxzsj',t)=0 then continue;

    s:=0; l:=length(t);

    for j:= 1 to l do begin

    if (j

  • 0
    @ 2009-10-22 16:35:05

    譕淚らづ寳唄

    var

    a:array[1..3000] of string;

    k,s,z:string;

    n,i,j,l,m,o,y,x,r:longint;

    begin

    readln(n);

    for i:=1 to n do

       readln(a[i]);

    o:=0;

    for i:= 1 to n do

       begin

       x:=length(a[i]);

       for j:=1 to x do

        begin

         s:=copy(a[i],j,8);

         if s='reioxzsj' then

          begin

           for l:=1 to x do

            begin

             y:=0;

             z:=copy(a[i],l,3);

             if z='woc' then

              begin

               for m:=l to x do

                 a:=a;

               a:='d';a:='r';a:='i';a:='b';

              end;

             for m:=1 to x do

              if (a='p')and(a='r') then y:=y+20

               else if (a='p')or(a='r') then y:=y+5;

             if y>o then begin o:=y; k:=a[i];r:=x; end

              else if (y=o)and(x

  • 0
    @ 2009-10-17 11:52:59

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ├ 测试数据 11:答案正确... 0ms

    ├ 测试数据 12:答案正确... 0ms

    ├ 测试数据 13:答案正确... 0ms

    ├ 测试数据 14:答案正确... 0ms

    ├ 测试数据 15:答案正确... 0ms

    ├ 测试数据 16:答案正确... 0ms

    ├ 测试数据 17:答案正确... 0ms

    ├ 测试数据 18:答案正确... 0ms

    ├ 测试数据 19:答案正确... 0ms

    ├ 测试数据 20:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms !、

    还得仔细啊!悲惨啊!7次啊!

  • 0
    @ 2009-10-11 11:19:28

    刚刚看到这题时觉得很水

    结果我交了9次才过..

    输出都是数字的是因为没用ansistring

    一开始超时2个点 后来超时一个点

    最后终于秒杀

  • 0
    @ 2009-10-10 22:15:33

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ├ 测试数据 11:答案正确... 0ms

    ├ 测试数据 12:答案正确... 0ms

    ├ 测试数据 13:答案正确... 0ms

    ├ 测试数据 14:答案正确... 0ms

    ├ 测试数据 15:答案正确... 0ms

    ├ 测试数据 16:答案正确... 0ms

    ├ 测试数据 17:答案正确... 0ms

    ├ 测试数据 18:答案正确... 0ms

    ├ 测试数据 19:答案正确... 0ms

    ├ 测试数据 20:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

    ___|\__|\__|\__|\__|\__|\__|\__|\__|\__|\__|\__|\__|

    太Rp了。我用血的代价告诉大家:

    不要忘拷斜杠'\0'

    for( j = 0; j

  • 0
    @ 2009-10-31 10:55:28

    乍似AC

    编译通过...

    ├ 测试数据 01:运行超时|无输出...

    ├ 测试数据 02:运行超时|无输出...

    ├ 测试数据 03:运行超时|无输出...

    ├ 测试数据 04:运行超时|无输出...

    ├ 测试数据 05:运行超时|无输出...

    ├ 测试数据 06:运行超时|无输出...

    ├ 测试数据 07:运行超时|无输出...

    ├ 测试数据 08:运行超时|无输出...

    ├ 测试数据 09:运行超时|无输出...

    ├ 测试数据 10:运行超时|无输出...

    ├ 测试数据 11:运行超时|无输出...

    ├ 测试数据 12:运行超时|无输出...

    ├ 测试数据 13:运行超时|无输出...

    ├ 测试数据 14:运行超时|无输出...

    ├ 测试数据 15:运行超时|无输出...

    ├ 测试数据 16:运行超时|无输出...

    ├ 测试数据 17:运行超时|无输出...

    ├ 测试数据 18:运行超时|无输出...

    ├ 测试数据 19:运行超时|无输出...

    ├ 测试数据 20:运行超时|无输出...

    ---|---|---|---|---|---|---|---|-

    Unaccepted 有效得分:0 有效耗时:0ms

  • 0
    @ 2009-10-07 14:41:02

    这题很简单,只要细心,看清每个细节,

    我用string就很简单的过了

    程序不长,只有60行左右,真的很水

    第一次提交,我忘删文件了

    第二次提交,我输错验证码了

    可怜的第三次,我终于ac了

    奋斗了2天,我晕倒了

    string处理起来会很方便,特别是一些简单的命令,直接替换,删除,很好用的

    -_-!!,大家努力!1!1!!!!!!!!

信息

ID
1454
难度
7
分类
字符串 | 模拟 点击显示
标签
(无)
递交数
2646
已通过
475
通过率
18%
被复制
2
上传者