Submission #725285

#TimeUsernameProblemLanguageResultExecution timeMemory
725285SanguineChameleonMars (APIO22_mars)C++17
36 / 100
182 ms2920 KiB
#include "mars.h" #include <bits/stdc++.h> using namespace std; string process(vector<vector<string>> a, int i, int j, int k, int n) { int sz = (k + 1) * 2 + 1; vector<vector<int>> grid(sz, vector<int>(sz, -1)); //cout << i << " " << j << " " << k << endl; for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { if (x + i >= y + j) { int pt = 0; for (int i = 0; i < sz - 2; i++) { for (int j = i & 1; j <= i; j += 2) { grid[x + i][y + j] = a[x][y][pt++] - '0'; } } } else { int pt = 0; for (int i = 0; i < sz - 2; i++) { for (int j = i; j < sz - 2; j += 2) { grid[x + i][y + j] = a[x][y][pt++] - '0'; } } } } } string res; if (k == n - 1) { /* cout << '\n'; for (int i = 0; i < sz; i++) { for (int j = 0; j < sz; j++) { if (grid[i][j] == -1) { cout << "?" << " "; } else { cout << grid[i][j] << " "; } } cout << '\n'; } cout << '\n';*/ vector<vector<bool>> flag(sz, vector<bool>(sz, false)); const vector<int> dx = {1, -1, 0, 0}; const vector<int> dy = {0, 0, 1, -1}; int cnt = 0; for (int i = 0; i < sz; i++) { for (int j = 0; j < sz; j++) { if (!flag[i][j] && grid[i][j]) { cnt++; flag[i][j] = true; deque<pair<int, int>> q = {{i, j}}; while (!q.empty()) { int cx = q.front().first; int cy = q.front().second; q.pop_front(); for (int d = 0; d < 4; d++) { int nx = cx + dx[d]; int ny = cy + dy[d]; if (0 <= nx && nx < sz && 0 <= ny && ny < sz && grid[nx][ny] && !flag[nx][ny]) { flag[nx][ny] = true; q.push_back({nx, ny}); } } } } } } while (cnt) { res += (char)('0' + (cnt & 1)); cnt >>= 1; } } else { if (i >= j) { for (int i = 0; i < sz; i++) { for (int j = i & 1; j <= i; j += 2) { res += (char)('0' + grid[i][j]); } } } else { for (int i = 0; i < sz; i++) { for (int j = i; j < sz; j += 2) { res += (char)('0' + grid[i][j]); } } } } res.resize(100, '0'); return res; }
#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...