QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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;
}
詳細信息
Test #1:
score: 0
Runtime Error
input:
3585 4096 2048 ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...