Submission #237128

# Submission time Handle Problem Language Result Execution time Memory
237128 2020-06-04T17:45:25 Z Vimmer Vođe (COCI17_vode) C++14
72 / 120
3000 ms 392340 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[10005][10005];

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 193 ms 392188 KB Output is correct
2 Correct 197 ms 392160 KB Output is correct
3 Correct 200 ms 392076 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 199 ms 392056 KB Output is correct
2 Correct 202 ms 392188 KB Output is correct
3 Correct 224 ms 392184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 199 ms 392056 KB Output is correct
2 Correct 215 ms 392312 KB Output is correct
3 Correct 196 ms 392184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 211 ms 392056 KB Output is correct
2 Correct 230 ms 392184 KB Output is correct
3 Correct 199 ms 392056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 207 ms 392056 KB Output is correct
2 Correct 218 ms 392340 KB Output is correct
3 Correct 269 ms 392184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 195 ms 392056 KB Output is correct
2 Correct 228 ms 392112 KB Output is correct
3 Correct 197 ms 392056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 399 ms 392288 KB Output is correct
2 Correct 1745 ms 392248 KB Output is correct
3 Execution timed out 3121 ms 392184 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 2499 ms 392184 KB Output is correct
2 Execution timed out 3122 ms 392184 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3107 ms 392184 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3114 ms 392184 KB Time limit exceeded
2 Halted 0 ms 0 KB -