# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
473995 | ZaZo_ | Lottery (CEOI18_lot) | C++14 | 3067 ms | 31780 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ZAZO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
const int N = 2010;
using namespace std;
int n , l ,q;
int v[N][N];
int ans[10005]={0},arr[10005];
int32_t main() {
ZAZO
cin >> n >> l ;
string s="";
for(int i = 0 ; i < n ; i ++)
{
cin >> arr[i];
s+=arr[i]+'0';
}
cin>>q;
int flg=0;
for(int i = 0 ; i < q ; i++){
int k;
cin>>k;
if(k==0 && q==1)
{
for(int i = 0 ; i < s.size()-l+1 ; i++)
{
string a = s.substr(i , l);
for(int j = i+1 ; j < s.size()-l+1 ; j++)
{
string b = s.substr(j , l);
if(a==b) ans[i]++,ans[j]++;
}
}
for(int i = 0 ; i < n-l+1 ; i++)
{
cout<<ans[i]<<" ";
}
}
else
{
if(!flg)
{
flg=1;
for(int i = 0 ; i < n-l+1 ; i ++)
{
for(int j = i+1 ; j < n-l+1 ; j ++)
{
int cur=0;
for(int p = 0 ; p < l ; p ++) if(arr[i+p] != arr[j+p] ) cur++;
v[i][j]=v[j][i]=cur;
}
}
}
for(int i = 0 ; i < n-l+1 ; i ++)
{
ans[i]=-1;
for(int j = 0 ; j < n-l+1 ; j++)
{
if(v[i][j]<=k) ans[i]++;
}
cout<<ans[i]<<" ";
}
cout<<'\n';
}
}
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |