#include<bits/stdc++.h>
#include "grader.h"
using namespace std;
typedef long long lint;
int V[56][65536];
map<lint,int>W[56];
void excerpt(int *E)
{
int l=0,maxi=0,maxind;
int e[65536]={};
for(int i=0;i<100;i++)
{
e[E[i]]++;
if(e[E[i]]>maxi)
{
maxi=e[E[i]];
maxind=E[i];
}
}
maxi=0;
vector<lint>T;
for(int i=0;i<99;i++)
{
if(E[i]!=maxind && E[i+1]!=maxind)
T.push_back(1ll*E[i]*65536+E[i+1]);
}
sort(T.begin(),T.end());
T.erase(unique(T.begin(),T.end()),T.end());
for(int j=0;j<56;j++)
{
int kind=0;
for(auto &i:T)
{
if(W[j][i]>5)kind++;
}
if(kind>maxi)
{
maxi=kind;
l=j;
}
}
if(maxi==0)
{
vector<int>S;
for(int i=0;i<100;i++)if(E[i]!=maxind)S.push_back(E[i]);
sort(S.begin(),S.end());
S.erase(unique(S.begin(),S.end()),S.end());
maxi=-1;
for(int j=0;j<56;j++)
{
int kind=0;
for(auto &i:S)
{
if(V[j][i])kind++;
}
if(kind>maxi)
{
maxi=kind;
l=j;
}
}
}
/*
vector<int>N;
for(int j=0;j<56;j++)
{
int kind=0;
for(int i=0;i<100;i++)
{
if(V[j][E[i]])
{
kind++;
}
}
if(kind==maxi)
{
N.push_back(j);
}
}
srand(time(NULL));
int r=rand();
r%=(int)(N.size());
l=N[r];*/
int L=language(l);
for(int i=0;i<100;i++)
{
if(E[i]!=maxind)V[L][E[i]]++;
}
for(int i=0;i<99;i++)
{
if(E[i]!=maxind && E[i+1]!=maxind)W[L][1ll*E[i]*65536+E[i+1]]++;
}
}
Compilation message
lang.cpp: In function 'void excerpt(int*)':
lang.cpp:93:21: warning: 'maxind' may be used uninitialized in this function [-Wmaybe-uninitialized]
93 | if(E[i]!=maxind && E[i+1]!=maxind)W[L][1ll*E[i]*65536+E[i+1]]++;
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4258 ms |
128244 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
4340 ms |
128152 KB |
Output is partially correct - 69.47% |