Submission #976443

# Submission time Handle Problem Language Result Execution time Memory
976443 2024-05-06T14:57:43 Z Unforgettablepl Mars (APIO22_mars) C++17
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int get_idx(int i,int j,int n){
    return i*(2*n+1) + j;
}

bool grid[11][11];
bool visited[11][11];

void dfs(int i,int j){
    if(visited[i][j] or !grid[i][j])return;
    visited[i][j]=true;
    dfs(i-1,j);
    dfs(i,j-1);
    dfs(i+1,j);
    dfs(i,j+1);
}

string process(vector<vector<string>> a, int32_t i, int32_t j, int32_t k, int32_t n){
    string ans(100,'0');
    for(int offseti = 0;offseti<3;offseti++){
        for(int offsetj=0;offsetj<3;offsetj++){
            if(a[offseti][offsetj][0]=='1')ans[get_idx(i+offseti,j+offsetj,n)+1]='1';
            for(int x=1;x<=81;x++)if(a[offseti][offsetj][x]=='1')ans[x]='1';
        }
    }
    if(k==n-1){
        // TODO code the dfs
        for(int x=1;x<=81;x++){
            if(ans[x]!='1')continue;
            int newx = (x-1)/(2*n+1);
            int newy = (x-1)%(2*n+1);
            grid[newx+1][newy+1]=true;
        }
        int cans = 0;
        for(int x=1;x<=9;x++){
            for(int y=1;y<=9;y++){
                if(grid[x][y] and !visited[x][y]){dfs(x,y);cans++;}
            }
        }
        ans = string(100,'0');
        for(int bit=0;bit<=31;bit++){
            if(cans&(1ll<<bit))ans[bit]='1';
        }
    }
    return ans;
}

//static void WA(string msg)
//{
//    cout << "WA: " << msg << endl;
//    exit(0);
//}
//
//static long long to_longlong(string s)
//{
//    long long ans=0;
//    for(int32_t i=(int32_t)s.size()-1;i>=0;i--)
//        ans=(ans*2)+s[i]-'0';
//    return ans;
//}
//
//int32_t main()
//{
//    int32_t t;
//    assert(scanf("%d",&t) == 1);
//    while(t--)
//    {
//        int32_t n;
//        assert(scanf("%d",&n) == 1);
//
//        vector <vector<char>> s(2*n+1, vector<char>(2*n+1));
//        for(int32_t i = 0; i < 2*n+1; i++)
//            for(int32_t j = 0; j < 2*n+1; j++)
//                assert(scanf(" %c",&s[i][j]) == 1);
//
//        vector <vector<string>> h(2*n+1, vector<string>(2*n+1, string(100 ,'0')));
//        for(int32_t i = 0; i < 2*n+1; i++)
//            for(int32_t j = 0; j < 2*n+1; j++)
//                h[i][j][0] = s[i][j];
//
//        vector <vector<string>> subarr(3, vector<string>(3));
//        for(int32_t k = 0; k < n; k++)
//        {
//            int32_t m = 2*(n-k-1);
//            for(int32_t i = 0; i <= m; i++)
//            {
//                for(int32_t j = 0; j <= m; j++)
//                {
//                    for(int32_t y = 0; y < 3; y++)
//                    {
//                        for(int32_t x = 0; x < 3; x++)
//                        {
//                            subarr[y][x] = h[i+y][j+x];
//                        }
//                    }
//                    h[i][j] = process(subarr, i, j, k, n);
//
//                    if(h[i][j].size() != 100) WA("Invalid return length");
//                    for(int32_t l = 0; l < 100; l++)
//                        if(h[i][j][l] != '0' && h[i][j][l] != '1') WA("Invalid return");
//                }
//            }
//        }
//
//        printf("%lld\n",to_longlong(h[0][0]));
//    }
//}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -