Submission #1063801

# Submission time Handle Problem Language Result Execution time Memory
1063801 2024-08-18T03:23:35 Z 12345678 Mars (APIO22_mars) C++17
6 / 100
8 ms 2916 KB
#include "mars.h"
#include <bits/stdc++.h>

using namespace std;

int dx[]={1, 0, 0, -1}, dy[]={0, 1, -1, 0};

std::string process(std::vector <std::vector<std::string>> a, int _i, int _j, int _k, int n)
{
    vector<vector<int>> vs(2*n+1, vector<int> (2*n+1, 0)), mp(2*n+1, vector<int> (2*n+1, 0));
    if (n==1) for (int i=0; i<2*n+1; i++) for (int j=0; j<2*n+1; j++) mp[i][j]=a[i][j][0]-'0';
    else
    {
        if (_k==0)
        {
            string res(100, '0');
            for (int i=0; i<3; i++) for (int j=0; j<3; j++) res[3*i+j]=a[i][j][0];
            return res;
        }
        else
        {
            for (int i=0; i<3; i++) for (int j=0; j<3; j++) for (int x=0; x<3; x++) for (int y=0; y<3; y++) mp[i+x][j+y]=a[i][j][3*x+y]-'0';
        }
    }
    int cnt=0;
    for (int i=0; i<2*n+1; i++)
    {
        for (int j=0; j<2*n+1; j++)
        {
            if (!vs[i][j]&&mp[i][j])
            {
                queue<pair<int, int>> q;
                vs[i][j]=1;
                q.push({i, j});
                cnt++;
                while (!q.empty())
                {
                    auto [x, y]=q.front();
                    q.pop();
                    for (int dr=0; dr<4; dr++)
                    {
                        int cx=x+dx[dr], cy=y+dy[dr];
                        if (cx<0||cx>2*n||cy<0||cy>2*n||vs[cx][cy]||!mp[cx][cy]) continue;
                        vs[cx][cy]=1;
                        q.push({cx, cy});
                    }
                }
            }
        }
    }
    string res(100, '0');
    for (int i=0; i<10; i++) if (cnt&(1<<i)) res[i]='1';
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2744 KB Output is correct
2 Correct 8 ms 2744 KB Output is correct
3 Correct 8 ms 2740 KB Output is correct
4 Correct 8 ms 2836 KB Output is correct
5 Correct 6 ms 2916 KB Output is correct
6 Correct 5 ms 2840 KB Output is correct
7 Incorrect 1 ms 332 KB Incorrect
8 Halted 0 ms 0 KB -