Submission #59565

# Submission time Handle Problem Language Result Execution time Memory
59565 2018-07-22T11:23:52 Z Benq Genetics (BOI18_genetics) C++11
100 / 100
1075 ms 20856 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

ll po (ll b, ll p) { return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD; }
ll inv (ll b) { return po(b,MOD-2); }

int ad(int a, int b) { return (a+b)%MOD; }
int sub(int a, int b) { return (a-b+MOD)%MOD; }
int mul(int a, int b) { return (ll)a*b%MOD; }

pi operator+(const pi& l, const pi& r) { return {ad(l.f,r.f),ad(l.s,r.s)}; }
pi operator-(const pi& l, const pi& r) { return {sub(l.f,r.f),sub(l.s,r.s)}; }
pi operator*(const pi& l, const pi& r) { return {mul(l.f,r.f),mul(l.s,r.s)}; }
pi operator*(const pi& l, const int& r) { return l*pi(r,r); }
pi operator*(const int& r, const pi& l) { return l*r; }

pi operator+=(pi& l, const pi& r) { return l = l+r; }
pi operator-=(pi& l, const pi& r) { return l = l-r; }
template<class T> pi operator*=(pi& l, const T& r) { return l = l*r; }

std::ostream& operator<<(std::ostream &strm, const pi& a) {
    strm << a.f << " " << a.s << " | ";
    return strm;
}

int N,M,K;
string S[4100];
pi hsh[4100], ans[4100], sum;

int get(char c) {
    if (c == 'A') return 0;
    if (c == 'C') return 1;
    if (c == 'G') return 2;
    return 3;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N >> M >> K;
    F0R(i,N) {
        cin >> S[i];
        hsh[i] = {rand()%MOD,rand()%MOD};
        sum += hsh[i];
    }
    F0R(i,M) {
        array<pi,4> tmp = array<pi,4>();
        F0R(j,N) tmp[get(S[j][i])] += hsh[j];
        F0R(j,N) ans[j] += sum-tmp[get(S[j][i])];
    }
    F0R(i,N) if (ans[i] == K*(sum-hsh[i])) cout << i+1;
}

/* Look for:
* the exact constraints (multiple sets are too slow for n=10^6 :( ) 
* special cases (n=1?)
* overflow (ll vs int?)
* array bounds
*/
# Verdict Execution time Memory 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 508 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
# Verdict Execution time Memory Grader output
1 Correct 64 ms 3192 KB Output is correct
2 Correct 63 ms 4728 KB Output is correct
3 Correct 77 ms 4472 KB Output is correct
4 Correct 19 ms 1400 KB Output is correct
5 Correct 70 ms 4600 KB Output is correct
6 Correct 72 ms 4600 KB Output is correct
7 Correct 35 ms 2424 KB Output is correct
8 Correct 32 ms 2424 KB Output is correct
9 Correct 76 ms 4344 KB Output is correct
10 Correct 73 ms 4344 KB Output is correct
11 Correct 65 ms 3960 KB Output is correct
12 Correct 70 ms 3960 KB Output is correct
13 Correct 65 ms 3960 KB Output is correct
14 Correct 56 ms 3576 KB Output is correct
15 Correct 56 ms 3576 KB Output is correct
16 Correct 56 ms 3576 KB Output is correct
17 Correct 75 ms 4472 KB Output is correct
18 Correct 73 ms 4472 KB Output is correct
19 Correct 74 ms 4472 KB Output is correct
20 Correct 74 ms 4472 KB Output is correct
21 Correct 78 ms 4600 KB Output is correct
22 Correct 76 ms 4472 KB Output is correct
23 Correct 77 ms 4472 KB Output is correct
24 Correct 73 ms 4472 KB Output is correct
25 Correct 76 ms 4472 KB Output is correct
26 Correct 77 ms 4472 KB Output is correct
27 Correct 74 ms 4472 KB Output is correct
28 Correct 76 ms 4472 KB Output is correct
29 Correct 76 ms 4472 KB Output is correct
30 Correct 63 ms 4600 KB Output is correct
31 Correct 59 ms 4600 KB Output is correct
32 Correct 82 ms 4600 KB Output is correct
33 Correct 5 ms 516 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 3192 KB Output is correct
2 Correct 63 ms 4728 KB Output is correct
3 Correct 77 ms 4472 KB Output is correct
4 Correct 19 ms 1400 KB Output is correct
5 Correct 70 ms 4600 KB Output is correct
6 Correct 72 ms 4600 KB Output is correct
7 Correct 35 ms 2424 KB Output is correct
8 Correct 32 ms 2424 KB Output is correct
9 Correct 76 ms 4344 KB Output is correct
10 Correct 73 ms 4344 KB Output is correct
11 Correct 65 ms 3960 KB Output is correct
12 Correct 70 ms 3960 KB Output is correct
13 Correct 65 ms 3960 KB Output is correct
14 Correct 56 ms 3576 KB Output is correct
15 Correct 56 ms 3576 KB Output is correct
16 Correct 56 ms 3576 KB Output is correct
17 Correct 75 ms 4472 KB Output is correct
18 Correct 73 ms 4472 KB Output is correct
19 Correct 74 ms 4472 KB Output is correct
20 Correct 74 ms 4472 KB Output is correct
21 Correct 78 ms 4600 KB Output is correct
22 Correct 76 ms 4472 KB Output is correct
23 Correct 77 ms 4472 KB Output is correct
24 Correct 73 ms 4472 KB Output is correct
25 Correct 76 ms 4472 KB Output is correct
26 Correct 77 ms 4472 KB Output is correct
27 Correct 74 ms 4472 KB Output is correct
28 Correct 76 ms 4472 KB Output is correct
29 Correct 76 ms 4472 KB Output is correct
30 Correct 63 ms 4600 KB Output is correct
31 Correct 59 ms 4600 KB Output is correct
32 Correct 82 ms 4600 KB Output is correct
33 Correct 5 ms 516 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 5 ms 504 KB Output is correct
36 Correct 595 ms 18556 KB Output is correct
37 Correct 586 ms 20504 KB Output is correct
38 Correct 643 ms 20472 KB Output is correct
39 Correct 176 ms 7544 KB Output is correct
40 Correct 628 ms 20324 KB Output is correct
41 Correct 339 ms 10872 KB Output is correct
42 Correct 278 ms 10744 KB Output is correct
43 Correct 463 ms 14588 KB Output is correct
44 Correct 671 ms 20856 KB Output is correct
45 Correct 664 ms 20728 KB Output is correct
46 Correct 677 ms 20728 KB Output is correct
47 Correct 569 ms 18424 KB Output is correct
48 Correct 580 ms 18552 KB Output is correct
49 Correct 475 ms 15768 KB Output is correct
50 Correct 460 ms 15740 KB Output is correct
51 Correct 521 ms 17272 KB Output is correct
52 Correct 634 ms 20216 KB Output is correct
53 Correct 652 ms 20216 KB Output is correct
54 Correct 521 ms 19192 KB Output is correct
55 Correct 537 ms 19064 KB Output is correct
56 Correct 560 ms 19164 KB Output is correct
57 Correct 621 ms 20344 KB Output is correct
58 Correct 637 ms 20340 KB Output is correct
59 Correct 622 ms 20088 KB Output is correct
60 Correct 637 ms 20216 KB Output is correct
61 Correct 637 ms 20216 KB Output is correct
62 Correct 640 ms 20600 KB Output is correct
63 Correct 631 ms 20472 KB Output is correct
64 Correct 650 ms 20216 KB Output is correct
65 Correct 625 ms 20284 KB Output is correct
66 Correct 634 ms 20344 KB Output is correct
67 Correct 634 ms 20344 KB Output is correct
68 Correct 647 ms 20472 KB Output is correct
69 Correct 685 ms 20344 KB Output is correct
70 Correct 634 ms 20344 KB Output is correct
71 Correct 619 ms 20472 KB Output is correct
72 Correct 642 ms 20472 KB Output is correct
73 Correct 620 ms 20284 KB Output is correct
74 Correct 5 ms 504 KB Output is correct
75 Correct 5 ms 504 KB Output is correct
76 Correct 5 ms 504 KB Output is correct
# Verdict Execution time Memory 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 508 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 64 ms 3192 KB Output is correct
19 Correct 63 ms 4728 KB Output is correct
20 Correct 77 ms 4472 KB Output is correct
21 Correct 19 ms 1400 KB Output is correct
22 Correct 70 ms 4600 KB Output is correct
23 Correct 72 ms 4600 KB Output is correct
24 Correct 35 ms 2424 KB Output is correct
25 Correct 32 ms 2424 KB Output is correct
26 Correct 76 ms 4344 KB Output is correct
27 Correct 73 ms 4344 KB Output is correct
28 Correct 65 ms 3960 KB Output is correct
29 Correct 70 ms 3960 KB Output is correct
30 Correct 65 ms 3960 KB Output is correct
31 Correct 56 ms 3576 KB Output is correct
32 Correct 56 ms 3576 KB Output is correct
33 Correct 56 ms 3576 KB Output is correct
34 Correct 75 ms 4472 KB Output is correct
35 Correct 73 ms 4472 KB Output is correct
36 Correct 74 ms 4472 KB Output is correct
37 Correct 74 ms 4472 KB Output is correct
38 Correct 78 ms 4600 KB Output is correct
39 Correct 76 ms 4472 KB Output is correct
40 Correct 77 ms 4472 KB Output is correct
41 Correct 73 ms 4472 KB Output is correct
42 Correct 76 ms 4472 KB Output is correct
43 Correct 77 ms 4472 KB Output is correct
44 Correct 74 ms 4472 KB Output is correct
45 Correct 76 ms 4472 KB Output is correct
46 Correct 76 ms 4472 KB Output is correct
47 Correct 63 ms 4600 KB Output is correct
48 Correct 59 ms 4600 KB Output is correct
49 Correct 82 ms 4600 KB Output is correct
50 Correct 5 ms 516 KB Output is correct
51 Correct 6 ms 504 KB Output is correct
52 Correct 5 ms 504 KB Output is correct
53 Correct 595 ms 18556 KB Output is correct
54 Correct 586 ms 20504 KB Output is correct
55 Correct 643 ms 20472 KB Output is correct
56 Correct 176 ms 7544 KB Output is correct
57 Correct 628 ms 20324 KB Output is correct
58 Correct 339 ms 10872 KB Output is correct
59 Correct 278 ms 10744 KB Output is correct
60 Correct 463 ms 14588 KB Output is correct
61 Correct 671 ms 20856 KB Output is correct
62 Correct 664 ms 20728 KB Output is correct
63 Correct 677 ms 20728 KB Output is correct
64 Correct 569 ms 18424 KB Output is correct
65 Correct 580 ms 18552 KB Output is correct
66 Correct 475 ms 15768 KB Output is correct
67 Correct 460 ms 15740 KB Output is correct
68 Correct 521 ms 17272 KB Output is correct
69 Correct 634 ms 20216 KB Output is correct
70 Correct 652 ms 20216 KB Output is correct
71 Correct 521 ms 19192 KB Output is correct
72 Correct 537 ms 19064 KB Output is correct
73 Correct 560 ms 19164 KB Output is correct
74 Correct 621 ms 20344 KB Output is correct
75 Correct 637 ms 20340 KB Output is correct
76 Correct 622 ms 20088 KB Output is correct
77 Correct 637 ms 20216 KB Output is correct
78 Correct 637 ms 20216 KB Output is correct
79 Correct 640 ms 20600 KB Output is correct
80 Correct 631 ms 20472 KB Output is correct
81 Correct 650 ms 20216 KB Output is correct
82 Correct 625 ms 20284 KB Output is correct
83 Correct 634 ms 20344 KB Output is correct
84 Correct 634 ms 20344 KB Output is correct
85 Correct 647 ms 20472 KB Output is correct
86 Correct 685 ms 20344 KB Output is correct
87 Correct 634 ms 20344 KB Output is correct
88 Correct 619 ms 20472 KB Output is correct
89 Correct 642 ms 20472 KB Output is correct
90 Correct 620 ms 20284 KB Output is correct
91 Correct 5 ms 504 KB Output is correct
92 Correct 5 ms 504 KB Output is correct
93 Correct 5 ms 504 KB Output is correct
94 Correct 987 ms 19960 KB Output is correct
95 Correct 774 ms 20216 KB Output is correct
96 Correct 1050 ms 20344 KB Output is correct
97 Correct 419 ms 11368 KB Output is correct
98 Correct 187 ms 7292 KB Output is correct
99 Correct 589 ms 20088 KB Output is correct
100 Correct 342 ms 10744 KB Output is correct
101 Correct 357 ms 10744 KB Output is correct
102 Correct 457 ms 14456 KB Output is correct
103 Correct 644 ms 20600 KB Output is correct
104 Correct 1074 ms 20728 KB Output is correct
105 Correct 1056 ms 20600 KB Output is correct
106 Correct 1010 ms 19736 KB Output is correct
107 Correct 567 ms 18344 KB Output is correct
108 Correct 463 ms 15864 KB Output is correct
109 Correct 872 ms 18040 KB Output is correct
110 Correct 574 ms 16680 KB Output is correct
111 Correct 827 ms 20608 KB Output is correct
112 Correct 1075 ms 20472 KB Output is correct
113 Correct 659 ms 19192 KB Output is correct
114 Correct 530 ms 19192 KB Output is correct
115 Correct 673 ms 19192 KB Output is correct
116 Correct 1060 ms 20344 KB Output is correct
117 Correct 1038 ms 20216 KB Output is correct
118 Correct 1052 ms 20216 KB Output is correct
119 Correct 1048 ms 20220 KB Output is correct
120 Correct 1060 ms 20088 KB Output is correct
121 Correct 556 ms 18168 KB Output is correct
122 Correct 574 ms 19704 KB Output is correct
123 Correct 643 ms 20088 KB Output is correct
124 Correct 5 ms 504 KB Output is correct
125 Correct 5 ms 504 KB Output is correct
126 Correct 5 ms 504 KB Output is correct