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>
using namespace std;
signed main()
{
int n, m, k;
cin >> n >> m >> k;
vector <int> a(n);
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
vector <vector <int> > dp(m + n, vector <int> (m, 0));
vector <vector <int> > up1(m + n, vector <int> (m, 1e9));
vector <vector <int> > up2(m + n, vector <int> (m, 1e9));
for(int i = m + n - 1; i >= 0; i--)
{
for(int j = m - 1; j >= 0; j--)
{
if(i == m + n - 1 || j == m - 1)
{
dp[i][j] = 0;
}
else if(a[(i + 1) % n] == a[i % n])
{
if(up1[i + 1][j + 1] <= j + k)
{
dp[i][j] = 1;
}
else
{
dp[i][j] = 0;
}
}
else
{
if(up2[i + 1][j + 1] <= j + k)
{
dp[i][j] = 1;
}
else
{
dp[i][j] = 0;
}
}
if(dp[i][j] == 0)
{
if(j != m - 1)
{
up1[i][j] = up1[i][j + 1];
}
up2[i][j] = j;
}
else
{
if(j != m - 1)
{
up2[i][j] = up2[i][j + 1];
}
up1[i][j] = j;
}
}
}
for(int i = 0; i < n; i++)
{
if(a[i] == 0)
{
if(dp[i][0])
{
cout << 0 << " ";
}
else
{
cout << 1 << " ";
}
}
else
{
if(dp[i][0])
{
cout << 1 << " ";
}
else
{
cout << 0 << " ";
}
}
}
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... |
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |