Submission #777952

#TimeUsernameProblemLanguageResultExecution timeMemory
777952TheSahibGenetics (BOI18_genetics)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")

#include <bits/stdc++.h> 
 
#define ll long long
#define ull unsigned ll
#define oo 1e9
#define pii pair<int, int>
 
using namespace std;
 
const int MAX = 4105;
const int SIZE = (MAX / 128 + 1) * 4;

int n, m, k;

struct bs{
    __uint128_t arr[SIZE];
    bs(){
        memset(arr, 0, sizeof(arr));
    }
    void setBit(int pos){
        arr[pos / 128] |= (__uint128_t(1) << (pos % 128));
    }
};

int band(bs& a, bs& b){
    int cnt = 0;
    for (int i = 0; i < SIZE; i++)
    {
        cnt += __popcount(a.arr[i] & b.arr[i]);
    }
    return cnt;
}

bs st[MAX];

int comp(int a, int b){
    return m - band(st[a], st[b]);
}

int ans[MAX];

void solve(){
    scanf("%d%d%d", &n, &m, &k);
    for (int i = 0; i < n; i++)
    {
        getchar();
        for (int j = 0; j < m; j++)
        {
            char c = getchar();
            if(c == 'G') c = 'B';
            if(c == 'T') c = 'D';
            st[i].setBit((c - 'A') * MAX + j);
        }
    }
    
    vector<int> v;
    v.resize(n);
    iota(v.begin(), v.end(), 0);
    srand(time(0));
    random_shuffle(v.begin(), v.end());
    
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if(comp(v[i], v[j]) == k){
                ans[v[i]]++;
                ans[v[j]]++;
            }
        }
        if(ans[v[i]] == n - 1){
            cout << v[i] + 1 << '\n';
            return;
        }
    }
}
 
int main()
{
    solve();
}

Compilation message (stderr)

In file included from /usr/include/c++/10/bits/range_access.h:38,
                 from /usr/include/c++/10/string:54,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from genetics.cpp:4:
/usr/include/c++/10/bits/int_limits.h: In instantiation of 'struct std::__detail::__int_limits<__int128 unsigned, false>':
/usr/include/c++/10/bit:185:47:   required from 'constexpr int std::__popcount(_Tp) [with _Tp = __int128 unsigned]'
genetics.cpp:32:46:   required from here
/usr/include/c++/10/bits/int_limits.h:63:39: error: static assertion failed: unsupported specialization
   63 |       static_assert(is_integral<_Tp>::value, "unsupported specialization");
      |                                       ^~~~~
genetics.cpp: In function 'void solve()':
genetics.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |     scanf("%d%d%d", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~