# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
588408 | Killer2501 | Vođe (COCI17_vode) | C++14 | 1117 ms | 193004 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 ll long long
#define pb push_back
#define task "deleg"
#define pll pair<ll, ll>
#define pii pair<ll, pll>
#define fi first
#define se second
#define ull unsigned long long
using namespace std;
const ll mod = 1e15 + 7;
const ll N = 5e3 + 5;
const ll M = 1e6 + 5;
vector<ll> adj[N], sub[N];
vector<ll> kq;
int n, m, t, k, b[N], a[N], sum[N][N], dp[N][N];
string s[N];
pll p[N];
bool get1(int i, int l, int r)
{
return (sum[i][l] - sum[i][r+1] > 0);
}
bool get0(int i, int l, int r)
{
return (sum[i][l] - sum[i][r+1] < k);
}
void sol()
{
cin >> n >> m >> k;
for(int i = 1; i <= n; i ++)
{
cin >> a[i];
dp[i][m-1] = 0;
sum[i][m-1] = 0;
}
for(int j = m-2; j >= 0; j --)
{
for(int i = 1; i <= n; i ++)
{
int nxt = (i == n ? 1 : i+1);
if(a[i] == a[nxt])
dp[i][j] = get1(nxt, j+1, min(j+k, m-1));
else
dp[i][j] = get0(nxt, j+1, min(j+k, m-1));
}
for(int i = 1; i <= n; i ++)sum[i][j] = sum[i][j+1]+dp[i][j];
}
for(int i = 1; i <= n; i ++)cout << (a[i]^dp[i][0]^1) <<" ";
}
int main()
{
if (fopen(task ".in", "r"))
{
freopen(task ".in", "r", stdin);
freopen(task ".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int ntest = 1;
// cin >> ntest;
while (ntest-- > 0)
sol();
}
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... |
# | 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... |