Submission #95837

# Submission time Handle Problem Language Result Execution time Memory
95837 2019-02-02T20:04:05 Z caesar2001 Genetics (BOI18_genetics) C++14
46 / 100
2000 ms 792264 KB
#include <bits/stdc++.h>
#define ll long long
#define lsb(x) (x & -x)

using namespace std;

void transpune(const vector<vector<ll>> &v, vector<vector<ll>> &ans, int n, int m) {
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= m; j ++)
            ans[j][i] = v[i][j];
}

void multiply(const vector<vector<ll>> &a, const vector<ll> &b, vector<ll> &ans, int n, int m) {
    for(int i = 1; i <= n; i ++)
        for(int k = 1; k <= m; k ++)
                ans[i] += (a[i][k] * b[k]);
}

void add(vector<ll> &ans, const vector<ll> &a, int n) {
    for(int i = 1; i <= n; i ++)
        ans[i] += a[i];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);

    int n, m, k;
    cin >> n >> m >> k;
    k = m - k;

    vector<int> code(30, 0);
    code['A' - 'A'] = 1;
    code['C' - 'A'] = 2;
    code['G' - 'A'] = 3;
    code['T' - 'A'] = 4;

    vector<vector<vector<ll>>> v(5, vector<vector<ll>> (n + 1, vector<ll> (m + 1, 0)));
    for(int i = 1; i <= n; i ++) {
        string s;
        cin >> s;

        for(int j = 0; j < m; j ++)
            v[code[s[j] - 'A']][i][j + 1] = 1;
    }

    srand(time(NULL));

    vector<ll> hs(n + 1, 0);
    for(int i = 1; i <= n; i ++)
        hs[i] = rand();

    vector<ll> ans(n + 1, 0);
    for(int i = 1; i <= 4; i ++) {
        vector<vector<ll>> t(m + 1, vector<ll> (n + 1, 0));
        transpune(v[i], t, n, m);

        vector<ll> ths(m + 1, 0);
        multiply(t, hs, ths, m, n);

        vector<ll> aux(n + 1, 0);
        multiply(v[i], ths, aux, n, m);
        add(ans, aux, n);
    }

    vector<vector<ll>> sol(n + 1, vector<ll> (n + 1, k));
    for(int i = 1; i <= n; i ++)
        sol[i][i] = m;
    vector<ll> solhs(n + 1, 0);
    multiply(sol, hs, solhs, n, n);

    for(int i = 1; i <= n; i ++) {
        if(solhs[i] == ans[i]) {
            cout << i;
            return 0;
        }
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 764 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 6 ms 888 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 508 KB Output is correct
10 Correct 5 ms 888 KB Output is correct
11 Correct 6 ms 760 KB Output is correct
12 Correct 5 ms 792 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 6 ms 888 KB Output is correct
15 Correct 5 ms 888 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 295 ms 124408 KB Output is correct
2 Correct 367 ms 153848 KB Output is correct
3 Correct 356 ms 146936 KB Output is correct
4 Correct 57 ms 37624 KB Output is correct
5 Correct 369 ms 153952 KB Output is correct
6 Correct 365 ms 153848 KB Output is correct
7 Correct 151 ms 66296 KB Output is correct
8 Correct 153 ms 66424 KB Output is correct
9 Correct 332 ms 141944 KB Output is correct
10 Correct 335 ms 141944 KB Output is correct
11 Correct 313 ms 124536 KB Output is correct
12 Correct 287 ms 125048 KB Output is correct
13 Correct 300 ms 124536 KB Output is correct
14 Correct 249 ms 106872 KB Output is correct
15 Correct 258 ms 108152 KB Output is correct
16 Correct 240 ms 107768 KB Output is correct
17 Correct 347 ms 147192 KB Output is correct
18 Correct 350 ms 146240 KB Output is correct
19 Correct 342 ms 147448 KB Output is correct
20 Correct 338 ms 145528 KB Output is correct
21 Correct 343 ms 147064 KB Output is correct
22 Correct 353 ms 145912 KB Output is correct
23 Correct 339 ms 146552 KB Output is correct
24 Correct 354 ms 146552 KB Output is correct
25 Correct 348 ms 145528 KB Output is correct
26 Correct 352 ms 146808 KB Output is correct
27 Correct 352 ms 145784 KB Output is correct
28 Correct 351 ms 145656 KB Output is correct
29 Correct 352 ms 146552 KB Output is correct
30 Correct 372 ms 154132 KB Output is correct
31 Correct 362 ms 153908 KB Output is correct
32 Correct 363 ms 153848 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 888 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 295 ms 124408 KB Output is correct
2 Correct 367 ms 153848 KB Output is correct
3 Correct 356 ms 146936 KB Output is correct
4 Correct 57 ms 37624 KB Output is correct
5 Correct 369 ms 153952 KB Output is correct
6 Correct 365 ms 153848 KB Output is correct
7 Correct 151 ms 66296 KB Output is correct
8 Correct 153 ms 66424 KB Output is correct
9 Correct 332 ms 141944 KB Output is correct
10 Correct 335 ms 141944 KB Output is correct
11 Correct 313 ms 124536 KB Output is correct
12 Correct 287 ms 125048 KB Output is correct
13 Correct 300 ms 124536 KB Output is correct
14 Correct 249 ms 106872 KB Output is correct
15 Correct 258 ms 108152 KB Output is correct
16 Correct 240 ms 107768 KB Output is correct
17 Correct 347 ms 147192 KB Output is correct
18 Correct 350 ms 146240 KB Output is correct
19 Correct 342 ms 147448 KB Output is correct
20 Correct 338 ms 145528 KB Output is correct
21 Correct 343 ms 147064 KB Output is correct
22 Correct 353 ms 145912 KB Output is correct
23 Correct 339 ms 146552 KB Output is correct
24 Correct 354 ms 146552 KB Output is correct
25 Correct 348 ms 145528 KB Output is correct
26 Correct 352 ms 146808 KB Output is correct
27 Correct 352 ms 145784 KB Output is correct
28 Correct 351 ms 145656 KB Output is correct
29 Correct 352 ms 146552 KB Output is correct
30 Correct 372 ms 154132 KB Output is correct
31 Correct 362 ms 153908 KB Output is correct
32 Correct 363 ms 153848 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 888 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 1900 ms 691704 KB Output is correct
37 Execution timed out 2122 ms 792264 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 764 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 380 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 5 ms 632 KB Output is correct
6 Correct 6 ms 888 KB Output is correct
7 Correct 5 ms 632 KB Output is correct
8 Correct 5 ms 380 KB Output is correct
9 Correct 5 ms 508 KB Output is correct
10 Correct 5 ms 888 KB Output is correct
11 Correct 6 ms 760 KB Output is correct
12 Correct 5 ms 792 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 6 ms 888 KB Output is correct
15 Correct 5 ms 888 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 295 ms 124408 KB Output is correct
19 Correct 367 ms 153848 KB Output is correct
20 Correct 356 ms 146936 KB Output is correct
21 Correct 57 ms 37624 KB Output is correct
22 Correct 369 ms 153952 KB Output is correct
23 Correct 365 ms 153848 KB Output is correct
24 Correct 151 ms 66296 KB Output is correct
25 Correct 153 ms 66424 KB Output is correct
26 Correct 332 ms 141944 KB Output is correct
27 Correct 335 ms 141944 KB Output is correct
28 Correct 313 ms 124536 KB Output is correct
29 Correct 287 ms 125048 KB Output is correct
30 Correct 300 ms 124536 KB Output is correct
31 Correct 249 ms 106872 KB Output is correct
32 Correct 258 ms 108152 KB Output is correct
33 Correct 240 ms 107768 KB Output is correct
34 Correct 347 ms 147192 KB Output is correct
35 Correct 350 ms 146240 KB Output is correct
36 Correct 342 ms 147448 KB Output is correct
37 Correct 338 ms 145528 KB Output is correct
38 Correct 343 ms 147064 KB Output is correct
39 Correct 353 ms 145912 KB Output is correct
40 Correct 339 ms 146552 KB Output is correct
41 Correct 354 ms 146552 KB Output is correct
42 Correct 348 ms 145528 KB Output is correct
43 Correct 352 ms 146808 KB Output is correct
44 Correct 352 ms 145784 KB Output is correct
45 Correct 351 ms 145656 KB Output is correct
46 Correct 352 ms 146552 KB Output is correct
47 Correct 372 ms 154132 KB Output is correct
48 Correct 362 ms 153908 KB Output is correct
49 Correct 363 ms 153848 KB Output is correct
50 Correct 5 ms 376 KB Output is correct
51 Correct 5 ms 888 KB Output is correct
52 Correct 5 ms 376 KB Output is correct
53 Correct 1900 ms 691704 KB Output is correct
54 Execution timed out 2122 ms 792264 KB Time limit exceeded
55 Halted 0 ms 0 KB -