제출 #1129085

#제출 시각아이디문제언어결과실행 시간메모리
1129085LudisseyGenetics (BOI18_genetics)C++20
19 / 100
2058 ms136836 KiB
#include <bits/stdc++.h> #define int long long #define sz(a) (int)a.size() #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() using namespace std; int popcount_u128(__uint128_t value) { // Cast and split into two 64-bit halves uint64_t lower = (uint64_t)value; // Lower 64 bits uint64_t upper = (uint64_t)(value >> 64); // Upper 64 bits // Use __builtin_popcountll for each half and sum the results return __builtin_popcountll(lower) + __builtin_popcountll(upper); } signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n,m,k; cin >> n >> m >> k; int blocks=(m/128)+1; vector<vector<__uint128_t>> a_c(n,vector<__uint128_t>(blocks+1)); vector<vector<__uint128_t>> g_t(n,vector<__uint128_t>(blocks+1)); vector<int> c(n); int mn=1e18; int mx=0; for (int i = 0; i < n; i++) { int j=0; int bl=0; while(j<m){ char hc; cin >> hc; if(hc=='A') { a_c[i][bl]+=((__uint128_t)1<<j); c[i]++; } j++; if(j%128==0) bl++; } mn=min(mn,c[i]); mx=max(mx,c[i]); } vector<vector<int>> dist(n,vector<int>(n,1e18)); for (int i = 0; i < n; i++) { if(c[i]-mn>k||mx-c[i]>k) continue; for (int j = 0; j < n; j++) { if(i==j) continue; if(dist[i][j]<1e18) continue; dist[i][j]=0; for (int _k = 0; _k < blocks; _k++) { dist[i][j]+=popcount_u128(a_c[i][_k]^a_c[j][_k]); } dist[j][i]=dist[i][j]; } } for (int i = 0; i < n; i++) { if(c[i]-mn>k||mx-c[i]>k) continue; bool b=true; for (int j = 0; j < n; j++) { if(i==j) continue; if(dist[i][j]!=k) { b=false; break; } } if(b==true){ cout << i+1 << "\n"; break; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...