#include "mars.h"
#include <bits/stdc++.h>
#define X first
#define Y second
using namespace std;
vector<pair<int, int> > adj[20][20];
bool vis[20][20];
int id(int i, int j, int n) {
return i*n+j;
}
bool valid(int i, int j, int n) {
if (i < 0) return false;
if (i >= n) return false;
if (j < 0) return false;
if (j >= n) return false;
return true;
}
void dfs(int x, int y) {
vis[x][y] = true;
for (auto p : adj[x][y]) {
if (!vis[p.X][p.Y]) dfs(p.X, p.Y);
}
}
string process(vector<vector<string> > a, int i, int j, int k, int n) {
string ans(100, '0');
int tn = n;
n = 2*n+1;
if (k == 0) {
for (int dx=0; dx < 3; ++dx) for (int dy=0; dy < 3; ++dy) if (a[dx][dy][0] == '1') ans[id(i+dx, j+dy, n)] = '1';
}
else {
for (int dx=0; dx < 3; ++dx) for (int dy=0; dy < 3; ++dy) for (int jk=0; jk < 100; ++jk) if (a[dx][dy][jk] == '1') ans[jk] = '1';
}
if (k == tn-1) {
char mat[n][n];
for (int dx=0; dx < n; ++dx) for (int dy=0; dy < n; ++dy) vis[dx][dy] = false;
for (int dx=0; dx < n; ++dx) for (int dy=0; dy < n; ++dy) mat[dx][dy] = ans[id(dx, dy, n)];
for (int dx=0; dx < n; ++dx) for (int dy=0; dy < n; ++dy) adj[dx][dy].clear();
int cc = 0;
for (int dx=0; dx < n; ++dx) {
for (int dy=0; dy < n; ++dy) {
if (mat[dx][dy] == '1') {
if (valid(dx-1, dy, n) && mat[dx-1][dy] == '1') {
adj[dx][dy].push_back(make_pair(dx-1, dy));
adj[dx-1][dy].push_back(make_pair(dx, dy));
}
if (valid(dx+1, dy, n) && mat[dx+1][dy] == '1') {
adj[dx][dy].push_back(make_pair(dx+1, dy));
adj[dx+1][dy].push_back(make_pair(dx, dy));
}
if (valid(dx, dy-1, n) && mat[dx][dy-1] == '1') {
adj[dx][dy].push_back(make_pair(dx, dy-1));
adj[dx][dy-1].push_back(make_pair(dx, dy));
}
if (valid(dx, dy+1, n) && mat[dx][dy+1] == '1') {
adj[dx][dy].push_back(make_pair(dx, dy+1));
adj[dx][dy+1].push_back(make_pair(dx, dy));
}
}
}
}
for (int dx=0; dx < n; ++dx) {
for (int dy=0; dy < n; ++dy) {
if (mat[dx][dy] == '1' && !vis[dx][dy]) {
++cc;
dfs(dx, dy);
}
}
}
string conn(100, '0');
for (i=0; i < 9; ++i) if (cc & (1 << i)) conn[i] = '1';
return conn;
}
else return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
14 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
14 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
14 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
14 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
14 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
14 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
14 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2092 KB |
Output is correct |
2 |
Correct |
4 ms |
1996 KB |
Output is correct |
3 |
Correct |
2 ms |
2280 KB |
Output is correct |
4 |
Correct |
4 ms |
2124 KB |
Output is correct |
5 |
Correct |
3 ms |
1972 KB |
Output is correct |
6 |
Correct |
5 ms |
1896 KB |
Output is correct |
7 |
Correct |
8 ms |
2168 KB |
Output is correct |
8 |
Correct |
9 ms |
2352 KB |
Output is correct |
9 |
Correct |
10 ms |
2340 KB |
Output is correct |
10 |
Correct |
10 ms |
2468 KB |
Output is correct |
11 |
Correct |
9 ms |
2124 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
8 ms |
2228 KB |
Output is correct |
14 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |