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>
#define pb push_back
#define F first
#define S second
using namespace std;
const int N = 1e3 + 5, MOD = 1e9 + 7, M = 1000;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
void dfs(int i, int j, int mat[M][M], int vis[M][M]){
if(vis[i][j] or !mat[i][j])
return;
vis[i][j] = true;
for(int z = 0; z < 4; ++z){
int x = i + dx[z], y = j + dy[z];
if(x >= 0 and y >= 0 and x < M and y < M)
dfs(x, y, mat, vis);
}
}
string binary(int x){
string res;
while(x > 0){
res.pb((x % 2 ? '1' : '0'));
x /= 2;
}
while(res.size() < 100)
res.pb('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){
int mat[M][M], vis[M][M];
for(int i = 0; i < 2*n + 1; ++i){
for(int j = 0; j < 2*n + 1; ++j){
mat[i][j] = 0;
vis[i][j] = 0;
}
}
if(n == 1){
for(int i = 0; i < 2*n + 1; ++i)
for(int j = 0; j < 2*n + 1; ++j)
mat[i][j] = (a[i][j][0] - '0');
}
else{
int x = 0, y = 0;
for(int i = 0; i < 9; ++i){
mat[x][y] = (a[0][0][i] - '0');
++y;
if(y == 3){
y = 0;
++x;
}
}
for(int i = 1; i < 3; ++i){
mat[0][i + 2] = (a[0][i][2] - '0');
mat[1][i + 2] = (a[0][i][5] - '0');
mat[2][i + 2] = (a[0][i][8] - '0');
}
for(int i = 1; i < 3; ++i){
for(int j = 0; j < 3; ++j){
mat[i + 2][j] = (a[i][j][6] - '0');
mat[i + 2][j + 1] = (a[i][j][7] - '0');
mat[i + 2][j + 2] = (a[i][j][8] - '0');
}
}
}
int ans = 0;
for(int i = 0; i < 2*n + 1; ++i){
for(int j = 0; j < 2*n + 1; ++j){
if(!vis[i][j] and mat[i][j]){
dfs(i, j, mat, vis);
++ans;
}
}
}
return binary(ans);
}
string res;
for(int i = 0; i < 3; ++i){
for(int j = 0; j < 3; ++j){
res.pb(a[i][j][0]);
}
}
while(res.size() < 100)
res.pb('0');
return res;
}
# | 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... |