Submission #1063933

# Submission time Handle Problem Language Result Execution time Memory
1063933 2024-08-18T06:18:12 Z 12345678 Mars (APIO22_mars) C++17
0 / 100
0 ms 336 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(3*n+1, vector<int> (3*n+1, 0)), mp(3*n+1, vector<int> (3*n+1, 0));
    for (int i=0; i<3; i++) 
    {
        for (int j=0; j<3; j++) 
        {
            for (int k=0; k<(2*n+1)*(2*n+1); k++) 
            {
                    mp[i+(k/(2*n+1))][j+(k%(2*n+1))]=a[i][j][k];
            }
        }
    }
    if (_k!=n-1)
    {
        string res(100, '0'); 
        for (int i=0; i<2*n+1; i++) for (int j=0; j<2*n+1; j++) res[(2*n+1)*i+j]=mp[i][j];
        //cout<<res<<'\n';
        return res;
    }
    /*
    for (int i=0; i<5; i++) 
    {
        for (int j=0; j<5;j ++) cout<<mp[i][j]-'0'<<' ';
        cout<<'\n';
    }*/
    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]=='1')
            {
                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]=='0') 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 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 336 KB Incorrect
2 Halted 0 ms 0 KB -