Submission #1093523

#TimeUsernameProblemLanguageResultExecution timeMemory
1093523ThanhsGenetics (BOI18_genetics)C++14
100 / 100
372 ms148308 KiB
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define int long long
#define endl '\n'
#define setmin(x, y) x = ((x) < (y) ? (x) : (y))
#define setmax(x, y) x = ((x) > (y) ? (x) : (y))

mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}

const int NM = 4100 + 5;

int n, m, k, a[NM][NM], c[NM][5], v[NM];

void solve()    
{
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++)
        v[i] = rand(1, 1e12);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
        {
            char t;
            cin >> t;
            a[i][j] = (t == 'A' ? 0 : t == 'C' ? 1 : t == 'G' ? 2 : 3);
            c[j][a[i][j]] += v[i];
            c[j][4] += v[i];
        }
    int tar = accumulate(v + 1, v + 1 + n, 0ll) * k;
    for (int i = 1; i <= n; i++)
    {
        int sum = 0;
        for (int j = 1; j <= m; j++)
            sum += c[j][4] - c[j][a[i][j]];
        if (sum == tar - v[i] * k)
        {
            cout << i;
            return;
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    if (fopen("in.txt", "r")) 
    {
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    }
    // freopen("storagebox.inp", "r", stdin);
    // freopen("storagebox.out", "w", stdout);
    int tc = 1; 
    // cin >> tc;
    while (tc--)
        solve();
}

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:51:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |         freopen("in.txt", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen("out.txt", "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...