답안 #140808

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
140808 2019-08-05T09:35:40 Z Minnakhmetov Genetics (BOI18_genetics) C++14
46 / 100
2000 ms 17656 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 4100, K = 4;
string s[N], let = "ACGT";
int a[N], b[N][K];
bool banned[N];

signed main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);

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

    mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

    for (int i = 0; i < n; i++) {
        a[i] = i;
        while (s[i].empty())
            getline(cin, s[i]);
        for (int j = 0; j < m; j++) {
            s[i][j] = find(all(let), s[i][j]) - let.begin();
            b[j][s[i][j]]++;
        }
    }

    for (int i = 0; i < m; i++) {
        int sum = 0;
        for (int j = 0; j < K; j++) {
            sum += b[i][j];
        }
        for (int j = 0; j < K; j++) {
            b[i][j] = sum - b[i][j];
        }
    }

    shuffle(a, a + n, rng);

    for (int h = 0; h < n; h++) {
        int i = a[h];

        if (banned[i])
            continue;

        ll sum = 0;
        for (int j = 0; j < m; j++) {
            sum += b[j][s[i][j]];
        }

        if (sum != k * (n - 1))
            continue;

        bool ok = true;
        for (int j = 0; j < n; j++) {
            if (i != j) {
                int d = 0;
                for (int k = 0; k < m; k++) {
                    if (s[i][k] != s[j][k])
                        d++;
                }
                if (d != k) {
                    banned[j] = 1;
                    ok = false;
                }
            }
        }
        if (ok) {
            cout << i + 1;
            return 0;
        }
    }
    
    return 0;
}

Compilation message

genetics.cpp: In function 'int main()':
genetics.cpp:31:25: warning: array subscript has type 'char' [-Wchar-subscripts]
             b[j][s[i][j]]++;
                         ^
genetics.cpp:55:32: warning: array subscript has type 'char' [-Wchar-subscripts]
             sum += b[j][s[i][j]];
                                ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 3192 KB Output is correct
2 Correct 52 ms 3832 KB Output is correct
3 Correct 52 ms 3704 KB Output is correct
4 Correct 15 ms 1144 KB Output is correct
5 Correct 52 ms 3960 KB Output is correct
6 Correct 52 ms 3832 KB Output is correct
7 Correct 26 ms 1912 KB Output is correct
8 Correct 25 ms 1912 KB Output is correct
9 Correct 260 ms 3832 KB Output is correct
10 Correct 182 ms 3704 KB Output is correct
11 Correct 746 ms 3320 KB Output is correct
12 Correct 129 ms 3320 KB Output is correct
13 Correct 64 ms 3320 KB Output is correct
14 Correct 43 ms 2936 KB Output is correct
15 Correct 119 ms 2808 KB Output is correct
16 Correct 42 ms 2808 KB Output is correct
17 Correct 51 ms 3704 KB Output is correct
18 Correct 51 ms 3704 KB Output is correct
19 Correct 53 ms 4472 KB Output is correct
20 Correct 56 ms 4344 KB Output is correct
21 Correct 53 ms 4472 KB Output is correct
22 Correct 52 ms 4344 KB Output is correct
23 Correct 51 ms 4344 KB Output is correct
24 Correct 56 ms 4472 KB Output is correct
25 Correct 55 ms 4344 KB Output is correct
26 Correct 51 ms 4344 KB Output is correct
27 Correct 50 ms 4344 KB Output is correct
28 Correct 51 ms 4344 KB Output is correct
29 Correct 55 ms 4344 KB Output is correct
30 Correct 54 ms 3964 KB Output is correct
31 Correct 51 ms 3964 KB Output is correct
32 Correct 54 ms 3960 KB Output is correct
33 Correct 5 ms 504 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 5 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 3192 KB Output is correct
2 Correct 52 ms 3832 KB Output is correct
3 Correct 52 ms 3704 KB Output is correct
4 Correct 15 ms 1144 KB Output is correct
5 Correct 52 ms 3960 KB Output is correct
6 Correct 52 ms 3832 KB Output is correct
7 Correct 26 ms 1912 KB Output is correct
8 Correct 25 ms 1912 KB Output is correct
9 Correct 260 ms 3832 KB Output is correct
10 Correct 182 ms 3704 KB Output is correct
11 Correct 746 ms 3320 KB Output is correct
12 Correct 129 ms 3320 KB Output is correct
13 Correct 64 ms 3320 KB Output is correct
14 Correct 43 ms 2936 KB Output is correct
15 Correct 119 ms 2808 KB Output is correct
16 Correct 42 ms 2808 KB Output is correct
17 Correct 51 ms 3704 KB Output is correct
18 Correct 51 ms 3704 KB Output is correct
19 Correct 53 ms 4472 KB Output is correct
20 Correct 56 ms 4344 KB Output is correct
21 Correct 53 ms 4472 KB Output is correct
22 Correct 52 ms 4344 KB Output is correct
23 Correct 51 ms 4344 KB Output is correct
24 Correct 56 ms 4472 KB Output is correct
25 Correct 55 ms 4344 KB Output is correct
26 Correct 51 ms 4344 KB Output is correct
27 Correct 50 ms 4344 KB Output is correct
28 Correct 51 ms 4344 KB Output is correct
29 Correct 55 ms 4344 KB Output is correct
30 Correct 54 ms 3964 KB Output is correct
31 Correct 51 ms 3964 KB Output is correct
32 Correct 54 ms 3960 KB Output is correct
33 Correct 5 ms 504 KB Output is correct
34 Correct 5 ms 504 KB Output is correct
35 Correct 5 ms 504 KB Output is correct
36 Execution timed out 2078 ms 17656 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 504 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 5 ms 504 KB Output is correct
4 Correct 5 ms 504 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 5 ms 504 KB Output is correct
8 Correct 5 ms 504 KB Output is correct
9 Correct 5 ms 504 KB Output is correct
10 Correct 5 ms 504 KB Output is correct
11 Correct 5 ms 504 KB Output is correct
12 Correct 5 ms 504 KB Output is correct
13 Correct 5 ms 504 KB Output is correct
14 Correct 5 ms 504 KB Output is correct
15 Correct 5 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 5 ms 504 KB Output is correct
18 Correct 154 ms 3192 KB Output is correct
19 Correct 52 ms 3832 KB Output is correct
20 Correct 52 ms 3704 KB Output is correct
21 Correct 15 ms 1144 KB Output is correct
22 Correct 52 ms 3960 KB Output is correct
23 Correct 52 ms 3832 KB Output is correct
24 Correct 26 ms 1912 KB Output is correct
25 Correct 25 ms 1912 KB Output is correct
26 Correct 260 ms 3832 KB Output is correct
27 Correct 182 ms 3704 KB Output is correct
28 Correct 746 ms 3320 KB Output is correct
29 Correct 129 ms 3320 KB Output is correct
30 Correct 64 ms 3320 KB Output is correct
31 Correct 43 ms 2936 KB Output is correct
32 Correct 119 ms 2808 KB Output is correct
33 Correct 42 ms 2808 KB Output is correct
34 Correct 51 ms 3704 KB Output is correct
35 Correct 51 ms 3704 KB Output is correct
36 Correct 53 ms 4472 KB Output is correct
37 Correct 56 ms 4344 KB Output is correct
38 Correct 53 ms 4472 KB Output is correct
39 Correct 52 ms 4344 KB Output is correct
40 Correct 51 ms 4344 KB Output is correct
41 Correct 56 ms 4472 KB Output is correct
42 Correct 55 ms 4344 KB Output is correct
43 Correct 51 ms 4344 KB Output is correct
44 Correct 50 ms 4344 KB Output is correct
45 Correct 51 ms 4344 KB Output is correct
46 Correct 55 ms 4344 KB Output is correct
47 Correct 54 ms 3964 KB Output is correct
48 Correct 51 ms 3964 KB Output is correct
49 Correct 54 ms 3960 KB Output is correct
50 Correct 5 ms 504 KB Output is correct
51 Correct 5 ms 504 KB Output is correct
52 Correct 5 ms 504 KB Output is correct
53 Execution timed out 2078 ms 17656 KB Time limit exceeded
54 Halted 0 ms 0 KB -