이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int arr[4107][4107],ars[4107][70],uc[4][4107],k,m;
bool c[4107],ps;
bool check(int a,int b)
{
if(ps)
{
int x=0;
for(int i=0;i<m;i++) if(arr[a][i]!=arr[b][i]) x++;
if(x==k) return true;
return false;
}
int x=0;
for(int i=0;i<=m/64+5;i++) x+=__builtin_popcount(ars[a][i] xor ars[b][i]);
if(x==k) return true;
return false;
}
int main()
{
ios::sync_with_stdio(false);
int n;
cin>>n>>m>>k;
string s;
for(int i=0;i<n;i++)
{
cin>>s;
for(int j=0;j<m;j++)
{
if(s[j]=='A') arr[i][j]=0;
if(s[j]=='C') arr[i][j]=1;
if(s[j]=='G') arr[i][j]=2;
if(s[j]=='T') arr[i][j]=3;
if(arr[i][j]>1) ps=true;
uc[arr[i][j]][j]++;
}
}
for(int i=0;i<n;i++) for(int j=0;j<m;j++) ars[i][j/64]+=(arr[i][j]<<(j%64));
/*for(int ttt=0;ttt<200000;ttt++)
{
int x=rand()%n,y=rand()%n;
if(x==y) continue;
int st=0;
if(!check(x,y)) {c[x]=c[y]=true;};
}*/
for(int i=0;i<n;i++) if(!c[i])
{
int skor=0;
bool propo=false;
for(int j=0;j<m;j++) skor+=(n-uc[arr[i][j]][j]);
if(skor!=(n-1)*k) continue;
for(int j=0;j<n;j++) if(i!=j) if(!check(i,j)) {propo=true; break;}
if(propo) continue;
printf("%d",i+1);
return 0;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |