High-pressure phase transitions of polar and nonpolar molecular structures of cyanoacetylene (HC 3 N) are studied by using first-principles simulations at constant pressure. In both polar and nonpolar crystals, at pressure ∼20 GPa, the cyanoacetylene molecules are interconnected together and form polyacrylonitrile (PA) polymers. At pressure ∼30 GPa, PA polymers are transformed to polymers with fused pyridine rings (FPR's). The individual geometrical structures of PA and FPR polymers obtained from polar and nonpolar molecular crystals of cyanoacetylene are identical, but their stacking is different. At pressures above 40 GPa, the FPR polymers are interconnected together and new three-dimensional (3D) carbon nitride systems are formed. At ambient pressure, the long-length PA and FPR polymers are metallic, and the created 3D structures are an insulator with energy band gaps around 2.85 eV. The electron transport characteristics of FPR polymers with different lengths are investigated at finite biases by using the nonequilibrium Green's function technique combined with density functional theory (DFT) by connecting the polymers to gold electrodes. The results show that FPR polymers have negative differential resistance behavior. Our time-dependent DFT calculations reveal that FPR polymers can absorb light in the visible region. From our results, it is expected that the FPR polymers will be a good material for optoelectronic applications.