题解

130 条题解

  • 0
    @ 2008-09-22 17:08:12

    首先,这里是房顶上的避雷针(最高了吧)

    ……

    第一次纯模拟暴力,70……

    1,3,5点超时

    所以想到了cheat……(-_-)

    cheat程序如下:

    readln(n);

    readln(s1);

    readln(s2);

    readln(s3);

    writeln(s1);

    可是,交了后得30分!

    1,3,5点0ms!!!!

    以为是回文词,但我怎么都觉得我的程序能解决。

    怪了……

    后来小小的cheat了一下,AC了。

    囧啊!!!

    以下是puppy编译……

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2008-09-22 13:28:59

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    我已经说过,我向来是不惮以最坏的恶意来做猥琐题的,然而我竟不料,也不信着道题竟会简单猥琐道这地步!

    只要枚举k就可以了...

  • 0
    @ 2008-09-22 13:30:44

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    procedure add(s1,s2:ansistring);

    var

    i:integer;

    begin

    ss[2]:=''; ss[3]:='';

    for i:=1 to n do

    ss[2]:=ss[2]+chr((ord(s1[i])-96+k+25)mod 26+97);

    if pos(ss[2],ss[1])=1 then

    for i:=1 to n do

    ss[3]:=ss[3]+chr((ord(s2[i])-96-k+25)mod 26+97);

    if pos(ss[2],ss[3])=1 then print;

    end;

    没看清K的范围。。WA了N次了。。终于AC了。。。。

    此乃暴力题

  • 0
    @ 2008-09-21 21:11:22

    60分是什么况?

    6 7 8 9 四个点没过!

    超时!而且是puppy!

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2008-09-21 20:17:29

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var

    w,n,i,j,k,l,q:longint;

    a:array[1..3,1..10002]of char;

    b:array[1..10001]of char;

    m:char;

    begin

    readln(n);

    for i:=1to 3do

    begin

    for j:=1to n do

    read(a);

    readln;

    end;

    for i:=1to 3do

    begin

    for j:=1to n do

    b[j]:=a;

    for k:=1to 3 do

    if ki then break;

    l:=ord(b[1])-ord(a[k,1]);

    for w:=1to 3do

    if(wi)and(wk)

    then break;

    for q:=1to n+1 do

    begin

    m:=chr(ord(b[q])+l);

    if m'z'

    then m:=chr(ord(m)-26);

    if ma[w,q]

    then break;

    end;

    if q=n+1

    then

    break;

    end;

    for i:=1to n do

    write(b[i]);

    writeln;

    end.

  • 0
    @ 2008-09-21 19:58:06

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    要是上午继续比赛,至少能得100分

  • 0
    @ 2008-09-21 19:11:24

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    真TMD见鬼了,交了2次一样的程序,一次O很,一次满分.囧...

  • 0
    @ 2008-09-21 18:24:38

    注意回文串!!!

    我没有考虑到回文串,然后败掉……

  • 0
    @ 2008-09-21 18:09:54

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

  • 0
    @ 2008-09-21 17:55:38

    可恶的第一题,第一次测竟有一个超时,第二次全对!!!

  • 0
    @ 2008-09-21 17:40:48

    轻松

  • 0
    @ 2008-09-21 17:30:12

    我想哭。考试的时候把一个9打成3了,结果考了80……

    此题乃水题,由于k值比较小,所以暴力枚举三个字符串的3种情况,共得到45个串。比较的时候,注意每个字符串必定对应一种情况,不用全部比较

  • 0
    @ 2008-09-21 17:01:49

    枚举第i行的字符串是逆序列,把它还原,与别的两个比较,看每位是否成立,不成立马上跳出,枚举i+1行为逆序列.........

    ---| 第1题 ---|---|---|---|---|---|---|---|---|---|---|--

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

  • -1
    @ 2018-02-02 23:02:12

    #include <iostream>
    #include<string>
    #include<stdlib.h>
    using namespace std;
    int test(string str, string a, string b, int m)
    {
    int k = 0;
    int pos = 0;
    string aa, bb;
    while (k <= 6)
    {
    aa = str;
    bb = str;
    for (int j = 0; j < k; j++)
    {
    for (int i = 0; i < m; i++)
    {
    if (aa[i] == 'a')
    aa[i] = 'z';
    else
    aa[i] = aa[i] - 1;
    if (bb[i] == 'z')
    bb[i] = 'a';
    else
    bb[i] = bb[i] + 1;
    }
    }
    if ((aa == a && bb == b) || (aa == b && bb == a))
    {
    pos = 1;
    break;
    }
    k++;
    }
    return pos;
    }
    int change(string& str,string a, string b,int n)
    {
    for (int i = 0; i < n / 2; i++)
    {
    char a = str[i];
    str[i] = str[n - i - 1];
    str[n - i - 1] = a;
    }
    int l = test(str, a, b, n);
    return l;
    }
    int main()
    {
    int n;
    string str1, str2, str3,str11,str22,str33;
    cin >> n;
    cin >> str1;
    cin >> str2;
    cin >> str3;
    str11 = str1;
    str22 = str2;
    str33 = str3;
    if (change(str11, str2, str3, n))
    cout << str11;
    else if (change(str22, str1, str3, n))
    cout << str22;
    else if (change(str33, str1, str2,n))
    cout << str33;
    system("pause");
    return 0;
    }

  • -1
    @ 2017-08-22 19:06:11
    var n,i,k:longint;s,s2,s3,a,b,c:ansistring;fa,fb:boolean;
    begin
        readln(n);
        readln(a);readln(b);readln(c);
        s:=a;s2:=s;s3:=s;
        for i:=1 to n do s[i]:=a[n+1-i];
        for k:=0 to 6 do 
            begin
            for i:=1 to n do begin
            if (ord(b[i])-k)<97 then s2[i]:=chr(123-(97-(ord(b[i])-k)))
            else s2[i]:=chr(ord(b[i])-k);
            if (ord(c[i])+k)>122 then s3[i]:=chr(ord(c[i])+k-122+96)
            else s3[i]:=chr(ord(c[i])+k);
            end;
            if (s=s2) and (s=s3) then fa:=true;
            if fa then break;
            for i:=1 to n do begin
            if (ord(b[i])+k)>122 then s2[i]:=chr(ord(b[i])+k-122+96)
            else s2[i]:=chr(ord(b[i])+k);
            if (ord(c[i])-k)<97 then s3[i]:=chr(123-(97-(ord(c[i])-k)))
            else s3[i]:=chr(ord(c[i])-k);
            end;
            if (s=s2) and (s=s3) then fa:=true;
            if fa then break;
           end;
        if fa=false then begin
        for i:=1 to n do s[i]:=b[n+1-i];
        for k:=0 to 6 do 
            begin
            for i:=1 to n do begin
            if (ord(a[i])-k)<97 then s2[i]:=chr(123-(97-(ord(a[i])-k)))
            else s2[i]:=chr(ord(a[i])-k);
            if (ord(c[i])+k)>122 then s3[i]:=chr(ord(c[i])+k-122+96)
            else s3[i]:=chr(ord(c[i])+k);
            end;
            if (s=s2) and (s=s3) then fb:=true;
            if fb then break;
            for i:=1 to n do begin
            if (ord(a[i])+k)>122 then s2[i]:=chr(ord(a[i])+k-122+96)
            else s2[i]:=chr(ord(a[i])+k);
            if (ord(c[i])-k)<97 then s3[i]:=chr(123-(97-(ord(c[i])-k)))
            else s3[i]:=chr(ord(c[i])-k);
            end;
            if (s=s2) and (s=s3) then fb:=true;
            if fb then break;
           end;
        end
        else fb:=true;
        if fb=false then for i:=1 to n do s[i]:=c[n+1-i];
        write(s);
    end.
    
  • -1
    @ 2017-08-15 19:34:18
    #include <string>
    #include <algorithm>
    #include <iostream>
    #include <cstdio>
    
    using namespace std;
    const string ab = "abcdefghijklmnopqrstuvwxyz";
    
    string cauA(string in) {
        string r;
        for(int i = in.size() - 1; i >= 0; i--)
            r.append(string(1, in.at(i)));
        return r;
    }
    
    string cauB(string in, int k) {
        string r = in;
        string abc = ab;
        if(k >= 0)
            rotate(abc.begin(), abc.begin() + k, abc.end());
        else
            rotate(abc.begin(), abc.end() - (-k), abc.end());
        for(char &c : r) {
            int ic = c - 'a';
            c = (char) (abc[ic]);
        }
        return r;
    }
    
    bool check(string a, string b, string c, int k){
        string ar = cauA(a);
        string br = cauB(b, k);
        string cr = cauB(c, -k);
        // cout << "Test:\n" << ar << "\n" << br << "\n" << cr << "\n" << endl;
        return equal(ar.begin(), ar.end(), br.begin()) && equal(br.begin(), br.end(), cr.begin());
    }
    
    int main() {
        int n;
        string a, b, c;
        scanf("%d", &n);
        cin >> a;
        cin >> b;
        cin >> c;
        
        for(int k = 0; k <= 6; k++) {
            if(check(a, b, c, k) || check(a, c, b, k)) {
                cout << cauA(a) << endl;
                return 0;
            }
            if(check(b, c, a, k) || check(b, a, c, k)) {
                cout << cauA(b) << endl;
                return 0;
            }
            if(check(c, b, a, k) || check(c, a, b, k)) {
                cout << cauA(c) << endl;
                return 0;
            }
        }
        return 0;
    }
    
  • -1
    @ 2017-08-13 18:22:02

    啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊

  • -1
    @ 2017-08-12 13:21:23

    n=int(input())
    s=[]
    alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    alphabet1=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','a','b','c','d','e','f','g']
    perm=[[0,1,2],[0,2,1],[1,0,2],[1,2,0],[2,0,1],[2,1,0]]
    for i in range(3):
    s.append(input())
    s[i]=list(s[i])

    def upsidedown(test):
    for i in range(round(n/2)):
    test[i],test[n-i-1]=test[n-i-1],test[i]
    return test
    #区别global和local return才有值
    #小心index
    def forward(test,k):
    for i in range(n):
    test[i]=alphabet[alphabet.index(test[i])-k]
    return test

    def backward(test,k):
    for i in range(n):
    test[i]=alphabet1[alphabet1.index(test[i])+k]
    return test
    #index索引
    for k in range(7):
    for j in range(6):
    a=upsidedown(s[perm[j][0]].copy())
    b=forward(s[perm[j][1]].copy(),k)
    c=backward(s[perm[j][2]].copy(),k)
    if a==b and b==c:
    for u in range(n):
    print(a[u],end='')
    break
    if a==b and b==c:
    break
    #一定要copy出来list的值才不会改

  • -1
    @ 2017-07-06 14:40:10

    #include<iostream>
    #include<string>
    using namespace std;
    string alphabet = "abcdefghijklmnopqrstuvwxyz";

    string move(string from, int k) {
    string ret;
    for(int i = 0; i < from.length(); i++) {
    ret += alphabet[((from[i] - 'a' + k) % 26) < 0 ? (26 + ((from[i] - 'a' + k) % 26)) : ((from[i] - 'a' + k) % 26)];
    }
    return ret;
    }

    bool check(string a, string b, string c) {
    reverse(a.begin(), a.end());
    for(int i = 0; i <= 6; i++) {
    if(!b.compare(move(a,i)) && !c.compare(move(a,-i))) {
    return true;
    }
    }
    return false;
    }

    int main() {
    int t;
    cin >> t;
    string a,b,c;
    cin >> a >> b >> c;
    if(check(a,b,c) || check(a,c,b)) {
    reverse(a.begin(),a.end());
    cout << a << endl;
    return 0;
    }
    if(check(b,a,c) || check(b,c,a)) {
    reverse(b.begin(),b.end());
    cout << b << endl;
    return 0;
    }
    if(check(c,a,b) || check(c,b,a)) {
    reverse(c.begin(),c.end());
    cout << c << endl;
    return 0;
    }
    return 0;
    }

  • -1
    @ 2017-05-28 13:26:53

    不难,分别算出解密的字符串,然后嵌套循环验证即可,注意k的范围

    #include<iostream>
    #include<string>
    
    std::string* input();
    std::string compute1(std::string str);
    std::string compute2(std::string str, int k);
    std::string compute3(std::string str, int k);
    std::string check(std::string str[]);
    
    int main()
    {
        std::string *test = input();
        std::cout << check(test) << std::endl;
    
        return 0;
    }
    
    std::string* input()
    {
        using namespace std;
        int n;
    
        cin >> n;
        string *str = new string[3];
        cin >> str[0];
        cin >> str[1];
        cin >> str[2];
    
        return str;
    }
    
    std::string compute1(std::string str)
    {
        using namespace std;
    
        string result;
        for(int i = str.size() - 1;i >= 0;i--)
        {
            result.append(string(1, str.at(i)));
        }
    
        return result;
    }
    
    std::string compute2(std::string str, int k)
    {
        using namespace std;
    
        string result(str.size(), '0');
        for(int i = 0, n = str.size();i < n;i++)
        {
            int check = (int)str.at(i) + k;
            if(check > (int)('z'))
            {
                result.at(i) = (char)(check % (int)('z') + (int)('a') - 1);
            }else
            {
                result.at(i) = (char)(check);
            }
        }
    
        return result;
    }
    
    std::string compute3(std::string str, int k)
    {
        using namespace std;
    
        string result(str.size(), '0');
        for(int i = 0;i < (int)str.size();i++)
        {
            int check = (int)str.at(i) - k;
            if(check < (int)('a'))
            {
                result.at(i) = (char)((int)('z') - (int)('a') + check + 1);
            }else
            {
                result.at(i) = (char)(check);
            }
        }
    
        return result;
    }
    
    std::string check(std::string str[])
    {
        using namespace std;
    
        string str1, str2, str3;
        for(int x = 0;x < 3;x++)
            for(int y = 0;y < 3;y++)
                for(int z = 0;z < 3;z++)
                    for(int k = 0;k <= 6;k++)
                    {
                        if(x != y && x != z && y != z)
                        {
                            if(compute1(str[x]) == compute2(str[y], k) && compute1(str[x]) == compute3(str[z], k))
                            {
                                return compute1(str[x]);
                            }
                        }else
                        {
                            continue;
                        }
                    }
    
        return "fail";
    }
    

信息

ID
1449
难度
6
分类
字符串 | 模拟 点击显示
标签
递交数
6904
已通过
1851
通过率
27%
被复制
9
上传者