답안 #744311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
744311 2023-05-18T11:52:21 Z saayan007 화성 (APIO22_mars) C++17
0 / 100
10 ms 2276 KB
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
#define nl endl
#include "mars.h"

int toInt(string x) {
    int res = 0;
    for(int i = 99; i >= 0; --i) {
        res *= 2;
        if(x[i] == '1') ++res;
    }
    return res;
}

string toStr(int x) {
    string res = "";
    for(int i = 0; i < 100; ++i) {
        if(x & 1) res += "1";
        else res += "0";
        x /= 2;
    }
    return res;
}

int dfs(vector<vector<string>> &a, int x, int y, vector<vector<bool>> &vis) {
    /* cout << x << ' ' << y << endl; */
    vis[x][y] = 1;
    int res = 1;
    for(int dx : {-1, 0, 1}) for(int dy : {-1, 0, 1}) if(abs(dx) != abs(dy)) {
        int X = x + dx, Y = y + dy;
        if(X < 0 || X > 2 || Y < 0 || Y > 2 || vis[X][Y] || a[X][Y][0] == '0') continue;
        res += dfs(a, X, Y, vis);
    }
    return res;
}

string process(vector <vector<string>> a, int i, int j, int k, int n)
{
    /* cout << i << ' ' << j << ' ' << k << ' ' << n << endl; */
    int res = 0;
    if(n == 2) {
        if(k == 0) {
            if(i == 1 || j == 1) {
                /* cout << endl; */
                return toStr(0);
            }
            vector<vector<bool>> vis(3, vector<bool>(3, 0));
            for(int di = 0; di < 3; ++di) for(int dj = 0; dj < 3; ++dj) if(a[di][dj][0] == '0') vis[di][dj] = 1;
            if(i != 0) {
                for(int dj = 0; dj < 3; ++dj) {
                    if(!vis[0][dj]) {
                        dfs(a, 0, dj, vis);
                    }
                }
            }
            if(j != 0) {
                for(int di = 0; di < 3; ++di) {
                    if(!vis[di][0]) {
                        dfs(a, di, 0, vis);
                    }
                }
            }
            /* for(int di = 0; di < 3; ++di) { */
            /*     for(int dj = 0; dj < 3; ++dj) { */
            /*         cout << vis[di][dj] << ' '; */
            /*     } */
            /*     cout << nl; */
            /* } */
            for(int di = 0; di < 3; ++di) {
                for(int dj = 0; dj < 3; ++dj) {
                    if(!vis[di][dj]) {
                        /* cout << "Start counting" << endl; */
                        ++res;
                        dfs(a, di, dj, vis);
                        /* cout << "Stop counting" << endl; */
                    }
                }
            }
        }
        else {
            for(int di = 0; di < 3; ++di) {
                for(int dj = 0; dj < 3; ++dj) {
                    /* cout << a[di][dj].substr(0, 5) << ' ' << toInt(a[di][dj]) << ' '; */
                    res += toInt(a[di][dj]);
                }
                /* cout << endl; */
            }
        }
        /* cout << endl; */
        /* cout << res << endl << endl; */
        return toStr(res);
    }
    else {
        vector<vector<bool>> vis(3, vector<bool>(3, 0));
        for(int di = 0; di < 3; ++di) for(int dj = 0; dj < 3; ++dj) if(a[di][dj][0] == '0') vis[di][dj] = 1;

        for(int di = 0; di < 3; ++di) {
            for(int dj = 0; dj < 3; ++dj) {
                if(!vis[di][dj]) {
                    ++res;
                    dfs(a, di, dj, vis);
                }
            }
        }
        return toStr(res);
    }
    /* cout << "what the fuck" << endl; */
    return "";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 2276 KB Output is correct
2 Correct 8 ms 1936 KB Output is correct
3 Incorrect 1 ms 344 KB Incorrect
4 Halted 0 ms 0 KB -