@@ -66,23 +66,16 @@ cmd.handler = function(argv) {
6666 if ( result . ok ) {
6767 session . updateStat ( 'ac' , 1 ) ;
6868 session . updateStat ( 'ac.set' , problem . fid ) ;
69- core . getSubmission ( { id : result . id } , function ( e , submission ) {
70- if ( e || ! submission || ! submission . distributionChart )
71- return log . warn ( 'Failed to get submission beat ratio.' ) ;
72-
73- const lang = submission . distributionChart . lang ;
74- const scores = submission . distributionChart . distribution ;
75- const myRuntime = parseFloat ( result . runtime ) ;
76-
77- let ratio = 0.0 ;
78- for ( let score of scores ) {
79- if ( parseFloat ( score [ 0 ] ) >= myRuntime )
80- ratio += parseFloat ( score [ 1 ] ) ;
81- }
82-
69+ if ( result . runtime_percentile )
8370 printLine ( result , 'Your runtime beats %d %% of %s submissions' ,
84- ratio . toFixed ( 2 ) , lang ) ;
85- } ) ;
71+ result . runtime_percentile . toFixed ( 2 ) , result . lang ) ;
72+ else
73+ return log . warn ( 'Failed to get runtime percentile.' ) ;
74+ if ( result . memory && result . memory_percentile )
75+ printLine ( result , 'Your memory usage beats %d %% of %s submissions (%s)' ,
76+ result . memory_percentile . toFixed ( 2 ) , result . lang , result . memory ) ;
77+ else
78+ return log . warn ( 'Failed to get memory percentile.' ) ;
8679 } else {
8780 printResult ( result , 'error' ) ;
8881 printResult ( result , 'testcase' ) ;
0 commit comments