이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define down '\n'
#define lli long long int
#define ulli unsigned long long int
#define ld long double
using namespace std;
using namespace __gnu_pbds;
const int maxn = 4150;
const int NUM_TEST = 4;
char ADN[] = {'A','C','G','T'};
char a[maxn][maxn];
gp_hash_table< char , lli > save[maxn];
lli n,m,k, sum;
lli val[maxn] , countt[maxn];
void rand_arr()
{
sum = 0;
for( int i = 1; i <= n; i ++ )
{
val[i] = ( rand()%12345678 + 123 );
sum += val[i];
}
for( int i = 1; i <= m; i ++ )
{
for( auto & j : save[i] ) j.second = 0;
}
for( int i = 1; i <= n; i ++ )
{
for( int j = 1; j <= m; j ++ )
{
save[j][ a[i][j] ] += val[i];
}
}
}
void process( int need )
{
rand_arr();
for( int i = 1; i <= n; i ++ )
{
if( countt[i] < need ) continue;
lli summm = 0;
for( int j = 1 ; j <= m; j ++ )
{
for( int k = 0 ; k < 4;k ++ )
{
if( a[i][j] != ADN[k] ) summm += save[j][ ADN[k] ];
}
}
if( summm == ( (sum - val[i] )*k ) ) countt[i]++;
}
}
void read()
{
cin >> n >> m >> k;
for( int i = 1; i <= n; i ++ )
{
for( int j = 1; j <= m; j ++ ) cin >> a[i][j];
}
}
void solve()
{
for( int i = 0 ; i < NUM_TEST; i ++ ) process(i);
for( int i = 1; i <= n; i ++ )
{
if( countt[i] == NUM_TEST )
{
cout << i;
exit(0);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
srand( time(nullptr) );
read();
solve();
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... |