제출 #1225272

#제출 시각아이디문제언어결과실행 시간메모리
1225272Jer화성 (APIO22_mars)C++20
0 / 100
8 ms3168 KiB
#include "mars.h" #include <bits/stdc++.h> using namespace std; string make(vector<vector<string>> a){ string res; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) res.push_back(a[i][j][0]); for (int i = 0; i < 91; i++) res.push_back('0'); return res; } int get(vector<vector<int>> b, int i, int j, int n){ if (i < 0 or j < 0 or i >= 2 * n + 1 or j >= 2 * n + 1) return -1; return b[i][j]; } #define isn(b, i, j, n) (get(b, i + 1, j, n) == 1 or get(b, i, j + 1, n) == 1 or get(b, i - 1, j, n) == 1 or get(b, i - 1, j - 1, n) == 1) int count(vector<vector<int>> b, int n){ int res = 0; for (int i = 0; i < 2 * n + 1; i++){ for (int j = 0; j < 2 * n + 1; j++){ if (b[i][j] == 1 and !isn(b, i, j, n)) res++; if (b[i][j] == 1) b[i][j] = 0; } } return res; } string to_binary(int x){ string res; while (x > 0) res.push_back(x % 2 + '0'), x /= 2; res.push_back(x % 2 + '0'); while (res.size() < 100) res.push_back('0'); return res; } std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n) { if (k != n - 1) return make(a); vector<vector<int>> b; if (n == 2){ b.resize(6); for (int i = 0; i < 6; i++) b[i].resize(6); for (int i = 0; i < 9; i++) b[i / 3][i % 3] = a[0][0][i] - '0'; for (int i = 0; i < 9; i++) b[i / 3][(i % 3) + 2] = a[0][2][i] - '0'; for (int i = 0; i < 9; i++) b[(i / 3) + 2][i % 3] = a[2][0][i] - '0'; for (int i = 0; i < 9; i++) b[(i / 3) + 2][(i % 3) + 2] = a[2][2][i] - '0';} if (n == 1){ b.resize(3); for (int i = 0; i < 3; i++) b[i].resize(3); for (int i = 0; i < 9; i++) b[i / 3][i % 3] = a[i / 3][i % 3][0] - '0'; } return to_binary(count(b, n)); }
#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...