Submission #237127

# Submission time Handle Problem Language Result Execution time Memory
237127 2020-06-04T17:44:54 Z Vimmer Vođe (COCI17_vode) C++14
72 / 120
1601 ms 199288 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 50001
#define M ll(1e9 + 7)
#define inf 1e9 + 1e9

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef short int si;
typedef array <int, 2> a2;

//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;



int f[5005][5005];

int main()
{
    //freopen("input.txt", "r", stdin); //freopen("output4.txt", "w", stdout);

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, m, k;

    cin >> n >> m >> k;

    int nm = n + m;

    int a[nm];

    int j = 0;

    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = n; i < nm; i++) a[i] = a[j++];

    memset(f, -1, sizeof(f));

    for (int i = 0; i < nm; i++) f[i][m - 1] = 0;

    for (int i = nm - 1; i > 0; i--)
      for (int j = m - 1; j >= 0; j--)
        {
            if (f[i][j] == -1) continue;

            if (a[i - 1] == a[i])
                for (int u = j - 1; u >= max(0, j - k); u--) f[i - 1][u] = (f[i - 1][u] == -1 ? f[i][j] : f[i - 1][u] | f[i][j]);
            else
                for (int u = j - 1; u >= max(0, j - k); u--) f[i - 1][u] = (f[i - 1][u] == -1 ? (1 + f[i][j]) % 2 : f[i - 1][u] | (1 + f[i][j]) % 2);
        }

    for (int i = 0; i < n; i++)
        if (f[i][0]) cout << a[i] << " "; else cout << (1 + a[i]) % 2 << " ";
}
# Verdict Execution time Memory Grader output
1 Correct 53 ms 98424 KB Output is correct
2 Correct 52 ms 98424 KB Output is correct
3 Correct 52 ms 98424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 98424 KB Output is correct
2 Correct 56 ms 98424 KB Output is correct
3 Correct 84 ms 98424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 98424 KB Output is correct
2 Correct 71 ms 98424 KB Output is correct
3 Correct 57 ms 98424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 98552 KB Output is correct
2 Correct 88 ms 98424 KB Output is correct
3 Correct 60 ms 98424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 66 ms 98424 KB Output is correct
2 Correct 70 ms 98424 KB Output is correct
3 Correct 131 ms 98424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 98424 KB Output is correct
2 Correct 85 ms 98512 KB Output is correct
3 Correct 52 ms 98424 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 234 ms 98552 KB Output is correct
2 Correct 1601 ms 98448 KB Output is correct
3 Runtime error 161 ms 199288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 164 ms 199160 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 160 ms 199160 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 167 ms 199288 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -