답안 #900309

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
900309 2024-01-08T05:34:46 Z cig32 Genetics (BOI18_genetics) C++17
0 / 100
483 ms 12180 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
const int MAXN = 5e5 + 10;
const int MOD = 1e9 + 7;
mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count());
int rnd(int x, int y) {
  int u = uniform_int_distribution<int>(x, y)(rng); return u;
}
int bm(int b, int p) {
  if(p==0) return 1 % MOD;
  int r = bm(b, p >> 1);
  if(p&1) return (((r*r) % MOD) * b) % MOD;
  return (r*r) % MOD;
}
int inv(int b) { 
  return bm(b, MOD-2);
}
int fastlog(int x) {
  return (x == 0 ? -1 : 64 - __builtin_clzll(x) - 1);
}
void printcase(int i) { cout << "Case #" << i << ": "; }
static void run_with_stack_size(void (*func)(void), size_t stsize) {
  char *stack, *send;
  stack = (char *)malloc(stsize);
  send = stack + stsize - 16;
  send = (char *)((uintptr_t)send / 16 * 16);
  asm volatile(
    "mov %%rsp, (%0)\n"
    "mov %0, %%rsp\n"
    :
    : "r"(send));
  func();
  asm volatile("mov (%0), %%rsp\n" : : "r"(send));
  free(stack);
}
void solve(int tc) {
  int n, m;
  cin >> n >> m;
  int k;
  cin >> k;
  int a[m], c[m], g[m], t[m];
  for(int i=0; i<m; i++) {
    a[i] = c[i] = g[i] = t[i] = 0;
  }
  string s[n];
  for(int i=0; i<n; i++) {
    cin >> s[i];
    for(int j=0; j<m; j++) s[i][j] ^= 32;
    for(int j=0; j<m; j++) {
      if(s[i][j] == 'a') a[j]++;
      else if(s[i][j] == 'c') c[j]++;
      else if(s[i][j] == 'g') g[j]++;
      else t[j]++;
    }
  }
  int itr = 0;
  for(int i=0; i<n; i++) {
    int totn = 0;
    for(int j=0; j<m; j++) {
      if(s[i][j] == 'a') totn += c[j] + g[j] + t[j];
      else if(s[i][j] == 'c') totn += a[j] + g[j] + t[j];
      else if(s[i][j] == 'g') totn += a[j] + c[j] + t[j];
      else totn += a[j] + c[j] + g[j];
    }
    if(totn == k * (n - 1)) {
      itr++;
      bool can = 1;
      for(int j=0; j<n; j++) {
        if(i != j) {
          int cnt = 0;
          for(int l=0; l<m; l++) {
            cnt += (s[i][l] != s[j][l]);
          }
          if(cnt != k) {
            can = 0; 
            break;
          }
        }
      }
      if(can) {
        cout << i+1 << '\n'; 
      }
    }
  }
  assert(itr <= ceil(sqrt(n)));
}

void uwu() {
  ios::sync_with_stdio(0); cin.tie(0);
  int t = 1; //cin >> t;
  for(int i=1; i<=t; i++) solve(i);
}
int32_t main() {
  #ifdef ONLINE_JUDGE
  uwu();
  #endif
  #ifndef ONLINE_JUDGE
  run_with_stack_size(uwu, 1024 * 1024 * 1024); // run with a 1 GiB stack
  #endif
}
/*
g++ B.cpp -std=c++17 -O2 -o B
./B < input.txt


*/
# 결과 실행 시간 메모리 Grader output
1 Runtime error 20 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 483 ms 12180 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 483 ms 12180 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 20 ms 600 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -