import java.io.*; import java.util.*; /** * Read in bitstrings and keep track of only those strings that * increase the rank of the space. This is done by performing * Gaussian Elimination each time a new string is added. * * Get the resulting set of bitstrings in reduced row echelon form * and track the operations used to do this. * Apply those operations to each target bitstring. Iterate over * the resulting bitstring to determine the largest index required * from the initial set of bitstrings. * * @author Finn Lidbetter */ public class basicbasis_finn { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb = new StringBuilder(); String[] s = br.readLine().split(" "); int n = Integer.parseInt(s[0]); int m = Integer.parseInt(s[1]); int k = Integer.parseInt(s[2]); BitSet[] arr = new BitSet[k*4]; for (int i=0; i minIndex = new HashMap<>(); ArrayList ops = new ArrayList<>(); int maxColumn = 0; for (int i=0; i0) { ArrayList newOps = rref(arr, maxColumn+2, true); if (isConsistent(arr, maxColumn+1)) { reverseOps(arr, newOps); if (minSkip==-1) minSkip = i; continue; } for (Operation op: newOps) { ops.add(op); } minIndex.put(maxColumn, i); maxColumn++; } else { minIndex.put(maxColumn, i); maxColumn++; } } //rref(arr, maxColumn+1, false); int[] setColumn = new int[4*k]; Arrays.fill(setColumn, -1); for (int c=0; c=0; j--) { if (binaryArray[j]==1) { int bitStringIndex = setColumn[j]; if (bitStringIndex==-1) { System.out.println(-1); } else { System.out.println(minIndex.get(bitStringIndex) + 1); } break; } } } } static void printBitSetArr(BitSet[] arr, int columns) { StringBuilder sb = new StringBuilder(); for (int i=0; i 0) ? 1 : 0; } } return arr; } static ArrayList rref(BitSet[] arr, int columns, boolean returnOperations) { int n = arr.length; int m = columns; int r = 0; ArrayList ops = new ArrayList<>(); for (int i = 0; i < m-1 && r ops) { for (Operation op: ops) { if (op.isSwap) { int tmp = arr[op.r1]; arr[op.r1] = arr[op.r2]; arr[op.r2] = tmp; } else { arr[op.r1] ^= arr[op.r2]; } } } static void reverseOps(BitSet[] arr, ArrayList ops) { for (int i=0; i