Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define("NL", "
- ", true);
- $in=file('H:\djks1_108.in', FILE_IGNORE_NEW_LINES);
- $firstLine=explode(' ', $in[0]);
- $n=$firstLine[0];
- $m=$firstLine[1];
- $secondLine=explode(' ', $in[1]);
- $from=$secondLine[0];
- $to=$secondLine[1];
- unset($in[0]);
- unset($in[1]);
- $kaidud=array();
- $kaugus=array();
- $kaugused=array();
- foreach($in as $x) {
- $x=explode(' ', $x);
- $a=$x[0];
- $b=$x[1];
- $c=$x[2];
- if(!isset($kaugused[$a])) {
- $kaugused[$a]=array();
- }
- if(!isset($kaugused[$b])) {
- $kaugused[$b]=array();
- }
- $kaugused[$a][$b]=$c;
- $kaugused[$b][$a]=$c;
- $kaugused[$a][$a]=0;
- $kaugused[$b][$b]=0;
- }
- foreach($kaugused as $k=>$ka) {
- print $k.NL;
- foreach($ka as $key=>$value) {
- print ' '.$key.': '.$value.NL;
- }
- }
- print $from.NL;
- print $to.NL;
- kaugused($from);
- function kaugused($from) {
- global $kaugus;
- global $kaugused;
- global $kaidud;
- $kaidud[$from]=true;
- $jarjekord=array();
- foreach($kaugused[$from] as $key=>$value) {
- if(!isset($kaidud[$key])) {
- array_push($jarjekord, $key);
- }
- }
- sort($jarjekord);
- var_dump($jarjekord);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement