#include <stdio.h> #include <stdlib.h> #include <time.h> //atoms array: //0: # atoms //1:...*atoms: atoms index //0: atomic number (1=H, 6=C, 17=Cl) (0 empty) //1: checked (for marking searched atoms in a search tree) (0 unmarked, 1 marked) //2: index (Starts from 1) //3: //0: bond 1 //1: bond 2 //2: bond 3 //3: bond 4 //4: radical (0 non-radical, 1 radical) //5: molecule //# atoms: *atoms //# elements in array: (*atoms + 1) //# properties per atom: 6 //# bonds per property: 4 //atom a, property p, bond b: *(atoms + a + p * (*atoms + 1) + b * (*atoms + 1) * 6) void PrintAtomsArray ( int * atoms ) { for ( int b = 0 ; b < 4 ; b ++ ) { for ( int p = 0 ; p < 6 ; p ++ ) { for ( int a = 0 ; a < ( * atoms + 1 ) ; a ++ ) printf ( "%2d " , * ( atoms + a + p * ( * atoms + 1 ) + b * ( * atoms + 1 ) * 6 ) ) ; atomsatomsatoms printf ( "

" ) ; } printf ( "

" ) ; } printf ( "

" ) ; } void Bond ( int * atoms , int atom1 , int atom2 ) { int index [ 2 ] ; index [ 0 ] = atom1 ; index [ 1 ] = atom2 ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int k = 0 ; k < 4 ; k ++ ) { if ( * ( atoms + index [ i ] + 3 * ( * atoms + 1 ) + k * ( * atoms + 1 ) * 6 ) == 0 ) { * ( atoms + index [ i ] + 3 * ( * atoms + 1 ) + k * ( * atoms + 1 ) * 6 ) = index [ 1 - i ] ; //set bond * ( atoms + index [ i ] + 4 * ( * atoms + 1 ) ) = 0 ; //set radical to 0 break ; } } } } void BreakBond ( int * atoms , int atom1 , int atom2 ) { int index [ 2 ] ; index [ 0 ] = atom1 ; index [ 1 ] = atom2 ; for ( int i = 0 ; i < 2 ; i ++ ) { for ( int k = 0 ; k < 4 ; k ++ ) { if ( * ( atoms + index [ i ] + 3 * ( * atoms + 1 ) + k * ( * atoms + 1 ) * 6 ) == index [ 1 - i ] ) { * ( atoms + index [ i ] + 3 * ( * atoms + 1 ) + k * ( * atoms + 1 ) * 6 ) = 0 ; //set bond to 0 * ( atoms + index [ i ] + 4 * ( * atoms + 1 ) ) = 1 ; //set radical to 1 break ; } } } } int * InitAtoms ( int numAtoms ) { int * atoms = ( int * ) malloc ( sizeof ( int ) * ( numAtoms + 1 ) * 6 * 4 ) ; atomsnumAtoms * atoms = numAtoms ; for ( int b = 0 ; b < 4 ; b ++ ) //clear for ( int p = 0 ; p < 6 ; p ++ ) for ( int a = 0 ; a < * atoms + 1 ; a ++ ) { if ( b == 0 && p == 0 && a == 0 ) //except for # atoms continue ; * ( atoms + a + p * ( * atoms + 1 ) + b * ( * atoms + 1 ) * 6 ) = 0 ; } for ( int a = 1 ; a <= * atoms ; a ++ ) //mark indices * ( atoms + a + 2 * ( * atoms + 1 ) ) = a ; return atoms ; } void MakeMolecule ( int * atoms , int * atomIndex , int molecule ) { int atomsInMolecule ; if ( molecule == 0 ) //CH4 atomsInMolecule = 5 ; else if ( molecule == 1 ) //Cl2 atomsInMolecule = 2 ; for ( int i = 0 ; i < * atoms ; i ++ ) atomIndex [ i ] = 0 ; int i = 0 ; for ( int a = 1 ; a <= * atoms ; a ++ ) if ( * ( atoms + a ) == 0 ) atomIndex [ i ++ ] = a ; if ( i < atomsInMolecule ) return 1 ; if ( molecule == 0 ) //CH4 { * ( atoms + atomIndex [ 0 ] ) = 6 ; //C for ( int i = 1 ; i < 5 ; i ++ ) { * ( atoms + atomIndex [ i ] ) = 1 ; //H Bond ( atoms , atomIndex [ 0 ] , atomIndex [ i ] ) ; } } else if ( molecule == 1 ) //Cl2 { for ( int i = 0 ; i < 2 ; i ++ ) * ( atoms + atomIndex [ i ] ) = 17 ; //Cl Bond ( atoms , atomIndex [ 0 ] , atomIndex [ 1 ] ) ; } } void MakeMolecules ( int * atoms , int * atomIndex , int CH4 , int Cl2 ) { for ( int i = 0 ; i < CH4 ; i ++ ) MakeMolecule ( atoms , atomIndex , 0 ) ; for ( int i = 0 ; i < Cl2 ; i ++ ) MakeMolecule ( atoms , atomIndex , 1 ) ; } void PrintMoleculesArray ( int * molecules ) { for ( int l = 0 ; l < 1 /*2*/ ; l ++ ) { for ( int k = 0 ; k < 1 /* *molecules*/ ; k ++ ) { for ( int j = 0 ; j < 1 /* *molecules + 9*/ ; j ++ ) { for ( int i = 0 ; i < * molecules + 1 ; i ++ ) printf ( "%2d " , * ( molecules + i + j * ( * molecules + 1 ) + k * ( * molecules + 1 ) * ( * molecules + 9 ) + l * ( * molecules + 1 ) * ( * molecules + 9 ) * * molecules ) ) ; moleculesmoleculesmoleculesmoleculesmoleculesmoleculesmolecules printf ( "

" ) ; } printf ( "

" ) ; } printf ( "

" ) ; } printf ( "

" ) ; } int * IndexMolecules ( int * atoms ) { //molecules array: //0: # atoms in atoms array //0: # radicals //1: # molecules //1...(*atoms): molecules list //0: index (Starts from 1) //1: contains radical (0 or index of radical atom) //2: # C-C bonds //0: bond 1 //0: atom 1 //1: atom 2 //1: bond 2 //0: atom 1 //1: atom 2 //...(*atoms - 1) //3: # C-H bonds //... //4: # C-Cl bonds //... //5: # H-Cl bonds //... //6: # Cl-Cl bonds //... //7: # Cl radical atom //8: # H radical atom //9...(*atoms + 8): list of atoms //0: atomic number int * molecules = ( int * ) malloc ( sizeof ( int ) * ( * atoms + 1 ) * ( * atoms + 9 ) * * atoms * 2 ) ; moleculesatomsatomsatoms * molecules = * atoms ; for ( int i = 0 ; i < * molecules + 1 ; i ++ ) for ( int j = 0 ; j < * molecules + 9 ; j ++ ) for ( int k = 0 ; k < * molecules ; k ++ ) for ( int l = 0 ; l < 2 ; l ++ ) { if ( i == 0 && j == 0 && k == 0 && l == 0 ) continue ; * ( molecules + i + j * ( * molecules + 1 ) + k * ( * molecules + 1 ) * ( * molecules + 9 ) + l * ( * molecules + 1 ) * ( * molecules + 9 ) * * molecules ) = 0 ; } return molecules ; } int main ( ) { int CH4 = 5 ; int Cl2 = 5 ; int * atoms = InitAtoms ( CH4 * 5 + Cl2 * 2 ) ; //blank array int * atomIndex = ( int * ) malloc ( sizeof ( int ) * ( * atoms + 1 ) ) ; //for temporarily storing lists of atoms atomIndexatoms MakeMolecules ( atoms , atomIndex , CH4 , Cl2 ) ; PrintAtomsArray ( atoms ) ; int * molecules = IndexMolecules ( atoms ) ; PrintMoleculesArray ( molecules ) ; free ( atoms ) ; atoms free ( atomIndex ) ; atomIndex free ( molecules ) ; molecules return 0 ; }

I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCi8vYXRvbXMgYXJyYXk6CiAgICAvLzA6ICMgYXRvbXMKICAgIC8vMTouLi4qYXRvbXM6IGF0b21zIGluZGV4CiAgICAgICAgLy8wOiBhdG9taWMgbnVtYmVyICgxPUgsIDY9QywgMTc9Q2wpICgwIGVtcHR5KQogICAgICAgIC8vMTogY2hlY2tlZCAoZm9yIG1hcmtpbmcgc2VhcmNoZWQgYXRvbXMgaW4gYSBzZWFyY2ggdHJlZSkgKDAgdW5tYXJrZWQsIDEgbWFya2VkKQogICAgICAgIC8vMjogaW5kZXggKFN0YXJ0cyBmcm9tIDEpCiAgICAgICAgLy8zOgogICAgICAgICAgICAvLzA6IGJvbmQgMQogICAgICAgICAgICAvLzE6IGJvbmQgMgogICAgICAgICAgICAvLzI6IGJvbmQgMwogICAgICAgICAgICAvLzM6IGJvbmQgNAogICAgICAgIC8vNDogcmFkaWNhbCAoMCBub24tcmFkaWNhbCwgMSByYWRpY2FsKQogICAgICAgIC8vNTogbW9sZWN1bGUKCi8vIyBhdG9tczogKmF0b21zCi8vIyBlbGVtZW50cyBpbiBhcnJheTogKCphdG9tcyArIDEpCi8vIyBwcm9wZXJ0aWVzIHBlciBhdG9tOiA2Ci8vIyBib25kcyBwZXIgcHJvcGVydHk6IDQKLy9hdG9tIGEsIHByb3BlcnR5IHAsIGJvbmQgYjogKihhdG9tcyArIGEgKyBwICogKCphdG9tcyArIDEpICsgYiAqICgqYXRvbXMgKyAxKSAqIDYpCgp2b2lkIFByaW50QXRvbXNBcnJheShpbnQgKmF0b21zKQp7CiAgICBmb3IoaW50IGIgPSAwOyBiIDwgNDsgYisrKQogICAgewogICAgICAgIGZvcihpbnQgcCA9IDA7IHAgPCA2OyBwKyspCiAgICAgICAgewogICAgICAgICAgICBmb3IoaW50IGEgPSAwOyBhIDwgKCphdG9tcyArIDEpOyBhKyspCiAgICAgICAgICAgICAgICBwcmludGYoIiUyZCAiLCAqKGF0b21zICsgYSArIHAgKiAoKmF0b21zICsgMSkgKyBiICogKCphdG9tcyArIDEpICogNikpOwogICAgICAgICAgICBwcmludGYoIlxuIik7CiAgICAgICAgfQogICAgICAgIHByaW50ZigiXG4iKTsKICAgIH0KICAgIHByaW50ZigiXG4iKTsKfQoKdm9pZCBCb25kKGludCAqYXRvbXMsIGludCBhdG9tMSwgaW50IGF0b20yKQp7CiAgICBpbnQgaW5kZXhbMl07CiAgICBpbmRleFswXSA9IGF0b20xOwogICAgaW5kZXhbMV0gPSBhdG9tMjsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCAyOyBpKyspCiAgICB7CiAgICAgICAgZm9yKGludCBrID0gMDsgayA8IDQ7IGsrKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKCooYXRvbXMgKyBpbmRleFtpXSArIDMgKiAoKmF0b21zICsgMSkgKyBrICogKCphdG9tcyArIDEpICogNikgPT0gMCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgKihhdG9tcyArIGluZGV4W2ldICsgMyAqICgqYXRvbXMgKyAxKSArIGsgKiAoKmF0b21zICsgMSkgKiA2KSA9IGluZGV4WzEgLSBpXTsgLy9zZXQgYm9uZAogICAgICAgICAgICAgICAgKihhdG9tcyArIGluZGV4W2ldICsgNCAqICgqYXRvbXMgKyAxKSkgPSAwOyAvL3NldCByYWRpY2FsIHRvIDAKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9Cgp2b2lkIEJyZWFrQm9uZChpbnQgKmF0b21zLCBpbnQgYXRvbTEsIGludCBhdG9tMikKewogICAgaW50IGluZGV4WzJdOwogICAgaW5kZXhbMF0gPSBhdG9tMTsKICAgIGluZGV4WzFdID0gYXRvbTI7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgMjsgaSsrKQogICAgewogICAgICAgIGZvcihpbnQgayA9IDA7IGsgPCA0OyBrKyspCiAgICAgICAgewogICAgICAgICAgICBpZigqKGF0b21zICsgaW5kZXhbaV0gKyAzICogKCphdG9tcyArIDEpICsgayAqICgqYXRvbXMgKyAxKSAqIDYpID09IGluZGV4WzEgLSBpXSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgKihhdG9tcyArIGluZGV4W2ldICsgMyAqICgqYXRvbXMgKyAxKSArIGsgKiAoKmF0b21zICsgMSkgKiA2KSA9IDA7IC8vc2V0IGJvbmQgdG8gMAogICAgICAgICAgICAgICAgKihhdG9tcyArIGluZGV4W2ldICsgNCAqICgqYXRvbXMgKyAxKSkgPSAxOyAvL3NldCByYWRpY2FsIHRvIDEKICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQp9CgppbnQgKiBJbml0QXRvbXMoaW50IG51bUF0b21zKQp7CiAgICBpbnQgKmF0b21zID0gKGludCopbWFsbG9jKHNpemVvZihpbnQpICogKG51bUF0b21zICsgMSkgKiA2ICogNCk7CiAgICAqYXRvbXMgPSBudW1BdG9tczsKCiAgICBmb3IoaW50IGIgPSAwOyBiIDwgNDsgYisrKSAvL2NsZWFyCiAgICAgICAgZm9yKGludCBwID0gMDsgcCA8IDY7IHArKykKICAgICAgICAgICAgZm9yKGludCBhID0gMDsgYSA8ICphdG9tcyArIDE7IGErKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoYiA9PSAwICYmIHAgPT0gMCAmJiBhID09IDApIC8vZXhjZXB0IGZvciAjIGF0b21zCiAgICAgICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgICAgICAqKGF0b21zICsgYSArIHAgKiAoKmF0b21zICsgMSkgKyBiICogKCphdG9tcyArIDEpICogNikgPSAwOwogICAgICAgICAgICB9CgogICAgZm9yKGludCBhID0gMTsgYSA8PSAqYXRvbXM7IGErKykgLy9tYXJrIGluZGljZXMKICAgICAgICAqKGF0b21zICsgYSArIDIgKiAoKmF0b21zICsgMSkpID0gYTsKCiAgICByZXR1cm4gYXRvbXM7Cn0KCnZvaWQgTWFrZU1vbGVjdWxlKGludCAqYXRvbXMsIGludCAqYXRvbUluZGV4LCBpbnQgbW9sZWN1bGUpCnsKICAgIGludCBhdG9tc0luTW9sZWN1bGU7CiAgICBpZihtb2xlY3VsZSA9PSAwKSAvL0NINAogICAgICAgIGF0b21zSW5Nb2xlY3VsZSA9IDU7CiAgICBlbHNlIGlmKG1vbGVjdWxlID09IDEpIC8vQ2wyCiAgICAgICAgYXRvbXNJbk1vbGVjdWxlID0gMjsKCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgKmF0b21zOyBpKyspCiAgICAgICAgYXRvbUluZGV4W2ldID0gMDsKICAgIGludCBpID0gMDsKICAgIGZvcihpbnQgYSA9IDE7IGEgPD0gKmF0b21zOyBhKyspCiAgICAgICAgaWYoKihhdG9tcyArIGEpID09IDApCiAgICAgICAgICAgIGF0b21JbmRleFtpKytdID0gYTsKICAgIGlmKGkgPCBhdG9tc0luTW9sZWN1bGUpCiAgICAgICAgcmV0dXJuIDE7CgogICAgaWYobW9sZWN1bGUgPT0gMCkgLy9DSDQKICAgIHsKICAgICAgICAqKGF0b21zICsgYXRvbUluZGV4WzBdKSA9IDY7IC8vQwogICAgICAgIGZvcihpbnQgaSA9IDE7IGkgPCA1OyBpKyspCiAgICAgICAgewogICAgICAgICAgICAqKGF0b21zICsgYXRvbUluZGV4W2ldKSA9IDE7IC8vSAogICAgICAgICAgICBCb25kKGF0b21zLCBhdG9tSW5kZXhbMF0sIGF0b21JbmRleFtpXSk7CiAgICAgICAgfQogICAgfQogICAgZWxzZSBpZihtb2xlY3VsZSA9PSAxKSAvL0NsMgogICAgewogICAgICAgIGZvcihpbnQgaSA9IDA7IGkgPCAyOyBpKyspCiAgICAgICAgICAgICooYXRvbXMgKyBhdG9tSW5kZXhbaV0pID0gMTc7IC8vQ2wKICAgICAgICBCb25kKGF0b21zLCBhdG9tSW5kZXhbMF0sIGF0b21JbmRleFsxXSk7CiAgICB9Cn0KCnZvaWQgTWFrZU1vbGVjdWxlcyhpbnQgKmF0b21zLCBpbnQgKmF0b21JbmRleCwgaW50IENINCwgaW50IENsMikKewogICAgZm9yKGludCBpID0gMDsgaSA8IENINDsgaSsrKQogICAgICAgIE1ha2VNb2xlY3VsZShhdG9tcywgYXRvbUluZGV4LCAwKTsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBDbDI7IGkrKykKICAgICAgICBNYWtlTW9sZWN1bGUoYXRvbXMsIGF0b21JbmRleCwgMSk7Cn0KCnZvaWQgUHJpbnRNb2xlY3VsZXNBcnJheShpbnQgKm1vbGVjdWxlcykKewogICAgZm9yKGludCBsID0gMDsgbCA8IDEvKjIqLzsgbCsrKQogICAgewogICAgICAgIGZvcihpbnQgayA9IDA7IGsgPCAxLyogKm1vbGVjdWxlcyovOyBrKyspCiAgICAgICAgewogICAgICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgMS8qICptb2xlY3VsZXMgKyA5Ki87IGorKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZm9yKGludCBpID0gMDsgaSA8ICptb2xlY3VsZXMgKyAxOyBpKyspCiAgICAgICAgICAgICAgICAgICAgcHJpbnRmKCIlMmQgIiwgKihtb2xlY3VsZXMgKyBpICsgaiAqICgqbW9sZWN1bGVzICsgMSkgKyBrICogKCptb2xlY3VsZXMgKyAxKSAqICgqbW9sZWN1bGVzICsgOSkgKyBsICogKCptb2xlY3VsZXMgKyAxKSAqICgqbW9sZWN1bGVzICsgOSkgKiAqbW9sZWN1bGVzKSk7CiAgICAgICAgICAgICAgICBwcmludGYoIlxuIik7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcHJpbnRmKCJcbiIpOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CiAgICBwcmludGYoIlxuIik7Cn0KCmludCAqIEluZGV4TW9sZWN1bGVzKGludCAqYXRvbXMpCnsKICAgIC8vbW9sZWN1bGVzIGFycmF5OgogICAgICAgIC8vMDogIyBhdG9tcyBpbiBhdG9tcyBhcnJheQogICAgICAgICAgICAvLzA6ICMgcmFkaWNhbHMKICAgICAgICAgICAgLy8xOiAjIG1vbGVjdWxlcwogICAgICAgIC8vMS4uLigqYXRvbXMpOiBtb2xlY3VsZXMgbGlzdAogICAgICAgICAgICAvLzA6IGluZGV4IChTdGFydHMgZnJvbSAxKQogICAgICAgICAgICAvLzE6IGNvbnRhaW5zIHJhZGljYWwgKDAgb3IgaW5kZXggb2YgcmFkaWNhbCBhdG9tKQogICAgICAgICAgICAvLzI6ICMgQy1DIGJvbmRzCiAgICAgICAgICAgICAgICAvLzA6IGJvbmQgMQogICAgICAgICAgICAgICAgICAgIC8vMDogYXRvbSAxCiAgICAgICAgICAgICAgICAgICAgLy8xOiBhdG9tIDIKICAgICAgICAgICAgICAgIC8vMTogYm9uZCAyCiAgICAgICAgICAgICAgICAgICAgLy8wOiBhdG9tIDEKICAgICAgICAgICAgICAgICAgICAvLzE6IGF0b20gMgogICAgICAgICAgICAgICAgLy8uLi4oKmF0b21zIC0gMSkKICAgICAgICAgICAgLy8zOiAjIEMtSCBib25kcwogICAgICAgICAgICAgICAgLy8uLi4KICAgICAgICAgICAgLy80OiAjIEMtQ2wgYm9uZHMKICAgICAgICAgICAgICAgIC8vLi4uCiAgICAgICAgICAgIC8vNTogIyBILUNsIGJvbmRzCiAgICAgICAgICAgICAgICAvLy4uLgogICAgICAgICAgICAvLzY6ICMgQ2wtQ2wgYm9uZHMKICAgICAgICAgICAgICAgIC8vLi4uCiAgICAgICAgICAgIC8vNzogIyBDbCByYWRpY2FsIGF0b20KICAgICAgICAgICAgLy84OiAjIEggcmFkaWNhbCBhdG9tCiAgICAgICAgICAgIC8vOS4uLigqYXRvbXMgKyA4KTogbGlzdCBvZiBhdG9tcwogICAgICAgICAgICAgICAgLy8wOiBhdG9taWMgbnVtYmVyCiAgICBpbnQgKm1vbGVjdWxlcyA9IChpbnQqKW1hbGxvYyhzaXplb2YoaW50KSAqICgqYXRvbXMgKyAxKSAqICgqYXRvbXMgKyA5KSAqICphdG9tcyAqIDIpOwogICAgKm1vbGVjdWxlcyA9ICphdG9tczsKCiAgICBmb3IoaW50IGkgPSAwOyBpIDwgKm1vbGVjdWxlcyArIDE7IGkrKykKICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgKm1vbGVjdWxlcyArIDk7IGorKykKICAgICAgICAgICAgZm9yKGludCBrID0gMDsgayA8ICptb2xlY3VsZXM7IGsrKykKICAgICAgICAgICAgICAgIGZvcihpbnQgbCA9IDA7IGwgPCAyOyBsKyspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgaWYoaSA9PSAwICYmIGogPT0gMCAmJiBrID09IDAgJiYgbCA9PSAwKQogICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsKICAgICAgICAgICAgICAgICAgICAqKG1vbGVjdWxlcyArIGkgKyBqICogKCptb2xlY3VsZXMgKyAxKSArIGsgKiAoKm1vbGVjdWxlcyArIDEpICogKCptb2xlY3VsZXMgKyA5KSArIGwgKiAoKm1vbGVjdWxlcyArIDEpICogKCptb2xlY3VsZXMgKyA5KSAqICptb2xlY3VsZXMpID0gMDsKICAgICAgICAgICAgICAgIH0KCiAgICByZXR1cm4gbW9sZWN1bGVzOwp9CgppbnQgbWFpbigpCnsKICAgIGludCBDSDQgPSA1OwogICAgaW50IENsMiA9IDU7CiAgICBpbnQgKmF0b21zID0gSW5pdEF0b21zKENINCAqIDUgKyBDbDIgKiAyKTsgLy9ibGFuayBhcnJheQogICAgaW50ICphdG9tSW5kZXggPSAoaW50KiltYWxsb2Moc2l6ZW9mKGludCkgKiAoKmF0b21zICsgMSkpOyAvL2ZvciB0ZW1wb3JhcmlseSBzdG9yaW5nIGxpc3RzIG9mIGF0b21zCiAgICBNYWtlTW9sZWN1bGVzKGF0b21zLCBhdG9tSW5kZXgsIENINCwgQ2wyKTsKICAgIFByaW50QXRvbXNBcnJheShhdG9tcyk7CgogICAgaW50ICptb2xlY3VsZXMgPSBJbmRleE1vbGVjdWxlcyhhdG9tcyk7CiAgICBQcmludE1vbGVjdWxlc0FycmF5KG1vbGVjdWxlcyk7CgogICAgZnJlZShhdG9tcyk7CiAgICBmcmVlKGF0b21JbmRleCk7CiAgICBmcmVlKG1vbGVjdWxlcyk7CiAgICByZXR1cm4gMDsKfQ==