Submission #1093621

#TimeUsernameProblemLanguageResultExecution timeMemory
1093621vjudge1Genetics (BOI18_genetics)C++17
100 / 100
349 ms36184 KiB
// #pragma GCC optimize("O3","unroll-loops")
#include <bits/stdc++.h>
using namespace std;

// #define 
#define int long long
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define file "file"
#define bit(x, y) ((y >> x) & 1)
#define __lcm(a, b) a * b / __gcd(a, b)
#define R(x) {cout << x << "\n"; return;}
#define coutf(x) cout << fixed << setprecision(x) 
#define inter(a) cout << a << "\n"; fflush(stdout)

mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// declare
const int N = 4100;
int n, m, k, d[N + 5][4], r[N + 5];
map <char, int> mp;
string s[N + 5];

int rand(int l, int r)
{
    int d = r - l + 1;
    return rnd() % d + l;
}

void Solve()
{
    mp['A'] = 0;
    mp['T'] = 1;
    mp['G'] = 2;
    mp['C'] = 3;
    int sum = 0;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) r[i] = rand(1, 1e9);
    for (int i = 1; i <= n; ++i)
    {
        sum += r[i];
        cin >> s[i];
        for (int j = 1; j <= m; ++j)
            d[j][mp[s[i][j - 1]]] += r[i];
    }
    for (int i = 1; i <= n; ++i)
    {
        int now = 0;
        for (int j = 1; j <= m; ++j)
            now += sum - d[j][mp[s[i][j - 1]]];
        if (now == (sum - r[i]) * k)
            R(i);
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (fopen(file ".inp", "r"))
    {
        freopen (file ".inp", "r", stdin);
        freopen (file ".out", "w", stdout);
    }
    int t = 1;
    // cin >> t;
    while (t--) 
        Solve();
    cerr << "\nTIME: " << 1000 * clock() / CLOCKS_PER_SEC << "ms.";
}

Compilation message (stderr)

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