Submission #1001747

#TimeUsernameProblemLanguageResultExecution timeMemory
1001747WhisperGenetics (BOI18_genetics)C++17
27 / 100
66 ms18000 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

//#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPD(i, n) for (int i = (n) - 1; i >= 0; --i)

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)


constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
    Phu Trong from Nguyen Tat Thanh High School for gifted student
*/

template <class X, class Y>
    bool minimize(X &x, const Y &y){
        X eps = 1e-9;
        if (x > y + eps) {x = y; return 1;}
        return 0;
    }

template <class X, class Y>
    bool maximize(X &x, const Y &y){
        X eps = 1e-9;
        if (x + eps < y) {x = y; return 1;}
        return 0;
    }
int numPeople, l, dif;
#define N   4100
int nw(char c){
    if (c == 'A') return 0;
    if (c == 'T') return 1;
    if (c == 'G') return 2;
    return 3;
}

int Rand(int l = 1, int h = 1e10){
    return uniform_int_distribution<int>(l, h)(rng);
}

char A[N + 5][N + 5], val[N + 5];
int sm[N + 5][N + 5];

void process(void){
    cin >> numPeople >> l >> dif;

    int sum = 0;
    for (int i = 1; i <= numPeople; ++i){
        val[i] = Rand();
        sum += val[i];
    }
    for (int i = 1; i <= numPeople; ++i){
        for (int j = 1; j <= l; ++j){
            cin >> A[i][j];
            sm[j][nw(A[i][j])] += val[i];
        }
    }

    for (int i = 1; i <= numPeople; ++i){
        int tot = 0;
        for (int j = 1; j <= l; ++j){
            tot += sum - sm[j][nw(A[i][j])];
        }
        if (tot == (sum - val[i]) * dif) return void(cout << i);
    }
}

signed main(){
    #define name "Whisper"
    cin.tie(nullptr) -> sync_with_stdio(false);
    //freopen(name".inp", "r", stdin);
    //freopen(name".out", "w", stdout);

    process();
}




Compilation message (stderr)

genetics.cpp:47:33: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
   47 | int Rand(int l = 1, int h = 1e10){
      |                                 ^
genetics.cpp: In function 'void process()':
genetics.cpp:59:23: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
   59 |         val[i] = Rand();
      |                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...