Submission #1103590

#TimeUsernameProblemLanguageResultExecution timeMemory
1103590fve5Mars (APIO22_mars)C++17
14 / 100
16 ms3264 KiB
#include <bits/stdc++.h> #include "mars.h" using namespace std; #define SIZE 100 string collect(const vector<vector<string>> &a, int k) { string ans; for (int i = 0; i < 2 * k + 3; i++) { if (i < 2 * k + 1) { ans += a[0][0].substr(i * (2 * k + 1), 2 * k + 1) + a[0][1][i * (2 * k + 1) + 2 * k] + a[0][2][i * (2 * k + 1) + 2 * k]; } else { int j = i - 2 * k; ans += a[j][0].substr((2 * k) * (2 * k + 1), 2 * k + 1) + a[j][1][(2 * k) * (2 * k + 1) + 2 * k] + a[j][2][(2 * k) * (2 * k + 1) + 2 * k]; } } return ans + string(SIZE - ans.size(), '0'); } string cc(const vector<vector<string>> &a, int n) { string grid = collect(a, n - 1); int m = 2 * n + 1; auto get = [&](int i, int j) { return grid[m * i + j] == '1'; }; vector<vector<bool>> vis(m, vector<bool>(m)); int cnt = 0; for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { if (vis[i][j] || !get(i, j)) continue; cnt++; queue<pair<int, int>> q; q.emplace(i, j); while (!q.empty()) { auto [x, y] = q.front(); q.pop(); if (vis[x][y] || !get(x, y)) continue; vis[x][y] = true; if (x > 0) q.emplace(x - 1, y); if (x < m - 1) q.emplace(x + 1, y); if (y > 0) q.emplace(x, y - 1); if (y < m - 1) q.emplace(x, y + 1); } } } string ans(SIZE, '0'); for (int i = 0; i < SIZE; i++) { if (cnt & 1) ans[i] = '1'; cnt >>= 1; } return ans; } string process(vector<vector<string>> a, int i, int j, int k, int n) { if (k == n - 1) return cc(a, n); if (k <= 3) return collect(a, k); assert(false); }
#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...