Submission #1078891

#TimeUsernameProblemLanguageResultExecution timeMemory
1078891Neco_arcGenetics (BOI18_genetics)C++17
100 / 100
289 ms33620 KiB
#include <bits/stdc++.h>
#ifdef LOCAL
#include <bits/debug.hpp>
#endif // LOCAL

#define ll long long
#define all(x) x.begin(), x.end()
#define Neco "Genetics"
#define resp(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define getbit(x,i) ((x >> i)&1)
#define _left id * 2, l, mid
#define _right id * 2 + 1, mid + 1, r
#define cntbit(x) __builtin_popcountll(x)
#define fi(i, a, b) for(int i = a; i <= b; i++)
#define fid(i, a, b) for(int i = a; i >= b; i--)
#define maxn (int) 4102

using namespace std;

const ll mod = 1e9 + 7; //972663749
const ll base = 911382323;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll GetRandom(ll l, ll r) {
    return uniform_int_distribution<ll> (l, r)(rng);
}

int n, m, k;
char a[maxn][maxn];
ll Rnd[maxn], P[maxn];
ll S[maxn];

void solve()
{

    cin >> n >> m >> k;
    fi(i, 1, n) fi(j, 1, m) cin >> a[i][j];

    fi(j, 1, m)
    {
        ll All = 0;
        S['A'] = S['G'] = S['T'] = S['C'] = 0;

        fi(i, 1, n) {
            All += Rnd[i];
            S[a[i][j]] += Rnd[i];
        }

        fi(i, 1, n) P[i] += All - S[a[i][j]];
    }

    ll Sum = 0;
    fi(i, 1, n) Sum += 1ll * Rnd[i] * k;

    fi(i, 1, n) {
        ll w = 1ll * Rnd[i] * k;
        if(P[i] == Sum - w) return cout << i, void();
    }

}


int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    if(fopen(Neco".inp", "r")) {
        freopen(Neco".inp", "r", stdin);
        freopen(Neco".out", "w", stdout);
    }

    fi(i, 1, maxn - 2) Rnd[i] = GetRandom(1, 1e18);

    int nTest = 1;
//    cin >> nTest;


    while(nTest--)
    {
        solve();
    }


    return 0;
}

Compilation message (stderr)

genetics.cpp: In function 'void solve()':
genetics.cpp:46:21: warning: array subscript has type 'char' [-Wchar-subscripts]
   46 |             S[a[i][j]] += Rnd[i];
      |               ~~~~~~^
genetics.cpp:49:43: warning: array subscript has type 'char' [-Wchar-subscripts]
   49 |         fi(i, 1, n) P[i] += All - S[a[i][j]];
      |                                     ~~~~~~^
genetics.cpp: In function 'int main()':
genetics.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(Neco".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:72:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen(Neco".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...