编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#5934 #1060. 海明码 Wrong Answer 10 621 ms 19540 K C++ 17 / 4.2 K AllenYGY 2024-08-17 17:46:48
显示原始代码
// #include<bits/stdc++.h>
// #include<iostream>
// #define int long long
// #define endl '\n'
// using namespace std;

// int read(){
//     int x = 0, f = 1;
//     char ch = getchar();
//     while (ch < '0' || ch > '9'){
//         if (ch == '-')
//             f = -1;
//         ch = getchar();
//     }
//     while (ch >= '0' && ch <= '9')
//         x = x * 10 + ch - '0', ch = getchar();
//     return x * f;
// }

// void write(int x){
//     if (x < 0)
//         putchar('-'), x = -x;
//     if (x > 9)
//         write(x / 10);
//     putchar(x % 10 + '0');
// }

// int getLowbit(int x){
//     return x&(-x);
// }

// int checkHammingcode(string a,string b,char c){
//     int che[b.size()]={0};
//     // cout<<b<<" "<<b.size()<<endl;
//     // cout<<a<<" "<<a.size()<<endl;
//     int cnt=0;
//     int size=b.size();
//     for(int i=1;i<=a.size();i++){
//         if(a[i-1]=='1'){
//             cnt++;
//             int val=i;
//             // cout<<val<<endl;
//             for(int j=0;j<b.size();j++){

//                 if(val&(1<<j)){
//                     che[j]++;
//                 }
//             }
//         }
//     }
//     string res="";
//     for(int i=0;i<b.size();i++){
//         if(b[i]=='1'){
//             che[i]++;
//         }
//         if(che[i]%2==0){
//             che[i]=0;
//             res+='0';
//         }
//         else{
//             che[i]=1;
//             res+='1';
//         }
//     }

//     int ans=0;
//     for(int i=0;i<res.size();i++){
//         ans=ans*2+res[i]-'0';
//     }
//     return ans;

// }

// signed main() {
//     int n = read();
//     string s;
//     cin >> s;
//     string a = s.substr(0, n);
//     string b = s.substr(n, s.size() - n - 1);
//     char c=s[n-1];
//     int res=0;
//     for(int i=0;i<n;i++){
//         res^=s[i];
//     }
//     res^=s[n-1];

//     if(res==0){
//         cout<<a<<endl;
//     }
//     else{
//         int bit=checkHammingcode(a,b,c);
//         // change the bit
//         a[bit-1]=a[bit-1]=='0'?'1':'0';
//         cout<<a<<endl;
//     }

//     return 0;
// }

#include <bits/stdc++.h>
#include <iostream>
#define int long long

#define endl '\n'

using namespace std;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    return x * f;
}

void write(int x) {
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        write(x / 10);
    putchar(x % 10 + '0');
}

int getLowbit(int x) { return x & (-x); }

int checkHammingcode(string a, string b) {
    vector<int> che(b.size(), 0);
    int size = b.size();
    // cout<<"Size"<<size<<endl;
    for (int i = 1; i <= a.size(); i++) {
        if (a[i - 1] == '1') {
            int val = i;
            for (int j = 0; j < b.size(); j++) {
                if (val & (1 << j)) {
                    che[j]++;
                }
            }
        }
    }
    // for(int i = 0; i < b.size(); i++){
    //     cout<<che[i]<<" ";
    // }
    string res = "";
    for (int i = 0; i < b.size(); i++) {
        if (b[i] == '1') {
            che[i]++;
        }

        if (che[i] % 2 == 0) {
            che[i] = 0;
            res += '0';
        } else {
            che[i] = 1;
            res += '1';
        }
    }
    // cout <<"Detection:" <<res << endl;

    int ans = 0;
    for (int i = 0; i < res.size(); i++) {
        ans = ans * 2 + res[i] - '0';
    }
    return ans;
}

signed main() {
    int n = read();
    string s;
    cin >> s;
    string a = s.substr(0, n);
    string b = s.substr(n, s.size() - n - 1);
    // char c = s[n-1];
    int res = (int)(s[n - 1] - '0');
    for (int i = 0; i < n; i++) {
        res ^= (int)(s[i] - '0');
    }
    // res ^= (int)(c-'0');

    if (res == 0) {
        cout << a << endl;
    } else {
        int bit = checkHammingcode(a, b);
        a[bit - 1] = a[bit - 1] == '0' ? '1' : '0';
        cout << a << endl;
    }

    return 0;
}
子任务 #1
Wrong Answer
得分:10
测试点 #1
Wrong Answer
得分:0
用时:3 ms
内存:360 KiB

输入文件(hamming1.in

3
101000

答案文件(hamming1.out

101

用户输出

001

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #2
Wrong Answer
得分:0
用时:3 ms
内存:512 KiB

输入文件(hamming2.in

3
110011

答案文件(hamming2.out

010

用户输出

110

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #3
Wrong Answer
得分:0
用时:5 ms
内存:356 KiB

输入文件(hamming3.in

3
011111

答案文件(hamming3.out

001

用户输出

111

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #4
Wrong Answer
得分:0
用时:3 ms
内存:384 KiB

输入文件(hamming4.in

3
110001

答案文件(hamming4.out

111

用户输出

110

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:2 ms
内存:256 KiB

输入文件(hamming5.in

7
00101000111

答案文件(hamming5.out

0010100

用户输出

0010100

系统信息

Exited with return code 0
测试点 #6
Wrong Answer
得分:0
用时:3 ms
内存:288 KiB

输入文件(hamming6.in

7
10111010110

答案文件(hamming6.out

1111101

用户输出

1011101

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #7
Wrong Answer
得分:0
用时:3 ms
内存:248 KiB

输入文件(hamming7.in

7
11111100001

答案文件(hamming7.out

1111111

用户输出

1111110

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #8
Wrong Answer
得分:0
用时:4 ms
内存:352 KiB

输入文件(hamming8.in

7
01100010100

答案文件(hamming8.out

0111001

用户输出

0110001

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #9
Wrong Answer
得分:0
用时:3 ms
内存:236 KiB

输入文件(hamming9.in

1011
11010100110000101111001100101011110101011000000000011110111010001110010100000100101100011001001
<927 bytes omitted>

答案文件(hamming9.out

1101010011000010111100110010101111010101100000000001111011101000111001010000010010110001100100111101
<911 bytes omitted>

用户输出

11010100110000101111001100101011110101011000000000011110111010001110010100000100101100011001001111010001001111110010010000110000
<884 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #10
Wrong Answer
得分:0
用时:3 ms
内存:304 KiB

输入文件(hamming10.in

823
100110001001000111000001101010111100001101111000001101101010110000111101100001100100011000100001
<738 bytes omitted>

答案文件(hamming10.out

1001100010010001110000011010101111000011011110000011011010101100001111011000011001000110001000010011
<723 bytes omitted>

用户输出

10011000100100011100000110101011110000110111100000110110101011000011110110000110010001100010000100111101110110011000100000111100
<696 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #11
Wrong Answer
得分:0
用时:2 ms
内存:244 KiB

输入文件(hamming11.in

958
101100100011110000010111000111010011100001001001011100100011011010100011000101110101101100001010
<873 bytes omitted>

答案文件(hamming11.out

1011001000111100000101110001110100111000010010010111001000110110101000110001011101011011000010101011
<858 bytes omitted>

用户输出

10110010001111000001011100011101001110000100100101110010001101101010001100010111010110110000101010110010100100110000000101101011
<831 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #12
Wrong Answer
得分:0
用时:27 ms
内存:2340 KiB

输入文件(hamming12.in

918908
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<918836 bytes omitted>

答案文件(hamming12.out

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<918808 bytes omitted>

用户输出

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<918781 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #13
Wrong Answer
得分:0
用时:30 ms
内存:2516 KiB

输入文件(hamming13.in

1031714
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<1031643 bytes omitted>

答案文件(hamming13.out

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<1031614 bytes omitted>

用户输出

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<1031587 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #14
Accepted
得分:100
用时:25 ms
内存:2144 KiB

输入文件(hamming14.in

867870
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<867798 bytes omitted>

答案文件(hamming14.out

0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<867770 bytes omitted>

用户输出

00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
<867743 bytes omitted>

系统信息

Exited with return code 0
测试点 #15
Wrong Answer
得分:0
用时:80 ms
内存:2616 KiB

输入文件(hamming15.in

1048575
01000000000000101001010011000110010010010000010110101010011101100100001001100011111001011000
<1048504 bytes omitted>

答案文件(hamming15.out

0100000000000010100101001100011001001001000001011010101001110110010000100110001111100101100000001100
<1048475 bytes omitted>

用户输出

01000000000000101001010011000110010010010000010110101010011101100100001001100011111001011000000011000010010100001000101111100110
<1048448 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #16
Wrong Answer
得分:0
用时:68 ms
内存:2648 KiB

输入文件(hamming16.in

1048575
11001111010100010110010101101011100111010011011101110001110110001111110111100110101010010111
<1048504 bytes omitted>

答案文件(hamming16.out

1100111101010001011001010110101110011101001101110111000111011000111111011110011010101001011111010100
<1048475 bytes omitted>

用户输出

11001111010100010110010101101011100111010011011101110001110110001111110111100110101010010111110101001100010111111110001111100011
<1048448 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #17
Wrong Answer
得分:0
用时:29 ms
内存:2620 KiB

输入文件(hamming17.in

1048575
10011011000011001111000110111101001000101011011000110010011101000101000001100100001101000100
<1048504 bytes omitted>

答案文件(hamming17.out

1001101100001100111100011011110100100010101101100011001001110100010100000110010000110100010011011001
<1048475 bytes omitted>

用户输出

10011011000011001111000110111101001000101011011000110010011101000101000001100100001101000100110110011001101101011000110100101101
<1048448 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #18
Wrong Answer
得分:0
用时:69 ms
内存:2616 KiB

输入文件(hamming18.in

1039660
01011010111000011001110110101010001010100111111110000100001100000101100011010100010001011001
<1039589 bytes omitted>

答案文件(hamming18.out

0101101011100001100111011010101000101010011111111000010000110000010110001101010001000101100101111001
<1039560 bytes omitted>

用户输出

01011010111000011001110110101010001010100111111110000100001100000101100011010100010001011001011110010010001111100110100001100101
<1039533 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #19
Wrong Answer
得分:0
用时:21 ms
内存:1852 KiB

输入文件(hamming19.in

712842
001100101011011110011101011010010000100000110101100110110111010000011010111010100101010001110
<712770 bytes omitted>

答案文件(hamming19.out

0011001010110111100111010110100100001000001101011001101101110100000110101110101001010100011101000101
<712742 bytes omitted>

用户输出

00110010101101111001110101101001000010000011010110011011011101000001101011101010010101000111010001011011001100011111101111001000
<712715 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0
测试点 #20
Wrong Answer
得分:0
用时:238 ms
内存:19540 KiB

输入文件(hamming20.in

9631168
11110110000110010011010101001000100100101011010010110010010010101010110010111010101000000001
<9631101 bytes omitted>

答案文件(hamming20.out

1111011000011001001101010100100010010010101101001011001001001010101011001011101010100000000101101110
<9631068 bytes omitted>

用户输出

11110110000110010011010101001000100100101011010010110010010010101010110010111010101000000001011011101001111001110010010101001110
<9631041 bytes omitted>

Special Judge 信息

Files user_out and answer differ

系统信息

Exited with return code 0