Submission #1166832

#TimeUsernameProblemLanguageResultExecution timeMemory
1166832SmuggingSpunMars (APIO22_mars)C++20
0 / 100
0 ms3264 KiB
#include "mars.h"
#include<bits/stdc++.h>
using namespace std;
string to_binary(int number){
    string ret = "";
    for(int i = 0; i < 30; i++){
        ret += char((number >> i & 1) + 48);
    }
    return ret + string(70, '0');
}
string process(vector<vector<string>>a, int i, int j, int k, int n){
    if(n == 1){
        int ans = 0;
        vector<vector<bool>>vis(4, vector<bool>(4, false));
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(a[i][j][0] == '1'){
                    vis[i + 1][j + 1] = true;
                }
            }
        }
        for(int i = 1; i < 4; i++){
            for(int j = 1; j < 4; j++){
                if(vis[i][j] && !vis[i][j - 1] && !vis[i - 1][j]){
                    ans++;
                }
            }
        }
        return to_binary(ans);
    }
    if(n == 2){
        if(k == 0){
            string ret = to_binary(((a[i + 2][j + 2][0] - 48) << 2) + ((a[i + 2][j + 1][0] - 48) << 1) + a[i + 2][j][0] - 48);
            if(a[i][j][0] == '1'){
                ret.back() = '1';
            }
            return ret;
        }
        vector<vector<bool>>board(6, vector<bool>(6, false));
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(a[i][j].back() == '1'){
                    board[i + 1][j + 1] = true;
                }
                int mask = a[i][j][0] - 48 + ((a[i][j][1] - 48) << 1) + ((a[i][j][2] - 48) << 2);
                for(int k = 0; k < 3; k++){
                    if(1 << k & mask){
                        board[i + 3][j + k + 1] = true;
                    }
                }
            }
        }
        int ans = 0;
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= n; j++){
                if(board[i][j] && !board[i][j - 1] && !board[i - 1][j]){
                    ans++;
                }
            }
        }
        return to_binary(ans);
    }
}

Compilation message (stderr)

mars.cpp: In function 'std::string process(std::vector<std::vector<std::__cxx11::basic_string<char> > >, int, int, int, int)':
mars.cpp:63:1: warning: control reaches end of non-void function [-Wreturn-type]
   63 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...