QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#507236 | #5254. Differences | ucup-team1525# | RE | 0ms | 0kb | C++17 | 1.2kb | 2024-08-06 14:16:36 | 2024-08-06 14:16:36 |
answer
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
string s[N];
int n,m,K;
mt19937 rnd(19260817);
#define ll long long
ll a[N][4];
int main()
{
// scanf("%d%d%d",&n,&m,&K);
ios::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>m>>K;
for (int i=1;i<=n;++i)
{
cin>>s[i];
for (int j=0;j<m;++j)
a[j][s[i][j]-'A']++;
}
vector<int> v;
for (int i=1;i<=n;++i)
{
int sum=0;
for (int j=0;j<m;++j)
sum+=(n-a[j][s[i][j]-'A']);
if (sum==(n-1)*K)
v.push_back(i);
}
while (v.size()!=1)
{
ll rndsum=0;
for (int i=0;i<m;++i)
for (int j=0;j<4;++j)
a[i][j]=0;
for (int i=1;i<=n;++i)
{
v[i]=rnd();
rndsum+=v[i];
for (int j=0;j<m;++j)
a[j][s[i][j]-'A']+=v[i];
}
vector<int> v2;
for (int x:v)
{
ll sum=0;
for (int j=0;j<m;++j)
sum+=(rndsum-a[j][s[x][j]-'A']);
if (sum==(rndsum-v[x])*K)
v2.push_back(x);
}
v=v2;
}
printf("%d\n",v[0]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
3585 4096 2048 ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...