Submission #96554

# Submission time Handle Problem Language Result Execution time Memory
96554 2019-02-10T09:31:38 Z Kastanda Genetics (BOI18_genetics) C++11
19 / 100
2000 ms 9976 KB
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
using namespace std;
const int N = 4105;
int n, m, k, P[N], Q[N];
bitset < N > B[N], M[N], cant;
inline int Diff(int i, int j)
{
    return ((B[i] ^ B[j]).count());
    /*int diff = m;
    for (int w = 0; w <= 3; w ++)
        diff -= (B[i][w] & B[j][w]).count();
    return (diff);*/
}
mt19937 Rnd(chrono::steady_clock::now().time_since_epoch().count());
int main()
{
    scanf("%d%d%d", &n, &m, &k);
    getchar();
    for (int i = 1; i <= n; i++, getchar())
    {
        for (int j = 1; j <= m; j++)
        {
            B[i][j] = (getchar() == 'A');
            /*int ch = getchar();
            if (ch == 'A') ch = 0;
            else if (ch == 'C') ch = 1;
            else if (ch == 'G') ch = 2;
            else ch = 3;
            B[i][ch][j] = 1;*/
        }
    }
    iota(P, P + n + 1, 0);
    iota(Q, Q + n + 1, 0);
    shuffle(Q + 1, Q + n + 1, Rnd);
    for (int i = 1; i <= n; i++)
    {
        int &id = Q[i];
        M[id][id] = 1;
        if (cant[id])
            continue;
        if (i % 50 == 0)
            shuffle(P + 1, P + n + 1, Rnd);
        int j = 1;
        for (; j <= n; j++)
        {
            if (!M[id][P[j]] && Diff(id, P[j]) != k)
            {
                M[id][P[j]] = M[P[j]][id] = 1;
                cant[P[j]] = 1;
                break;
            }
        }
        if (j > n)
            return !printf("%d\n", id);
    }
    assert(0);
}

Compilation message

genetics.cpp: In function 'int main()':
genetics.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 221 ms 1868 KB Output is correct
2 Correct 287 ms 2296 KB Output is correct
3 Correct 290 ms 2372 KB Output is correct
4 Correct 101 ms 1528 KB Output is correct
5 Correct 271 ms 2212 KB Output is correct
6 Correct 263 ms 2336 KB Output is correct
7 Correct 50 ms 1148 KB Output is correct
8 Correct 58 ms 1148 KB Output is correct
9 Correct 82 ms 1912 KB Output is correct
10 Correct 197 ms 2164 KB Output is correct
11 Correct 139 ms 1784 KB Output is correct
12 Correct 190 ms 1912 KB Output is correct
13 Correct 218 ms 2040 KB Output is correct
14 Correct 179 ms 1656 KB Output is correct
15 Correct 161 ms 1656 KB Output is correct
16 Correct 217 ms 1784 KB Output is correct
17 Correct 376 ms 2040 KB Output is correct
18 Correct 167 ms 2040 KB Output is correct
19 Correct 206 ms 2168 KB Output is correct
20 Correct 392 ms 2036 KB Output is correct
21 Correct 222 ms 2040 KB Output is correct
22 Correct 110 ms 1784 KB Output is correct
23 Correct 390 ms 2044 KB Output is correct
24 Correct 190 ms 2168 KB Output is correct
25 Correct 370 ms 2040 KB Output is correct
26 Correct 255 ms 2040 KB Output is correct
27 Correct 122 ms 2040 KB Output is correct
28 Correct 320 ms 2168 KB Output is correct
29 Correct 282 ms 2320 KB Output is correct
30 Correct 62 ms 2168 KB Output is correct
31 Correct 61 ms 2168 KB Output is correct
32 Correct 62 ms 2168 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 221 ms 1868 KB Output is correct
2 Correct 287 ms 2296 KB Output is correct
3 Correct 290 ms 2372 KB Output is correct
4 Correct 101 ms 1528 KB Output is correct
5 Correct 271 ms 2212 KB Output is correct
6 Correct 263 ms 2336 KB Output is correct
7 Correct 50 ms 1148 KB Output is correct
8 Correct 58 ms 1148 KB Output is correct
9 Correct 82 ms 1912 KB Output is correct
10 Correct 197 ms 2164 KB Output is correct
11 Correct 139 ms 1784 KB Output is correct
12 Correct 190 ms 1912 KB Output is correct
13 Correct 218 ms 2040 KB Output is correct
14 Correct 179 ms 1656 KB Output is correct
15 Correct 161 ms 1656 KB Output is correct
16 Correct 217 ms 1784 KB Output is correct
17 Correct 376 ms 2040 KB Output is correct
18 Correct 167 ms 2040 KB Output is correct
19 Correct 206 ms 2168 KB Output is correct
20 Correct 392 ms 2036 KB Output is correct
21 Correct 222 ms 2040 KB Output is correct
22 Correct 110 ms 1784 KB Output is correct
23 Correct 390 ms 2044 KB Output is correct
24 Correct 190 ms 2168 KB Output is correct
25 Correct 370 ms 2040 KB Output is correct
26 Correct 255 ms 2040 KB Output is correct
27 Correct 122 ms 2040 KB Output is correct
28 Correct 320 ms 2168 KB Output is correct
29 Correct 282 ms 2320 KB Output is correct
30 Correct 62 ms 2168 KB Output is correct
31 Correct 61 ms 2168 KB Output is correct
32 Correct 62 ms 2168 KB Output is correct
33 Correct 5 ms 376 KB Output is correct
34 Correct 5 ms 376 KB Output is correct
35 Correct 5 ms 376 KB Output is correct
36 Correct 1236 ms 4092 KB Output is correct
37 Correct 1100 ms 4760 KB Output is correct
38 Correct 566 ms 3960 KB Output is correct
39 Correct 265 ms 3708 KB Output is correct
40 Correct 1368 ms 4600 KB Output is correct
41 Correct 361 ms 7800 KB Output is correct
42 Correct 430 ms 7928 KB Output is correct
43 Correct 286 ms 8568 KB Output is correct
44 Correct 439 ms 9336 KB Output is correct
45 Correct 868 ms 9592 KB Output is correct
46 Correct 930 ms 9976 KB Output is correct
47 Correct 1600 ms 9720 KB Output is correct
48 Correct 740 ms 6560 KB Output is correct
49 Correct 753 ms 6264 KB Output is correct
50 Correct 1161 ms 6420 KB Output is correct
51 Correct 539 ms 6268 KB Output is correct
52 Correct 1797 ms 7032 KB Output is correct
53 Execution timed out 2081 ms 7036 KB Time limit exceeded
54 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -