Submission #724422

# Submission time Handle Problem Language Result Execution time Memory
724422 2023-04-15T08:26:18 Z MohamedAliSaidane Mars (APIO22_mars) C++17
6 / 100
8 ms 2104 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[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[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[h] |=  (int)(a[l][p][h] - '0');
            }
        }
    }
    string ans = "";
    if(k == n -1)
    {
        for(int h = 0; h < 100; h++)
            ans += '0';

        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[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[h]));
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1884 KB Output is correct
2 Correct 8 ms 2104 KB Output is correct
3 Correct 8 ms 1960 KB Output is correct
4 Correct 7 ms 1724 KB Output is correct
5 Correct 8 ms 2036 KB Output is correct
6 Correct 8 ms 1984 KB Output is correct
7 Runtime error 1 ms 412 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -