Submission #104584

# Submission time Handle Problem Language Result Execution time Memory
104584 2019-04-08T09:34:09 Z daili Genetics (BOI18_genetics) C++14
46 / 100
2000 ms 4676 KB
#include <bits/stdc++.h>

using namespace std;

int diff(string a, string b)
{
    int cnt = 0;
    for (int i = 0; i < a.size() ; i++)
    {
        if (a[i] != b[i])
        {
            cnt++;
        }
    }
    return cnt;
}

void Task1(int n, int m ,int k)
{
    vector<string> all;
    for (int i =0; i <n ; i++)
    {
        string x;
        cin >> x;

        all.push_back(x);
    }

    for (int i = 0; i < n; i++)
    {
        bool flag = true;
        for (int j = 0; j < n; j++)
        {
            if (i == j)
            {
                continue;
            }

            if (diff(all[i], all[j]) != k)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            cout << i+1 << "\n";
            return;
        }
    }
}

void TaskBC(int n, const int m, int k)
{
    vector<bitset<4101> > all;
    for (int i = 0; i < n; i++)
    {
        bitset<4101> bit;
        string x;
        cin >> x;

        for (int j = 0; j < m; j++)
        {
            if (x[j] == 'A')
            {
                bit[j] = 1;
            }
        }
        all.push_back(bit);
    }

    for (int i = 0; i < n; i++)
    {
        bool flag = true;
        for (int j = 0; j < n; j++)
        {
            if (i == j)
            {
                continue;
            }

            bitset<4101> xr = all[i] ^ all[j];
            if (xr.count() != k)
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            cout << i+1 << "\n";
            return;
        }
    }

}



signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;

    if (n <= 100 && m <= 100)
    {
        Task1(n, m, k);
    }
    else
    {
        TaskBC(n, m, k);
    }
}

Compilation message

genetics.cpp: In function 'int diff(std::__cxx11::string, std::__cxx11::string)':
genetics.cpp:8:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size() ; i++)
                     ~~^~~~~~~~~~
genetics.cpp: In function 'void TaskBC(int, int, int)':
genetics.cpp:83:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if (xr.count() != k)
                 ~~~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 8 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 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 633 ms 1516 KB Output is correct
2 Correct 357 ms 1516 KB Output is correct
3 Correct 923 ms 1516 KB Output is correct
4 Correct 180 ms 1516 KB Output is correct
5 Correct 74 ms 1560 KB Output is correct
6 Correct 208 ms 1516 KB Output is correct
7 Correct 94 ms 1016 KB Output is correct
8 Correct 83 ms 1012 KB Output is correct
9 Correct 29 ms 1512 KB Output is correct
10 Correct 527 ms 1512 KB Output is correct
11 Correct 127 ms 1512 KB Output is correct
12 Correct 37 ms 1640 KB Output is correct
13 Correct 121 ms 1512 KB Output is correct
14 Correct 265 ms 1512 KB Output is correct
15 Correct 96 ms 1512 KB Output is correct
16 Correct 154 ms 1516 KB Output is correct
17 Correct 303 ms 1516 KB Output is correct
18 Correct 52 ms 1516 KB Output is correct
19 Correct 308 ms 1516 KB Output is correct
20 Correct 173 ms 1516 KB Output is correct
21 Correct 505 ms 1516 KB Output is correct
22 Correct 757 ms 1516 KB Output is correct
23 Correct 806 ms 1512 KB Output is correct
24 Correct 471 ms 1516 KB Output is correct
25 Correct 78 ms 1516 KB Output is correct
26 Correct 353 ms 1524 KB Output is correct
27 Correct 208 ms 1512 KB Output is correct
28 Correct 171 ms 1520 KB Output is correct
29 Correct 491 ms 1512 KB Output is correct
30 Correct 18 ms 1516 KB Output is correct
31 Correct 19 ms 1516 KB Output is correct
32 Correct 30 ms 1508 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 633 ms 1516 KB Output is correct
2 Correct 357 ms 1516 KB Output is correct
3 Correct 923 ms 1516 KB Output is correct
4 Correct 180 ms 1516 KB Output is correct
5 Correct 74 ms 1560 KB Output is correct
6 Correct 208 ms 1516 KB Output is correct
7 Correct 94 ms 1016 KB Output is correct
8 Correct 83 ms 1012 KB Output is correct
9 Correct 29 ms 1512 KB Output is correct
10 Correct 527 ms 1512 KB Output is correct
11 Correct 127 ms 1512 KB Output is correct
12 Correct 37 ms 1640 KB Output is correct
13 Correct 121 ms 1512 KB Output is correct
14 Correct 265 ms 1512 KB Output is correct
15 Correct 96 ms 1512 KB Output is correct
16 Correct 154 ms 1516 KB Output is correct
17 Correct 303 ms 1516 KB Output is correct
18 Correct 52 ms 1516 KB Output is correct
19 Correct 308 ms 1516 KB Output is correct
20 Correct 173 ms 1516 KB Output is correct
21 Correct 505 ms 1516 KB Output is correct
22 Correct 757 ms 1516 KB Output is correct
23 Correct 806 ms 1512 KB Output is correct
24 Correct 471 ms 1516 KB Output is correct
25 Correct 78 ms 1516 KB Output is correct
26 Correct 353 ms 1524 KB Output is correct
27 Correct 208 ms 1512 KB Output is correct
28 Correct 171 ms 1520 KB Output is correct
29 Correct 491 ms 1512 KB Output is correct
30 Correct 18 ms 1516 KB Output is correct
31 Correct 19 ms 1516 KB Output is correct
32 Correct 30 ms 1508 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 1889 ms 2524 KB Output is correct
37 Correct 921 ms 4676 KB Output is correct
38 Execution timed out 2085 ms 2520 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 380 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 8 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 633 ms 1516 KB Output is correct
19 Correct 357 ms 1516 KB Output is correct
20 Correct 923 ms 1516 KB Output is correct
21 Correct 180 ms 1516 KB Output is correct
22 Correct 74 ms 1560 KB Output is correct
23 Correct 208 ms 1516 KB Output is correct
24 Correct 94 ms 1016 KB Output is correct
25 Correct 83 ms 1012 KB Output is correct
26 Correct 29 ms 1512 KB Output is correct
27 Correct 527 ms 1512 KB Output is correct
28 Correct 127 ms 1512 KB Output is correct
29 Correct 37 ms 1640 KB Output is correct
30 Correct 121 ms 1512 KB Output is correct
31 Correct 265 ms 1512 KB Output is correct
32 Correct 96 ms 1512 KB Output is correct
33 Correct 154 ms 1516 KB Output is correct
34 Correct 303 ms 1516 KB Output is correct
35 Correct 52 ms 1516 KB Output is correct
36 Correct 308 ms 1516 KB Output is correct
37 Correct 173 ms 1516 KB Output is correct
38 Correct 505 ms 1516 KB Output is correct
39 Correct 757 ms 1516 KB Output is correct
40 Correct 806 ms 1512 KB Output is correct
41 Correct 471 ms 1516 KB Output is correct
42 Correct 78 ms 1516 KB Output is correct
43 Correct 353 ms 1524 KB Output is correct
44 Correct 208 ms 1512 KB Output is correct
45 Correct 171 ms 1520 KB Output is correct
46 Correct 491 ms 1512 KB Output is correct
47 Correct 18 ms 1516 KB Output is correct
48 Correct 19 ms 1516 KB Output is correct
49 Correct 30 ms 1508 KB Output is correct
50 Correct 5 ms 376 KB Output is correct
51 Correct 5 ms 376 KB Output is correct
52 Correct 5 ms 376 KB Output is correct
53 Correct 1889 ms 2524 KB Output is correct
54 Correct 921 ms 4676 KB Output is correct
55 Execution timed out 2085 ms 2520 KB Time limit exceeded
56 Halted 0 ms 0 KB -