제출 #997753

#제출 시각아이디문제언어결과실행 시간메모리
997753MarwenElarbiGenetics (BOI18_genetics)C++17
74 / 100
1767 ms47188 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define fi first #define se second #define ll long long #define pb push_back #define ii pair<int,int> const int nax=4100; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int main(){ int n,m,k; cin>>n>>m>>k; if(n<=100){ string tab[n]; vector<int> per(n); for (int i = 0; i < n; ++i) { per[i]=i; cin>>tab[i]; } //shuffle(per.begin(),per.end(),rng); bool vis[n]; memset(vis,0,sizeof vis); //int cnt=0; for (int i = 0; i < n; ++i) { //if(vis[i]) continue; //if(cnt>10) break; //cnt++; bool test=true; for (int j = 0; j < n; ++j) { //if(vis[j]||j==i) continue; if(i==j) continue; int cur=0; for (int t = 0; t < m; ++t) { if(tab[i][t]!=tab[j][t]) cur++; if(cur>k) break; } if(cur!=k){ test=false; } } if(test){ cout <<i+1<<endl; return 0; } } for (int i = 0; i < n; ++i) { if(vis[i]==0){ cout <<i+1<<endl; break; } } }else{ string tab[n]; vector<bitset<nax>> b(n); vector<int> per(n); for (int i = 0; i < n; ++i) { per[i]=i; cin>>tab[i]; for (int j = 0; j < m; ++j) { if(tab[i][j]=='A') b[i][j]=1; else b[i][j]=0; } } bool vis[n]; memset(vis,0,sizeof vis); int cnt=0; for (int i = 0; i < n; ++i) { if(vis[i]==1) continue; shuffle(per.begin(),per.end(),rng); for (int j = 0; j < n; ++j) { if(per[j]==i) continue; auto cnt=b[i]^b[per[j]]; int cur=cnt.count(); if(cur!=k){ vis[per[j]]=1; vis[i]=1; break; } } if(vis[i]==0){ cout <<i+1<<endl; return 0; } } } }

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

genetics.cpp: In function 'int main()':
genetics.cpp:75:13: warning: unused variable 'cnt' [-Wunused-variable]
   75 |         int cnt=0;
      |             ^~~
In file included from /usr/include/string.h:495,
                 from /usr/include/c++/10/cstring:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:48,
                 from genetics.cpp:1:
In function 'void* memset(void*, int, size_t)',
    inlined from 'int main()' at genetics.cpp:25:15:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:71:33: warning: 'void* __builtin_memset(void*, int, long unsigned int)' specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   71 |   return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
      |          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...