language: Java (sun-jdk-1.7.0_10)
date: 873 days 23 hours ago
link:
visibility: public
1
import java.util.*;public class Main{public static void main(String[]r){Scanner s=new Scanner(System.in);final Map g=new HashMap();while(s.hasNext()){g.put(s.nextInt(),s.nextInt());}for(int a:new HashSet<Integer>(g.keySet()){{removeAll(g.values());}}){while(g.containsKey(a)){System.out.print(a+"->");a=(Integer)g.get(a);}System.out.println(a);}}}
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
  • upload with new input
  • result: Success     time: 0.09s    memory: 213440 kB     returned value: 0

    784 955
    405 185
    723 726
    188 531
    522 775
    716 514
    731 489
    380 861
    514 110
    921 468
    674 793
    489 364
    755 247
    90 716
    4 470
    315 193
    257 21
    793 673
    783 481
    468 315
    745 504
    726 606
    592 968
    401 195
    99 368
    231 76
    110 859
    412 142
    193 674
    504 99
    219 755
    861 522
    368 412
    773 188
    859 976
    21 212
    185 257
    976 104
    955 381
    775 565
    350 401
    92 723
    212 783
    847 727
    477 4
    142 921
    258 942
    238 745
    470 350
    247 92
    119 592
    968 833
    673 405
    263 90
    481 269
    381 231
    195 258
    76 644
    942 263
    821 238
    565 773
    364 847
    104 119
    644 380
    833 731
    531 219
    821->238->745->504->99->368->412->142->921->468->315->193->674->793->673->405->185->257->21->212->783->481->269
    784->955->381->231->76->644->380->861->522->775->565->773->188->531->219->755->247->92->723->726->606
    477->4->470->350->401->195->258->942->263->90->716->514->110->859->976->104->119->592->968->833->731->489->364->847->727