제출 #553970

#제출 시각아이디문제언어결과실행 시간메모리
553970Vladth11Genetics (BOI18_genetics)C++14
100 / 100
468 ms30028 KiB
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
 
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;
 
const ll NMAX = 4101;
const ll VMAX = 1001;
const ll INF = (1LL << 60);
const ll MOD = 1000000007;
const ll BLOCK = 447;
const ll base = 31;
const ll nr_of_bits = 19;
 
ll n, m, k;
string s[NMAX];
ll w[NMAX];
ll cost[NMAX][4];
ll total = 0;
 
int cod(char L){
    if(L == 'A') return 0;
    if(L == 'G') return 1;
    if(L == 'C') return 2;
    if(L == 'T') return 3;
}
 
int main() {
    srand(time(0));
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i;
    cin >> n >> m >> k;
    for(i = 1; i <= n; i++){
        cin >> s[i];
        w[i] = rand() % MOD;
        total += w[i];
      	if(total >= MOD) total -= MOD;
        for(int j = 0; j < m; j++){
            cost[j][cod(s[i][j])] += w[i];
            if(cost[j][cod(s[i][j])] >= MOD)
              	cost[j][cod(s[i][j])] -= MOD;
        }
    }
    for(i = 1; i <= n; i++){
        ll target = (total - w[i] + MOD) % MOD;
        target *= k;
        target %= MOD;
        for(int j = 0; j < m; j++){
            for(int t = 0; t < 4; t++){
                if(t == cod(s[i][j])) continue;
                target = target - cost[j][t];
                if(target < 0)
                    target += MOD;
            }
        }
        if(target == 0){
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

genetics.cpp: In function 'int cod(char)':
genetics.cpp:29:1: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...