File tree Expand file tree Collapse file tree 5 files changed +145
-1
lines changed 
Codeforces Round #618 (Div. 2) 
Codeforces Round #624 (Div. 3) Expand file tree Collapse file tree 5 files changed +145
-1
lines changed Original file line number Diff line number Diff line change 1+ // http://codeforces.com/contest/1300/problem/A 
2+ 
3+ 'use strict' 
4+ 
5+ const  readInts  =  ( )  =>  { 
6+   return  readline ( ) . split ( ' ' ) . map ( num  =>  parseInt ( num ) ) 
7+ } 
8+ 
9+ const  readInt  =  ( )  =>  readInts ( ) [ 0 ] 
10+ 
11+ let  t  =  readInt ( ) 
12+ 
13+ while  ( t  -- >  0 )  { 
14+   const  n  =  readInt ( ) 
15+   const  arr  =  readInts ( ) 
16+ 
17+   let  ans  =  0 
18+   let  sum  =  0 
19+   for  ( let  i  in  arr )  sum  +=  arr [ i ] 
20+ 
21+   for  ( let  i  in  arr )  { 
22+     if  ( ! arr [ i ] )  { 
23+       arr [ i ]  ++ 
24+       ans  ++ 
25+       sum  ++ 
26+     } 
27+   } 
28+ 
29+   if  ( ! sum )  { 
30+     for  ( let  i  in  arr )  { 
31+         if  ( arr [ i ]  +  1  !==  0 )  { 
32+             arr [ i ]  ++ 
33+             ans  ++ 
34+             break 
35+         } 
36+     } 
37+   } 
38+ 
39+   print ( ans ) 
40+ } 
Original file line number Diff line number Diff line change 1+ // http://codeforces.com/contest/1311/problem/A 
2+ 
3+ 'use strict' 
4+ 
5+ let  t  =  parseInt ( readline ( ) ) 
6+ 
7+ while  ( t  -- >  0 )  { 
8+   const  arr  =  readline ( ) . split ( ' ' ) . map ( n  =>  parseInt ( n ) ) 
9+   const  a  =  arr [ 0 ] 
10+   const  b  =  arr [ 1 ] 
11+   
12+   let  ans  =  0 
13+   const  diff  =  Math . abs ( a  -  b ) 
14+   if  ( a  <  b )  { 
15+     if  ( diff  %  2 )  ans  =  1 
16+     else  ans  =  2 
17+   }  else  if  ( a  >  b )  { 
18+     if  ( diff  %  2 )  ans  =  2 
19+     else  ans  =  1 
20+   } 
21+   print ( ans ) 
22+ } 
Original file line number Diff line number Diff line change 1+ // http://codeforces.com/contest/1311/problem/B 
2+ 
3+ 'use strict' 
4+ 
5+ let  t  =  parseInt ( readline ( ) ) 
6+ const  readInts  =  ( )  =>  readline ( ) . split ( ' ' ) . map ( n  =>  parseInt ( n ) ) 
7+ const  readInt  =  ( )  =>  readInts [ 0 ] 
8+ 
9+ while  ( t  -- >  0 )  { 
10+   const  nm  =  readInts ( ) 
11+   const  arr  =  readInts ( ) 
12+   const  p  =  readInts ( ) 
13+ 
14+   let  found  =  true 
15+   while  ( found )  { 
16+     found  =  false 
17+     for  ( let  i  in  p )  { 
18+       const  pos  =  p [ i ] 
19+       if  ( arr [ pos  -  1 ]  >  arr [ pos ] )  { 
20+         const  tmp  =  arr [ pos  -  1 ] 
21+         arr [ pos  -  1 ]  =  arr [ pos ] 
22+         arr [ pos ]  =  tmp 
23+         found  =  true 
24+       } 
25+     } 
26+   } 
27+ 
28+   let  ok  =  true 
29+   for  ( let  i  =  1 ;  i  <  arr . length ;  ++ i )  { 
30+     if  ( arr [ i  -  1 ]  >  arr [ i ] )  { 
31+       ok  =  false 
32+       break 
33+     } 
34+   } 
35+   print ( ok  ? 'YES'  : 'NO' ) 
36+ } 
Original file line number Diff line number Diff line change 1+ // http://codeforces.com/contest/1311/problem/C 
2+ 
3+ 'use strict' 
4+ 
5+ const  getLine  =  ( )  =>  readline ( ) . split ( ' ' ) 
6+ const  getInts  =  ( )  =>  getLine ( ) . map ( n  =>  parseInt ( n ) ) 
7+ const  getInt  =  ( )  =>  getInts ( ) [ 0 ] 
8+ 
9+ main ( ) 
10+ 
11+ function  main  ( )  { 
12+   let  t  =  getInt ( ) 
13+   while  ( t  -- >  0 )  { 
14+     const  params  =  getInts ( ) 
15+     const  s  =  getLine ( ) [ 0 ] 
16+     const  mistakes  =  getInts ( ) 
17+     solve ( ...params ,  s ,  mistakes ) 
18+   } 
19+ } 
20+ 
21+ function  solve  ( n ,  m ,  s ,  mistakes )  { 
22+   const  freq  =  Array ( n  +  1 ) . fill ( 0 ) 
23+   const  ans  =  Array ( 26 ) . fill ( 0 ) 
24+   let  accumulate  =  0 
25+ 
26+   mistakes . push ( n ) 
27+ 
28+   for  ( const  i  of  mistakes )  { 
29+     freq [ 0 ]  ++ 
30+     freq [ i ]  -- 
31+   } 
32+ 
33+   for  ( let  i  =  0 ;  i  <  n ;  ++ i )  { 
34+     const  ind  =  s [ i ] . charCodeAt ( )  -  'a' . charCodeAt ( ) 
35+     accumulate  +=  freq [ i ] 
36+     ans [ ind ]  +=  accumulate 
37+   } 
38+ 
39+   print ( ans . join ( ' ' ) ) 
40+ } 
Original file line number Diff line number Diff line change 1067106732161457
1068106831878123
1069106931910741
1070- 32605600
1070+ 32605600
1071+ 71946383
1072+ 71824279
1073+ 71185827
1074+ 71822449
1075+ 71822118
1076+ 71946544
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments