Submission #724420

# Submission time Handle Problem Language Result Execution time Memory
724420 2023-04-15T08:21:48 Z MohamedAliSaidane Mars (APIO22_mars) C++17
0 / 100
1 ms 200 KB
#include<bits/stdc++.h>
#include "mars.h"
#include<ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpi;

#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(),(x).end()

const ll MOD = 1e9 + 7, INF = 1e18;
ll mod(ll x, ll m = MOD) {return (x + m) % m;}


string process(vector<vector<string>> a, int i, int j, int k, int n)
{
    int nx[4] = {1, -1, 0, 0};
    int ny[4] = {0, 0, 1, -1};
    int bs[3][3][100];
    memset(bs, 0, sizeof(bs));
    if(k == 0)
    {
        for(int l = i; l < i + 3; l++)
        {
            for(int p = j; p < j+3; p++)
            {
                int id = (2 * n + 1) * l + p;
                bs[0][0][id] = (int)(a[l - i][p - j][0] - '0');
            }
        }
    }
    else
    {
        for(int l = i; l < i + 3; l++)
        {
            for(int p = j; p < j+3; p++)
            {
                for(int h = 0; h < 100; h++)
                    bs[0][0][h] |=  (int)(a[l][p][h] - '0');
            }
        }
    }
    string ans = "";
    if(k == n -1)
    {
        for(int h = 0; h < 100; h++)
            ans += 'h';

        int mp[2 * n + 1][2 * n + 1];
        memset(mp, 0, sizeof(mp));
        for(int h = 0; h < (2 * n + 1) * (2 * n + 1); h++)
        {
            mp[h/(2 * n + 1)][h % (2 * n + 1)] = bs[0][0][h];
        }
        int vis[2 * n + 1][2 * n + 1];
        memset(vis, 0, sizeof(vis));
        int cnt = 0;
        for(int l =0; l < 2 * n + 1;l ++)
        {
            for(int p = 0; p < 2 * n + 1; p++)
            {
                if(mp[l][p] & (1 - vis[l][p]))
                {
                    cnt++;
                    queue<pii> q;
                    q.push({l, p});
                    vis[l][p] = 1;
                    while(!q.empty())
                    {
                        pii u = q.front();
                        q.pop();
                        for(int h = 0; h < 4; h++)
                        {
                            int x = nx[h] + u.ff;
                            int y = ny[h] + u.ss;
                            if(x >= 0 && x < 2 * n + 1 && y >= 0 && y < 2 * n + 1 &&
                               mp[x][y] && (1 - vis[x][y]))
                            {
                                vis[x][y] = 1;
                                q.push({x, y});
                            }
                        }
                    }
                }
            }
        }
        for(int h =0; h < 20; h++)
        {
            if((1 << h) & cnt)
                ans[h] = '1';
        }
    }
    else
    {
        for(int h = 0; h < 100; h++)
            ans += (char)('0' + (int)(bs[0][0][h]));
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB invalid in
2 Halted 0 ms 0 KB -