# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
573255 |
2022-06-06T10:06:34 Z |
sumit_kk10 |
Mars (APIO22_mars) |
C++17 |
|
39 ms |
64684 KB |
#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 |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
64508 KB |
Output is correct |
2 |
Correct |
38 ms |
64648 KB |
Output is correct |
3 |
Correct |
39 ms |
64628 KB |
Output is correct |
4 |
Correct |
39 ms |
64660 KB |
Output is correct |
5 |
Correct |
36 ms |
64648 KB |
Output is correct |
6 |
Correct |
39 ms |
64684 KB |
Output is correct |
7 |
Incorrect |
7 ms |
8008 KB |
Incorrect |
8 |
Halted |
0 ms |
0 KB |
- |