QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#294573#4832. TelepathyForever_Young#0 18ms6152kbC++144.0kb2023-12-30 14:41:462023-12-30 14:41:47

Judging History

你现在查看的是最新测评结果

  • [2023-12-30 14:41:47]
  • 评测
  • 测评结果:0
  • 用时:18ms
  • 内存:6152kb
  • [2023-12-30 14:41:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long LL;
mt19937 gene(233);
int cnt[10][2][10];
int sta[]={0,0,1,0,2,2,1,0,0,0,1,1,2,0,2,0};
vector<int> encode1(int n, int k, string s) {
    vector<int> res;
    //cout << s << endl;
    for(int i = 0; i < 3 * k; i += 3) {
        int msk = 0;
        for(int j = 0; j < 3; j++) {
            msk = msk * 2 + s[i + 2 - j] - '0';
            //cout << s[j] << ' ' << msk << endl;
        }
        res.pb(i + sta[msk]);
        /*int cnt = 0;
        vector<int> vec[2];
        for(int j = 0; j < n / k; j++) {
            cnt += s[i + j] == '1';
            vec[s[i + j] - '0'].pb(i + j);
        }
        if(cnt >= 5) {
            res.pb(vec[1][gene() % vec[1].size()]);
        }else {
            res.pb(vec[0][gene() % vec[0].size()]);
        }*/
    }
    return res;
}
vector<int> encode2(int n, int k, string s) {
    vector<int> res;
    for(int i = 0; i < 3 * k; i += 3) {
        int msk = 0;
        for(int j = 0; j < 3; j++) {
            msk = msk * 2 + s[i + 2 - j] - '0';
        }
        res.pb(i + sta[msk + 8]);
        /*int cnt = 0;
        vector<int> vec[2];
        for(int j = 0; j < n / k; j++) {
            cnt += s[i + j] == '1';
            vec[s[i + j] - '0'].pb(i + j);
        }
        if(cnt == 0 || cnt == n / k) {
            res.pb(i);
        }else {
            if(gene() % 2) {
                res.pb(vec[0][0]);
            }else {
                res.pb(vec[1][0]);
            }
        }*/
    }
    return res;
}
void check(string s1, string s2, vector<int> v1, vector<int> v2) {
    string t1, t2;
    for(int i : v1) {
        t1.pb(s2[i]);
    }
    for(int i : v2) {
        t2.pb(s1[i]);
    }
    assert(t1.size() == t2.size());
    int cnt = 0;
    for(int i = 0; i < (int)t1.size(); i++) {
        cnt += t1[i] == t2[i];
    }
    printf("cnt = %d\n", cnt);
}
int main() {
    string t;
    cin >> t;
    /*for(int i = 0; i < 1024; i++) {
        go[i] = gene() % 10;
        for(int j = 0; j < 10; j++) {
            if((i >> j) & 1) {

            }else {
                go[i] = j;
            }
        }
        for(int j = 0; j < 10; j++) {
            int d = (i >> j) & 1;
            cnt[j][d][go[i]]++;
        }
    }
    for(int i = 0; i < 1024; i++) {
        int mx = -1, mxj = -1;
        for(int j = 0; j < 10; j++) {
            int c = 0;
            for(int d = 0; d < 2; d++) {
                int sum =0 ;
                for(int k = 0; k < 10; k++) {
                    sum += cnt[j][d][k];
                    if(((i >> k) & 1) == d) {
                        c += cnt[j][d][k];
                    }
                }
                //printf("sum = %d c = %d\n", sum, c);
            }
            if(c > mx) {
                mx = c;
                mxj = j;
            }
        }
        //printf("%d %d\n", mx, mxj);
        select[i] = mxj;
    }*/
    if(t == "Flim") {
        int n, k;
        scanf("%d%d", &n, &k);
        string s;
        cin >> s;
        vector<int> vec = encode1(n, k, s);
        for(int i = 0; i < k; i++) {
            printf("%d%c", vec[i], i == k - 1 ? '\n' : ' ');
        }
    } else if(t == "Flam") {
        int n, k;
        scanf("%d%d", &n, &k);
        string s;
        cin >> s;
        vector<int> vec = encode2(n, k, s);
        for(int i = 0; i < k; i++) {
            printf("%d%c", vec[i], i == k - 1 ? '\n' : ' ');
        }
    } else {
        assert(t == "test");
        string s(1000000, ' ');
        for(int i = 0; i < 100; i++) {
            for(char & c : s) {
                c = gene() % 2 ? '0' : '1';
            }
            vector<int> v1 = encode1(1000000, 100000, s);
            string s1 = s;
            for(char & c : s) {
                c = gene() % 2 ? '0' : '1';
            }
            vector<int> v2 = encode2(1000000, 100000, s);
            check(s1, s, v1, v2);
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 18ms
memory: 6152kb

input:

Flim
1000000 100000
1101111111100010011110111001110011110110100000111110011111111111110111110100000001001000000110111000000101110000001100111110100100000100010111001011111010001000101100101100001111011100110010010000100100100101110100100110101001001000001011111101111111001100101000010110001011011000...

output:

0 3 6 9 14 17 18 22 24 27 32 33 37 40 42 46 48 53 54 57 60 63 67 69 73 75 78 81 84 87 91 94 96 99 103 105 108 111 114 118 120 124 127 129 133 137 139 141 146 147 152 153 156 160 162 166 168 171 174 179 180 184 188 191 192 196 199 202 205 207 211 214 217 220 222 225 228 231 236 237 240 243 246 249 25...

input:

Flam
1000000 100000
0000001101000100010010001001011111000101010011011001010100101001110101001011001011100001011100110100011110011010100101110101101101100101111011000111001101001100010000010010101110101010111110001100110000110001001111010010000010111101110001011011101101010000111111011111100100010001...

output:

0 3 7 9 13 17 20 21 24 27 30 33 37 39 44 45 48 51 55 58 60 63 67 69 72 75 78 82 84 87 91 95 97 101 102 107 108 112 115 117 121 124 127 130 133 135 138 141 146 147 151 153 157 161 162 167 170 172 174 178 180 185 186 189 193 197 198 203 204 207 210 213 218 219 224 227 229 231 234 237 240 244 247 249 2...

result:

wrong answer