Submission #96037

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

using namespace std;

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);
    vector<ll> ths(m + 1, 0);
    for(int color = 1; color <= 4; color ++) {
        for(int i = 1; i <= m; i ++)
            ths[i] = 0;
        for(int i = 1; i <= m; i ++)
            for(int k = 1; k <= n; k ++)
                ths[i] += (v[color][k][i] * hs[k]);

        for(int i = 1; i <= n; i ++)
            for(int k = 1; k <= m; k ++)
                ans[i] += (v[color][i][k] * ths[k]);
    }

    vector<ll> solhs(n + 1, 0);
    for(int i = 1; i <= n; i ++) {
        for(int j = 1; j <= n; j ++) {
            if(i == j)
                solhs[i] += (m * hs[j]);
            else
                solhs[i] += (k * hs[j]);
        }
    }

    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 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 5 ms 560 KB Output is correct
6 Correct 5 ms 760 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 632 KB Output is correct
10 Correct 5 ms 760 KB Output is correct
11 Correct 5 ms 760 KB Output is correct
12 Correct 5 ms 760 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 5 ms 888 KB Output is correct
15 Correct 6 ms 888 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 263 ms 126072 KB Output is correct
2 Correct 346 ms 155768 KB Output is correct
3 Correct 327 ms 148984 KB Output is correct
4 Correct 52 ms 32376 KB Output is correct
5 Correct 344 ms 155904 KB Output is correct
6 Correct 343 ms 155768 KB Output is correct
7 Correct 86 ms 66808 KB Output is correct
8 Correct 83 ms 66808 KB Output is correct
9 Correct 302 ms 143864 KB Output is correct
10 Correct 315 ms 143992 KB Output is correct
11 Correct 270 ms 126048 KB Output is correct
12 Correct 272 ms 126932 KB Output is correct
13 Correct 263 ms 126144 KB Output is correct
14 Correct 219 ms 108152 KB Output is correct
15 Correct 232 ms 109688 KB Output is correct
16 Correct 216 ms 109048 KB Output is correct
17 Correct 327 ms 149240 KB Output is correct
18 Correct 322 ms 148216 KB Output is correct
19 Correct 322 ms 149368 KB Output is correct
20 Correct 333 ms 147448 KB Output is correct
21 Correct 330 ms 148984 KB Output is correct
22 Correct 333 ms 148072 KB Output is correct
23 Correct 325 ms 148600 KB Output is correct
24 Correct 336 ms 148636 KB Output is correct
25 Correct 319 ms 147448 KB Output is correct
26 Correct 358 ms 148728 KB Output is correct
27 Correct 357 ms 147704 KB Output is correct
28 Correct 327 ms 147704 KB Output is correct
29 Correct 323 ms 148732 KB Output is correct
30 Correct 349 ms 156024 KB Output is correct
31 Correct 346 ms 155896 KB Output is correct
32 Correct 344 ms 155768 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 263 ms 126072 KB Output is correct
2 Correct 346 ms 155768 KB Output is correct
3 Correct 327 ms 148984 KB Output is correct
4 Correct 52 ms 32376 KB Output is correct
5 Correct 344 ms 155904 KB Output is correct
6 Correct 343 ms 155768 KB Output is correct
7 Correct 86 ms 66808 KB Output is correct
8 Correct 83 ms 66808 KB Output is correct
9 Correct 302 ms 143864 KB Output is correct
10 Correct 315 ms 143992 KB Output is correct
11 Correct 270 ms 126048 KB Output is correct
12 Correct 272 ms 126932 KB Output is correct
13 Correct 263 ms 126144 KB Output is correct
14 Correct 219 ms 108152 KB Output is correct
15 Correct 232 ms 109688 KB Output is correct
16 Correct 216 ms 109048 KB Output is correct
17 Correct 327 ms 149240 KB Output is correct
18 Correct 322 ms 148216 KB Output is correct
19 Correct 322 ms 149368 KB Output is correct
20 Correct 333 ms 147448 KB Output is correct
21 Correct 330 ms 148984 KB Output is correct
22 Correct 333 ms 148072 KB Output is correct
23 Correct 325 ms 148600 KB Output is correct
24 Correct 336 ms 148636 KB Output is correct
25 Correct 319 ms 147448 KB Output is correct
26 Correct 358 ms 148728 KB Output is correct
27 Correct 357 ms 147704 KB Output is correct
28 Correct 327 ms 147704 KB Output is correct
29 Correct 323 ms 148732 KB Output is correct
30 Correct 349 ms 156024 KB Output is correct
31 Correct 346 ms 155896 KB Output is correct
32 Correct 344 ms 155768 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 1731 ms 695632 KB Output is correct
37 Execution timed out 2033 ms 796804 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 632 KB Output is correct
5 Correct 5 ms 560 KB Output is correct
6 Correct 5 ms 760 KB Output is correct
7 Correct 5 ms 564 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 632 KB Output is correct
10 Correct 5 ms 760 KB Output is correct
11 Correct 5 ms 760 KB Output is correct
12 Correct 5 ms 760 KB Output is correct
13 Correct 5 ms 888 KB Output is correct
14 Correct 5 ms 888 KB Output is correct
15 Correct 6 ms 888 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 263 ms 126072 KB Output is correct
19 Correct 346 ms 155768 KB Output is correct
20 Correct 327 ms 148984 KB Output is correct
21 Correct 52 ms 32376 KB Output is correct
22 Correct 344 ms 155904 KB Output is correct
23 Correct 343 ms 155768 KB Output is correct
24 Correct 86 ms 66808 KB Output is correct
25 Correct 83 ms 66808 KB Output is correct
26 Correct 302 ms 143864 KB Output is correct
27 Correct 315 ms 143992 KB Output is correct
28 Correct 270 ms 126048 KB Output is correct
29 Correct 272 ms 126932 KB Output is correct
30 Correct 263 ms 126144 KB Output is correct
31 Correct 219 ms 108152 KB Output is correct
32 Correct 232 ms 109688 KB Output is correct
33 Correct 216 ms 109048 KB Output is correct
34 Correct 327 ms 149240 KB Output is correct
35 Correct 322 ms 148216 KB Output is correct
36 Correct 322 ms 149368 KB Output is correct
37 Correct 333 ms 147448 KB Output is correct
38 Correct 330 ms 148984 KB Output is correct
39 Correct 333 ms 148072 KB Output is correct
40 Correct 325 ms 148600 KB Output is correct
41 Correct 336 ms 148636 KB Output is correct
42 Correct 319 ms 147448 KB Output is correct
43 Correct 358 ms 148728 KB Output is correct
44 Correct 357 ms 147704 KB Output is correct
45 Correct 327 ms 147704 KB Output is correct
46 Correct 323 ms 148732 KB Output is correct
47 Correct 349 ms 156024 KB Output is correct
48 Correct 346 ms 155896 KB Output is correct
49 Correct 344 ms 155768 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 1731 ms 695632 KB Output is correct
54 Execution timed out 2033 ms 796804 KB Time limit exceeded
55 Halted 0 ms 0 KB -