Permutating a vector - c++

I am trying to get every permutation of a vector but also with a divider that indicates sub-permutations. It seems there is a mistake in my code as you can see from my results the ending permutation.
0 1 3 2 | and 0 2 3 1 | and 0 3 2 1 | are all duplicated.
I am also curious if there is a way to do what I am trying to do that can accept a reference to the vector rather than making a copy.
IDEONE: http://ideone.com/fork/2v0wk3
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void permute(vector<int> v, int path_length) {
do {
for(int i=0; i<=3; ++i) {
cout << v[i] << " ";
if(i == path_length-1)
cout << "| ";
}
cout << endl;
if(path_length == v.size()) {
cout << "====="<< endl;
return;
}
permute(v, path_length+1);
} while(next_permutation(v.begin()+path_length-1,v.end()));
}
int main() {
vector<int> v;
for(int i=0;i<=3;++i)
v.push_back(i);
int path_length = 2;
permute(v, path_length);
return 0;
}
Results:
0 1 | 2 3
0 1 2 | 3
0 1 2 3 |
=====
0 1 3 | 2
0 1 3 2 |
=====
0 1 | 3 2
0 1 3 | 2
0 1 3 2 |
=====
0 2 | 1 3
0 2 1 | 3
0 2 1 3 |
=====
0 2 3 | 1
0 2 3 1 |
=====
0 2 | 3 1
0 2 3 | 1
0 2 3 1 |
=====
0 3 | 1 2
0 3 1 | 2
0 3 1 2 |
=====
0 3 2 | 1
0 3 2 1 |
=====
0 3 | 2 1
0 3 2 | 1
0 3 2 1 |
=====
Expected Results:
0 1 | 2 3
0 1 2 | 3
0 1 2 3 |
=====
0 1 3 | 2
0 1 3 2 |
=====
0 2 | 1 3
0 2 1 | 3
0 2 1 3 |
=====
0 2 3 | 1
0 2 3 1 |
=====
0 3 | 1 2
0 3 1 | 2
0 3 1 2 |
=====
0 3 2 | 1
0 3 2 1 |
=====

Consider another way to generate every sequence you need.
We will have a vector <int> cur to store the current sequence, and a vector <bool> used to track which integers are used and which are not.
In a recursive function with a depth argument, find another unused integer, put it as cur[depth] and proceed considering the next position, which is depth + 1.
Print the result anytime the depth is in the required bounds.
#include <iostream>
#include <vector>
using namespace std;
int const n = 3;
void generate (vector <int> & cur, vector <bool> & used, int depth) {
if (depth >= 2) {
for (int i = 0; i < depth; i++) {
cout << cur[i] << ' ';
}
cout << endl;
}
for (int i = 0; i <= n; i++) {
if (!used[i]) {
used[i] = true;
cur[depth] = i;
generate (cur, used, depth + 1);
used[i] = false;
}
}
}
int main () {
vector <int> cur (n);
vector <bool> used (n, false);
cur[0] = 0;
used[0] = true;
generate (cur, used, 1);
return 0;
}
And the output is:
0 1
0 1 2
0 1 2 3
0 1 3
0 1 3 2
0 2
0 2 1
0 2 1 3
0 2 3
0 2 3 1
0 3
0 3 1
0 3 1 2
0 3 2
0 3 2 1
You can add the ===== part, too, if you print it when depth > n.

Your question is not very clear to me. You can use the not so well known next permutation from the STL :
std::vector<int> my_vector = { 1 , 5 , 7 , 2 , 3 , 10};
std::sort(my_vector.begin(), my_vector.end());
do {
std::copy(my_vector.begin(), my_vector.end(), ostream_iterator<int>(std::cout, " "));
std::cout << std::endl;
} while(std::next_permutation(my_vector.begin(), my_vector.end()));
1 - Sort the vector
2 - Iterate over the permutations
(the do while just print it with a copy to the cout)
I'm not wure of what you call "sub" permutations, are you just moving the "|" inside each permutation ?

Related

Generate graph with vertices equal to elements of std::next_permutation, with edges between pairwise adjacent permutations

Consider the code snippet:
#include <vector>
#include <algorithm>
#include <stdio.h>
int main(){
int szvec = 4;
std::vector<int> vecint(szvec);
for (size_t i = 0, szi = szvec; i < szi; i++){
vecint[i] = i;
}
do{
for (size_t i = 0, szi = vecint.size(); i < szi; i++){
printf("%d\t", vecint[i]);
}
printf("\n");
} while (std::next_permutation(vecint.begin(), vecint.end()));
}
The output of this is the set of 4! different permutations.:
0 1 2 3 (Permutation 1)
0 1 3 2 (Permutation 2)
0 2 1 3
0 2 3 1
0 3 1 2
0 3 2 1
1 0 2 3
1 0 3 2
1 2 0 3
1 2 3 0
1 3 0 2
1 3 2 0
2 0 1 3
2 0 3 1
2 1 0 3 (Permutation 15)
2 1 3 0
2 3 0 1
2 3 1 0
3 0 1 2
3 0 2 1
3 1 0 2
3 1 2 0
3 2 0 1 (Permutation 23)
3 2 1 0 (Permutation 24)
I am interested in constructing an undirected graph with 24 nodes, (each node represents one permutation), with an edge connecting i and j if these permutations differ from each other in exactly one contiguous pair of elements. For instance, Permutation 1 and Permutation 2 will be connected since they differ in the pairwise exchange over contiguous indices. Permutation 1 and Permutation 15 will NOT be connected since even though they differ in pairwise exchange of elements, this exchange is not over contiguous indices. Permutation 23 and Permutation 24 will be connected.
The only way I can think of now of how to do this is to select each pair of permutations and evaluate explicitly whether they should be connected. Is there a more efficient way of doing this analytically? What I mean by analytical here is that given a particular node i, can we efficiently enumerate all other permutations it will be connected to? Note that szvec can be an arbitrary integer, not only 4.
ETA: With szvec = 3, we have six permutations:
0 1 2 (Permutation 1)
0 2 1 (Permutation 2)
1 0 2 (Permutation 3)
1 2 0 (Permutation 4)
2 0 1 (Permutation 5)
2 1 0 (Permutation 6)
and the graph looks so:
___________________
| |
5 - 6 - 4 - 3 - 1 - 2

Copying a vector into an array using Iterators

I've been attempting to copy a vector into an array with no luck. I'm not that familiar with iterators, which seem to be the best choice, but I've been unable to get the copy to work correctly. Here's the code:
// [[Rcpp::export]]
Rcpp::LogicalMatrix mateFamily(const Rcpp::LogicalVector& parent1,
const Rcpp::LogicalVector& parent2) {
// init
int i, AllCount, crossPt, crossCol;
AllCount = parent1.length();
Rcpp::LogicalVector child1(AllCount), child2(AllCount);
Rcpp::LogicalMatrix matePop(6,AllCount);
// print parents
std::cout << "parent1=" << parent1 << '\n';
std::cout << "parent2=" << parent2 << '\n';
// create 6 children
for (i = 0; i < 3; ++i) {
// determine crossover location
crossPt = i + 1;
crossCol = 3*(crossPt==1) + 6*(crossPt==2) + 9*(crossPt==3);
// swap
// child1 = parent1/parent2
std::copy(parent1.begin(), parent1.end(), child1.begin());
std::copy(parent2.begin()+crossCol, parent2.end(), child1.begin()+crossCol);
// child2 = parent2/parent1
std::copy(parent2.begin(), parent2.end(), child2.begin());
std::copy(parent1.begin()+crossCol, parent1.end(), child2.begin()+crossCol);
// print children
std::cout << "child1= " << child1 << '\n';
std::cout << "child2= " << child2 << '\n';
// copy children into matePop
std::copy(child1.begin(), child1.end(), matePop.begin()+i*AllCount);
std::copy(child2.begin(), child2.end(), matePop.begin()+i*AllCount);
}
std::cout << "matePop=" << '\n' << matePop << '\n';
return matePop;
}
The genetic crossover code works and creates the correct children combinations, but I can't figure out how to copy all 6 children into matePop.
The test parents as defined in R for this simplified example are:
parent1 <- cbind(1,1,1, 1,1,1, 1,1,1, 1,1,1)
parent2 <- cbind(0,0,1, 0,0,1, 0,0,1, 0,0,1)
Any help is greatly appreciated.
The crossover section works. Here's the output:
parent1= 1 1 1 1 1 1 1 1 1 1 1 1
parent2= 0 0 1 0 0 1 0 0 1 0 0 1
child1= 1 1 1 0 0 1 0 0 1 0 0 1
child2= 0 0 1 1 1 1 1 1 1 1 1 1
child1= 1 1 1 1 1 1 0 0 1 0 0 1
child2= 0 0 1 0 0 1 1 1 1 1 1 1
child1= 1 1 1 1 1 1 1 1 1 0 0 1
child2= 0 0 1 0 0 1 0 0 1 1 1 1
Here's the matePop output:
matePop=
100110011100
100110011100
111111111111
001110011001
001110011001
111111111111
So the mystery is when the children get copied into matePop
You should do this instead:
std::copy(child1.begin(), child1.end(), matePop.begin()+2*i*AllCount);
std::copy(child2.begin(), child2.end(), matePop.begin()+(2*i+1)*AllCount);
matePop is a 2d matrix with 6 rows and AllCount columns. So for the first time you'll be copying into rows 0 and 1. Second time into 2 & 3 and so on.

DFS on undirected graph

I have an exercise for university where I have to write a DFS algorithm to run on an undirected graph. I also have to make the program sum the values of all nodes show the order in which the nodes were visited.
Here is the given structure:
#include <iostream>
#include <cassert>
using namespace std;
struct node {
// DATA STRUCTURE NODES
};
int dfs_sum(/* FUNCTION ARGUMENTS */) {
// DEPTH FIRST SEARCH ALGORITHM
}
void node_init(/* FUNCTION ARGUMENTS */) {
// INITIALIZATION OF NODE WITH LABEL "value" AND NEIGHBOR "num_adjacent"
}
void edge_init(/* FUNCTION ARGUMENTS */) {
// INITIALIZATION OF EDGE BETWEEN TWO NODES
}
void node_delete(/* FUNCTION ARGUMENTS */) {
// DE-ALLOCATE MEMORY THAT WAS ALLOCATED IN "node_init"
}
void init_nodes(node *nodes) {
node_init(&nodes[0], 1, 1);
node_init(&nodes[1], 2, 4);
node_init(&nodes[2], 3, 1);
node_init(&nodes[3], 4, 4);
node_init(&nodes[4], 5, 4);
node_init(&nodes[5], 6, 2);
node_init(&nodes[6], 7, 5);
node_init(&nodes[7], 8, 3);
node_init(&nodes[8], 9, 2);
node_init(&nodes[9], 10, 2);
node_init(&nodes[10], 11, 4);
node_init(&nodes[11], 12, 2);
edge_init(&nodes[0], &nodes[1]);
edge_init(&nodes[1], &nodes[4]);
edge_init(&nodes[1], &nodes[6]);
edge_init(&nodes[1], &nodes[7]);
edge_init(&nodes[2], &nodes[3]);
edge_init(&nodes[3], &nodes[6]);
edge_init(&nodes[3], &nodes[7]);
edge_init(&nodes[3], &nodes[11]);
edge_init(&nodes[4], &nodes[5]);
edge_init(&nodes[4], &nodes[8]);
edge_init(&nodes[4], &nodes[9]);
edge_init(&nodes[5], &nodes[6]);
edge_init(&nodes[6], &nodes[9]);
edge_init(&nodes[6], &nodes[10]);
edge_init(&nodes[7], &nodes[10]);
edge_init(&nodes[8], &nodes[10]);
edge_init(&nodes[10], &nodes[11]);
}
void delete_nodes(node *nodes) {
for (int i = 0; i < 12; ++i) {
node_delete(&nodes[i]);
}
}
int main() {
node *nodes= new node[12];
init_nodes(nodes);
int sum_dfs = dfs_sum(&nodes[0]);
cout << endl;
int sum_loop = 0;
for (int i = 0; i < 12; ++i) {
sum_loop += nodes[i].value;
}
cout << "sum_dfs = " << sum_dfs << " sum_loop = " << sum_loop << endl;
delete_nodes(nodes);
delete [] nodes;
return 0;
}
I do not know how to begin this exercise
I am not familiar with c++ (I think that's what you used) but the implementation is the same anyway so I can give you a pseudo-code of what the algorithm should look like.
create a stack where object will be stored
all nodes are not visited when we begin
push source in the stack and mark it as visited
while the stack is not empty;
go to the first adjacent node to source and if it has not been visited
mark as visited and move to its next unvisited node and so on
if at any point you reach a node that cannot visited any other unvisited node
pop the stack until you can visited an unvisited node.
Do this until the stack is empty
Below is a simple implementation using an adjacency matrix
void dfs(int adjacency_matrix[][], int source){
Stack<Integer> stack = new Stack<>();
int numNodes = adjacency_matrix[source].length -1;
boolean [] visited = new boolean[numNodes +1];
visited[source] = true;
stack.add(source);
while(!stack.isEmpty()){
int current = stack.peek(); // don't remove the element but get it
System.out.println("Current node being visited is "+current);
for(int x = 0; x <= numNodes; x++){
if(adjacency_matrix[current][x] == 1 && visited[x] == false){
visited[x] = true;
stack.push(x);
break;
}else if(x == numNodes){
stack.pop();
}
}
}
}
You can test with a graph like this
0 --- 1-------5----6--8
| \ \ | / /
| \ \ | / /
| \ \ | / /
2 3----4---7---9
0 1 2 3 4 5 6 7 8 9
---------------------
0 | 0 1 1 1 0 0 0 0 0 0
1 | 1 0 0 0 1 1 0 0 0 0
2 | 1 0 0 0 0 0 0 0 0 0
3 | 1 0 0 0 1 0 0 0 0 0
4 | 0 1 0 1 0 0 0 1 0 0
5 | 0 1 0 0 0 0 1 1 0 0
6 | 0 0 0 0 0 1 0 1 1 0
7 | 0 0 0 0 1 1 1 0 0 1
8 | 0 0 0 0 0 0 1 0 0 1
9 | 0 0 0 0 0 0 0 1 1 0
---------------------

bit vector intersect in handling parquet file format

I am handling parquet file format. For example:
a group of data:
1 2 null 3 4 5 6 null 7 8 null null 9 10 11 12 13 14
I got a bit vector to indicate null element:
1 1 0 1 1 1 1 0 1 1 0 0 1 1 1 1 1 1
and only store the non-null element:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
I want to evaluate a predicate: big then 5
I compared non-null element to 5 and got a bit vector:
0 0 0 0 0 1 1 1 1 1 1 1 1 1
I want to got a bit vector for all elements:
0 0 0 0 0 0 1 0 1 1 0 0 1 1 1 1 1 1
the 0 in bold is null elements, should be false.
void IntersectBitVec(vector<int64_t>& bit_vec, vector<int64_t>& sub_bit_vec) {
int data_idx = 0,
int bit_idx = 63;
for (int i = 0; i < bit_vec.size(); ++i) {
for (int j = 63; j >=0; --j) {
if (bit_vec[i] & 0x01 << j) {
if (!(sub_bit_vec[data_idx] & 0x01 << bit_idx)) {
bit_vec[i] &= ~(0x01 << j);
}
if (--bit_idx < 0) {
--data_idx;
bit_idx = 63;
}
}
}
}}
My code is quite ugly, is there anyway to make it fast? Great thanks!

Find all puddles on the square (algorithm)

The problem is defined as follows:
You're given a square. The square is lined with flat flagstones size 1m x 1m. Grass surround the square. Flagstones may be at different height. It starts raining. Determine where puddles will be created and compute how much water will contain. Water doesn't flow through the corners. In any area of ​​grass can soak any volume of water at any time.
Input:
width height
width*height non-negative numbers describing a height of each flagstone over grass level.
Output:
Volume of water from puddles.
width*height signs describing places where puddles will be created and places won't.
. - no puddle
# - puddle
Examples
Input:
8 8
0 0 0 0 0 1 0 0
0 1 1 1 0 1 0 0
0 1 0 2 1 2 4 5
0 1 1 2 0 2 4 5
0 3 3 3 3 3 3 4
0 3 0 1 2 0 3 4
0 3 3 3 3 3 3 0
0 0 0 0 0 0 0 0
Output:
11
........
........
..#.....
....#...
........
..####..
........
........
Input:
16 16
8 0 1 0 0 0 0 2 2 4 3 4 5 0 0 2
6 2 0 5 2 0 0 2 0 1 0 3 1 2 1 2
7 2 5 4 5 2 2 1 3 6 2 0 8 0 3 2
2 5 3 3 0 1 0 3 3 0 2 0 3 0 1 1
1 0 1 4 1 1 2 0 3 1 1 0 1 1 2 0
2 6 2 0 0 3 5 5 4 3 0 4 2 2 2 1
4 2 0 0 0 1 1 2 1 2 1 0 4 0 5 1
2 0 2 0 5 0 1 1 2 0 7 5 1 0 4 3
13 6 6 0 10 8 10 5 17 6 4 0 12 5 7 6
7 3 0 2 5 3 8 0 3 6 1 4 2 3 0 3
8 0 6 1 2 2 6 3 7 6 4 0 1 4 2 1
3 5 3 0 0 4 4 1 4 0 3 2 0 0 1 0
13 3 6 0 7 5 3 2 21 8 13 3 5 0 13 7
3 5 6 2 2 2 0 2 5 0 7 0 1 3 7 5
7 4 5 3 4 5 2 0 23 9 10 5 9 7 9 8
11 5 7 7 9 7 1 0 17 13 7 10 6 5 8 10
Output:
103
................
..#.....###.#...
.......#...#.#..
....###..#.#.#..
.#..##.#...#....
...##.....#.....
..#####.#..#.#..
.#.#.###.#..##..
...#.......#....
..#....#..#...#.
.#.#.......#....
...##..#.#..##..
.#.#.........#..
......#..#.##...
.#..............
................
I tried different ways. Floodfill from max value, then from min value, but it's not working for every input or require code complication. Any ideas?
I'm interesting algorithm with complexity O(n^2) or o(n^3).
Summary
I would be tempted to try and solve this using a disjoint-set data structure.
The algorithm would be to iterate over all heights in the map performing a floodfill operation at each height.
Details
For each height x (starting at 0)
Connect all flagstones of height x to their neighbours if the neighbour height is <= x (storing connected sets of flagstones in the disjoint set data structure)
Remove any sets that connected to the grass
Mark all flagstones of height x in still remaining sets as being puddles
Add the total count of flagstones in remaining sets to a total t
At the end t gives the total volume of water.
Worked Example
0 0 0 0 0 1 0 0
0 1 1 1 0 1 0 0
0 1 0 2 1 2 4 5
0 1 1 2 0 2 4 5
0 3 3 3 3 3 3 4
0 3 0 1 2 0 3 4
0 3 3 3 3 3 3 0
0 0 0 0 0 0 0 0
Connect all flagstones of height 0 into sets A,B,C,D,E,F
A A A A A 1 B B
A 1 1 1 A 1 B B
A 1 C 2 1 2 4 5
A 1 1 2 D 2 4 5
A 3 3 3 3 3 3 4
A 3 E 1 2 F 3 4
A 3 3 3 3 3 3 A
A A A A A A A A
Remove flagstones connecting to the grass, and mark remaining as puddles
1
1 1 1 1
1 C 2 1 2 4 5 #
1 1 2 D 2 4 5 #
3 3 3 3 3 3 4
3 E 1 2 F 3 4 # #
3 3 3 3 3 3
Count remaining set size t=4
Connect all of height 1
G
C C C G
C C 2 D 2 4 5 #
C C 2 D 2 4 5 #
3 3 3 3 3 3 4
3 E E 2 F 3 4 # #
3 3 3 3 3 3
Remove flagstones connecting to the grass, and mark remaining as puddles
2 2 4 5 #
2 2 4 5 #
3 3 3 3 3 3 4
3 E E 2 F 3 4 # # #
3 3 3 3 3 3
t=4+3=7
Connect all of height 2
A B 4 5 #
A B 4 5 #
3 3 3 3 3 3 4
3 E E E E 3 4 # # #
3 3 3 3 3 3
Remove flagstones connecting to the grass, and mark remaining as puddles
4 5 #
4 5 #
3 3 3 3 3 3 4
3 E E E E 3 4 # # # #
3 3 3 3 3 3
t=7+4=11
Connect all of height 3
4 5 #
4 5 #
E E E E E E 4
E E E E E E 4 # # # #
E E E E E E
Remove flagstones connecting to the grass, and mark remaining as puddles
4 5 #
4 5 #
4
4 # # # #
After doing this for heights 4 and 5 nothing will remain.
A preprocessing step to create lists of all locations with each height should mean that the algorithm is close to O(n^2).
This seems to be working nicely. The idea is it is a recursive function, that checks to see if there is an "outward flow" that will allow it to escape to the edge. If the values that do no have such an escape will puddle. I tested it on your two input files and it works quite nicely. I copied the output for these two files for you. Pardon my nasty use of global variables and what not, I figured it was the concept behind the algorithm that mattered, not good style :)
#include <fstream>
#include <iostream>
#include <vector>
using namespace std;
int SIZE_X;
int SIZE_Y;
bool **result;
int **INPUT;
bool flowToEdge(int x, int y, int value, bool* visited) {
if(x < 0 || x == SIZE_X || y < 0 || y == SIZE_Y) return true;
if(visited[(x * SIZE_X) + y]) return false;
if(value < INPUT[x][y]) return false;
visited[(x * SIZE_X) + y] = true;
bool left = false;
bool right = false;
bool up = false;
bool down = false;
left = flowToEdge(x-1, y, value, visited);
right = flowToEdge(x+1, y, value, visited);
up = flowToEdge(x, y+1, value, visited);
down = flowToEdge(x, y-1, value, visited);
return (left || up || down || right);
}
int main() {
ifstream myReadFile;
myReadFile.open("test.txt");
myReadFile >> SIZE_X;
myReadFile >> SIZE_Y;
INPUT = new int*[SIZE_X];
result = new bool*[SIZE_X];
for(int i = 0; i < SIZE_X; i++) {
INPUT[i] = new int[SIZE_Y];
result[i] = new bool[SIZE_Y];
for(int j = 0; j < SIZE_Y; j++) {
int someInt;
myReadFile >> someInt;
INPUT[i][j] = someInt;
result[i][j] = false;
}
}
for(int i = 0; i < SIZE_X; i++) {
for(int j = 0; j < SIZE_Y; j++) {
bool visited[SIZE_X][SIZE_Y];
for(int k = 0; k < SIZE_X; k++)//You can avoid this looping by using maps with pairs of coordinates instead
for(int l = 0; l < SIZE_Y; l++)
visited[k][l] = 0;
result[i][j] = flowToEdge(i,j, INPUT[i][j], &visited[0][0]);
}
}
for(int i = 0; i < SIZE_X; i++) {
cout << endl;
for(int j = 0; j < SIZE_Y; j++)
cout << result[i][j];
}
cout << endl;
}
The 16 by 16 file:
1111111111111111
1101111100010111
1111111011101011
1111000110101011
1011001011101111
1110011111011111
1100000101101011
1010100010110011
1110111111101111
1101101011011101
1010111111101111
1110011010110011
1010111111111011
1111110110100111
1011111111111111
1111111111111111
The 8 by 8 file
11111111
11111111
11011111
11110111
11111111
11000011
11111111
11111111
You could optimize this algorithm easily and considerably by doing several things. A: return true immediately upon finding a route would speed it up considerably. You could also connect it globally to the current set of results so that any given point would only have to find a flow point to an already known flow point, and not all the way to the edge.
The work involved, each n will have to exam each node. However, with optimizations, we should be able to get this much lower than n^2 for most cases, but it still an n^3 algorithm in the worst case... but creating this would be very difficult(with proper optimization logic... dynamic programming for the win!)
EDIT:
The modified code works for the following circumstances:
8 8
1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 1
1 0 1 1 1 1 0 1
1 0 1 0 0 1 0 1
1 0 1 1 0 1 0 1
1 0 1 1 0 1 0 1
1 0 0 0 0 1 0 1
1 1 1 1 1 1 1 1
And these are the results:
11111111
10000001
10111101
10100101
10110101
10110101
10000101
11111111
Now when we remove that 1 at the bottom we want to see no puddling.
8 8
1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 1
1 0 1 1 1 1 0 1
1 0 1 0 0 1 0 1
1 0 1 1 0 1 0 1
1 0 1 1 0 1 0 1
1 0 0 0 0 1 0 1
1 1 1 1 1 1 0 1
And these are the results
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1