This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "mars.h"
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
int pos(int i, int j, int n) {
int x = 2*n+1;
return i*x+j;
}
std::string process(std::vector <std::vector<std::string>> a, int i, int j, int k, int n)
{
string out;
frange(i, 100) out += '0';
if(k == 0) {
vvi val(3, vi(3));
forr(r, 0, 3) {
forr(c, 0, 3) {
if(int(a[r][c][0] - '0')) {
out[pos(i+r, j+c, n)] = '1';
}
}
}
// return out;
}
else {
frange(r, 3) {
frange(c, 3) {
frange(l, 100) {
if(out[l] == '1' || a[r][c][l] == '1') {
out[l] = '1';
}
}
}
}
}
if(k == n-1) {
int x = 2*n+1;
vvi grid(2*n+1, vi(2*n+1));
frange(l, 100) {
if(out[l] == '1') {
grid[l/x][l%x] = 1;
}
}
// frange(i, x) {
// frange(j, x) {
// printf("%d ", grid[i][j]);
// }
// printf("\n");
// }
vector<vb> vis(x, vb(x));
int c = 0;
frange(i, x) {
frange(j, x) {
if(!vis[i][j] && grid[i][j]) {
c++;
stack<pii> stk;
stk.push(mp(i, j));
while(stk.size()) {
auto p = stk.top();
stk.pop();
if(p.f < 0 || p.f >= x || p.s < 0 || p.s >= x || !grid[p.f][p.s] || vis[p.f][p.s]) continue;
vis[p.f][p.s] = true;
stk.push(mp(p.f+1, p.s));
stk.push(mp(p.f-1, p.s));
stk.push(mp(p.f, p.s+1));
stk.push(mp(p.f, p.s-1));
}
}
}
}
out = "";
frange(i, 100) out += '0';
frange(i, 20) {
if(c&(1<<i)) out[i] = '1';
}
}
return out;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |