Submission #217294

# Submission time Handle Problem Language Result Execution time Memory
217294 2020-03-29T11:23:08 Z quocnguyen1012 Vođe (COCI17_vode) C++14
120 / 120
798 ms 96636 KB
#include <bits/stdc++.h>

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

const int maxn = 5e3 + 5;

int f[maxn][maxn], num[2][maxn], a[maxn];
int N, M, K;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #ifdef LOCAL
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  #endif // LOCAL
  cin >> N >> M >> K;
  for(int i = 1; i <= N; ++i){
    cin >> a[i];
    f[i][M - 1] = a[i] ^ 1;
    num[a[i] ^ 1][i]++;
  }
  for(int j = M - 2; j >= 0; --j){
    for(int i = 1; i <= N; ++i){
      int nxt = i + 1; if(nxt > N) nxt -= N;
      if(num[a[i]][nxt]) f[i][j] = a[i];
      else f[i][j] = a[i] ^ 1;
    }
    for(int i = 1; i <= N; ++i){
      num[f[i][j]][i]++;
      if(j + K < M) num[f[i][j + K]][i]--;
    }
  }
  for(int i = 1; i <= N; ++i)
    cout << f[i][0] << ' ';
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1408 KB Output is correct
2 Correct 5 ms 896 KB Output is correct
3 Correct 6 ms 1408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1536 KB Output is correct
2 Correct 6 ms 1408 KB Output is correct
3 Correct 6 ms 1536 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2048 KB Output is correct
2 Correct 7 ms 2432 KB Output is correct
3 Correct 7 ms 2304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 3072 KB Output is correct
2 Correct 8 ms 2944 KB Output is correct
3 Correct 7 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2688 KB Output is correct
2 Correct 9 ms 2816 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 19196 KB Output is correct
2 Correct 118 ms 20952 KB Output is correct
3 Correct 734 ms 94820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 225 ms 38528 KB Output is correct
2 Correct 637 ms 94584 KB Output is correct
3 Correct 227 ms 41208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 798 ms 95608 KB Output is correct
2 Correct 12 ms 2560 KB Output is correct
3 Correct 7 ms 1664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 773 ms 96172 KB Output is correct
2 Correct 632 ms 96376 KB Output is correct
3 Correct 657 ms 96636 KB Output is correct