Submission #66099900


Source Code Expand

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define int long long
#define nl "\n"
#define oo 1e9 + 1
#define OO 1e18 + 1
#define sp ' '
#define sz(x) (int)(x.size())
#define MOD 1000000007
#define fixed(n) fixed << setprecision(n)
#define sub_mod(a, b, m) ((((a) % m) - ((b) % m) + m) % m)
#define add_mod(a, b, m) ((((a) % m) + ((b) % m)) % m)
#define mult_mod(a, b, m) ((((a) % m) * ((b) % m)) % m)
#define EPS 1e-9
#define PI acos(-1)
using namespace __gnu_pbds;
using namespace std;

int n, m, mx_val = 0;
vector<vector<int>> a;
vector<vector<bool>> vis;
void rec(int i = 0, int j = 0, int cur_xor = 0)
{
    if (i == n)
    {
        mx_val = max(mx_val, cur_xor);
        return;
    }
    if (j == m)
    {
        rec(i + 1, 0, cur_xor);
        return;
    }
    if (vis[i][j])
    {
        rec(i, j + 1, cur_xor);
        return;
    }

    if (j + 1 < m && !vis[i][j + 1])
    {
        vis[i][j] = vis[i][j + 1] = true;
        rec(i, j + 2, cur_xor);
        vis[i][j] = vis[i][j + 1] = false;
    }
 
    if (i + 1 < n && !vis[i + 1][j])
    {
        vis[i][j] = vis[i + 1][j] = true;
        rec(i, j + 1, cur_xor);
        vis[i][j] = vis[i + 1][j] = false;
    }
    

    rec(i, j + 1, cur_xor ^ a[i][j]);
}
void solve()
{
    cin >> n >> m;
    a.resize(n, vector<int>(m));
    vis.resize(n, vector<bool>(m, false));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }
    rec(0, 0, 0);
    cout << mx_val << nl;
}
signed main(void)
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    int tc = 1;
    //cin >> tc;
    while (tc--)
    {
        solve();
    }
    return 0;
}

Submission Info

Submission Time
Task D - Domino Covering XOR
User Mazen_Ghanayem
Language C++ 23 (gcc 12.2)
Score 425
Code Size 1888 Byte
Status AC
Exec Time 3 ms
Memory 3616 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 51
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt, 01_random_40.txt, 01_random_41.txt, 01_random_42.txt, 01_random_43.txt, 01_random_44.txt, 01_random_45.txt, 01_random_46.txt, 01_random_47.txt, 01_random_48.txt, 01_random_49.txt, 01_random_50.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3532 KiB
00_sample_01.txt AC 1 ms 3424 KiB
00_sample_02.txt AC 2 ms 3428 KiB
01_random_03.txt AC 1 ms 3420 KiB
01_random_04.txt AC 2 ms 3420 KiB
01_random_05.txt AC 2 ms 3412 KiB
01_random_06.txt AC 2 ms 3612 KiB
01_random_07.txt AC 2 ms 3428 KiB
01_random_08.txt AC 1 ms 3484 KiB
01_random_09.txt AC 1 ms 3496 KiB
01_random_10.txt AC 2 ms 3492 KiB
01_random_11.txt AC 2 ms 3544 KiB
01_random_12.txt AC 2 ms 3484 KiB
01_random_13.txt AC 2 ms 3452 KiB
01_random_14.txt AC 1 ms 3412 KiB
01_random_15.txt AC 1 ms 3448 KiB
01_random_16.txt AC 1 ms 3444 KiB
01_random_17.txt AC 1 ms 3328 KiB
01_random_18.txt AC 1 ms 3488 KiB
01_random_19.txt AC 2 ms 3616 KiB
01_random_20.txt AC 1 ms 3444 KiB
01_random_21.txt AC 1 ms 3388 KiB
01_random_22.txt AC 1 ms 3428 KiB
01_random_23.txt AC 1 ms 3484 KiB
01_random_24.txt AC 3 ms 3336 KiB
01_random_25.txt AC 1 ms 3428 KiB
01_random_26.txt AC 1 ms 3332 KiB
01_random_27.txt AC 1 ms 3404 KiB
01_random_28.txt AC 1 ms 3288 KiB
01_random_29.txt AC 1 ms 3428 KiB
01_random_30.txt AC 1 ms 3420 KiB
01_random_31.txt AC 2 ms 3532 KiB
01_random_32.txt AC 1 ms 3488 KiB
01_random_33.txt AC 1 ms 3444 KiB
01_random_34.txt AC 1 ms 3492 KiB
01_random_35.txt AC 1 ms 3484 KiB
01_random_36.txt AC 1 ms 3468 KiB
01_random_37.txt AC 1 ms 3404 KiB
01_random_38.txt AC 2 ms 3464 KiB
01_random_39.txt AC 2 ms 3472 KiB
01_random_40.txt AC 2 ms 3612 KiB
01_random_41.txt AC 2 ms 3488 KiB
01_random_42.txt AC 1 ms 3528 KiB
01_random_43.txt AC 2 ms 3540 KiB
01_random_44.txt AC 2 ms 3488 KiB
01_random_45.txt AC 2 ms 3616 KiB
01_random_46.txt AC 1 ms 3424 KiB
01_random_47.txt AC 1 ms 3468 KiB
01_random_48.txt AC 1 ms 3316 KiB
01_random_49.txt AC 1 ms 3392 KiB
01_random_50.txt AC 1 ms 3332 KiB