2013 ( 28 ) ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 10 B 1 C 1 D 5 E 5 F 1 G II 5 H 30 1
2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%i64d %I64d", &a, &b); 10 printf("%i64d\n", a + b); 11 } 12 return 0; 13 } C++ 1 #include <iostream> 2 int main() 3 { 4 int cases; 5 std::cin >> cases; 6 for (int i = 0; i < cases; ++i) 7 { 8 long long a, b; 9 std::cin >> a >> b; 10 std::cout << a + b << std::endl; 11 } 12 return 0; 13 } 2
A : 10 P i A i B i C i P i D i C i T (T 20) N (N 100), M (M N(N 1)), S, E (1 S, E N), F (F 10 9 ) N M S, E F M A i, B i (1 A i, B i N), C i, D i (D i 10 9 ), C i (C i C i 50216) 3
2 C T 0perasan 3 4 4 1 4 1 1 2 1 1 1 2 4 5 1 3 1 3 1 1 1 3 4 6 1 1 4 4 1 4 2 1 2 1 1 1 2 4 5 1 3 1 3 1 1 1 3 4 6 1 1 2 1 1 2 999999999 1 2 50216 1000 50216 6 9 50215999949784 4
B : 1 N M D max D min D max D min T (T 40) N, M (1 M N 50000) N M N D i (1 D i 10 9 ) i 1. 2. 5
2 5 2 9 7 6 2 1 5 3 9 7 6 2 1 4 2 6
C : 1 (x, y) (x y, x y ) x y XOR (5, 3) (6, 2) (4, 4) (0, 0) x = y (0, 0) (0, 0) (a, b) 1 a N 1 b M (0, 0) T (T 50) N, M(1 N, M 10000) (0, 0) 7
3 3 4 2 5 514 217 12 10 111538 8
D : 5 / R C (grid). * ( ) * * * 90 180 270 ) 9
T (T 50) ( ) R (1 R 1024) C (1 C 1024) R C. * ( ) Yes ( ) No ( ) 4 7 9.....****.....****.....****............ 5 8 *... *.****.. *.****.. *.****.. *... 10
2 2 ** *. 4 4.*.. *......*..** 7 7.....****...*..*...****...*.....*...... 7 7.....****...*..*...****....*....*.... 5 5 ***** *...* *...* *...* ***** 5 5 ***** *...* *.*.* *...* ***** 11
Yes Yes No Yes 12
E : 5 N i C i T (T 1000) N (N 50000) N C i (C i 50000) 99% N 1000 Yes No ( ) 13
3 3 1 2 3 3 1 2 4 3 1 1 1 Yes No Yes 14
F : 1 N e ( ) 15
T (T 30) N (3 N 400), M (M 500) N M N X i, Y i ( 1000 X i, Y i 1000) M PX i, PY i, DX i, DY i ( 1000 DX i, DY i 1000, DX 2 i + DY 2 i > 0) ( e ) ( ) 10 6 16
3 3 1 0.0 0.0 3.0 0.0 0.0 2.0 1.0 1.0 0.0 1.0 4 2 0.0 0.0 0.0 2.0 2.0 2.0 2.0 0.0 1.0 1.0 1.0 0.0 2.0 0.0 0.0 1.0 4 2 0.0 0.0 2.0 0.0 2.0 2.0 0.0 2.0 0.0 2.0 0.0 1.0 2.0 0.0 1.0 0.0 0.3333 2.0000 0.0000 17
18
G II : 5 X X N M N T (T 1000) N, M (N 100000, M 10 9 ) N C i (C i 10 9 ) i C i 99% N 1000 N 19
1. 2. 4 3 1 1 1 1 3 1 1 2 3 3 1 1 3 2 3 3 5 1 4 3 3 3 2 20
H : 30 (w 1 w 2 w n ) w 1 display 514 (display 514) 0123456789 0 2 30 0 0123456789 ASCII 33 39 42 126 ASCII 40 41 define 1. (display w) w w 0 (display 514) (display (display 514)) 514 514 0 21
2. (begin w 1 w 2 w n ) w 1 w n w n (display (begin (display 1) (display 2) 3)) 1 2 3 3. (if w 1 w 2 w 3 ) w 1 0 w 2 w 3 w 1 0 w 3 w 2 w 1 (if (display 514) (display 514514) (display 514514514)) 514 514514514 22
4. (define w 1 w 2 ) w 2 v 2 w 1 v 2 w 1 display begin define lambda + - < define w 2 (if (display (define x 514)) (display 514514) (display x)) (display x) (define x 50216) (display x) 514 514 514 50216 5. (+ w 1 w 2 ) w 1 w 2 v 1 v 2 v 1 + v 2 v 1 v 2 (- w 1 w 2 ) w 1 w 2 v 1 v 2 v 1 v 2 v 1 v 2 (< w 1 w 2 ) w 1 w 2 v 1 v 2 v 1 < v 2 1 0 v 1 v 2 (if (< 514 50216) (display (+ 514 50216)) (display (- 514 50216))) 50730 23
6. (lambda (w 1 w 2 w n ) b) w 1 w n f (f p 1 p 2 p n ) (a) p 1 p n v 1 v n (b) b E 1 w 1 w n v 1 v n (c) (lambda (w 1 w 2 w n ) b) E 2 (d) (f p 1 p 2 p n ) E 3 (e) b define define E 1 E 1 E 2 E 3 (define add1 (lambda (x) (+ x 1))) (display (add1 2)) 3 (define y 1) (define magic!! (lambda (x) (+ x (+ y z)))) (define x 100) (define y 200) (define z 400) (display (magic!! 2)) 403 ; ( ) 2 30 10 7 24
1 ; 3 2 (display (+ 1 2)) 3 4 (define a 3) 5 ; 7 6 (display (+ a 4)) 7 8 (define add1 (lambda (x) (+ x 1))) 9 ; 6 10 (display (add1 5)) 11 12 (define pair (lambda (x y) (lambda (m) (m x y)))) 13 (define first (lambda (x) (x (lambda (a b) a)))) 14 (define second (lambda (x) (x (lambda (a b) b)))) 15 16 (define a (pair 1 2)) 17 ; 1 18 (display (first a)) 19 ; 2 20 (display (second a)) 21 22 (define [] (pair 1 1)) 23 (define empty? first) 24 (define : (lambda (hd tl) (pair 0 (pair hd tl)))) 25 (define head (lambda (xs) (first (second xs)))) 26 (define tail (lambda (xs) (second (second xs)))) 27 28 (define ++ 29 (lambda (xs ys) 30 (if (empty? xs) 31 ys 32 (: (head xs) (++ (tail xs) ys))))) 25
33 34 (define map 35 (lambda (func xs) 36 (if (empty? xs) 37 [] 38 (: (func (head xs)) (map func (tail xs)))))) 39 40 (define display-list (lambda (xs) (map display xs))) 41 42 (define peter (: 5 (: 0 (: 2 (: 1 (: 6 [])))))) 43 ; 5 0 2 1 6 44 (display-list peter) 45 46 (define filter 47 (lambda (pred xs) 48 (if (empty? xs) 49 [] 50 (begin 51 (define xs' (filter pred (tail xs))) 52 (if (pred (head xs)) 53 (: (head xs) xs') 54 xs'))))) 55 56 (define! (lambda (x) (if x 0 1))) 57 (define <= (lambda (x y) (! (< y x)))) 58 (define > (lambda (x y) (< y x))) 59 (define sort 60 (lambda (xs) 61 (if (empty? xs) 62 [] 63 (begin 64 (define x (head xs)) 65 (define xs' (tail xs)) 66 (define <=x (filter (lambda (y) (<= y x)) xs')) 67 (define >x (filter (lambda (y) ( > y x)) xs')) 68 (++ (sort <=x) (: x (sort >x))))))) 69 70 ; 0 1 2 5 6 71 (display-list (sort peter)) 72 26
73 (define take 74 (lambda (xs) 75 (lambda (n) 76 (if n 77 (: (head xs) ((take (tail xs)) (- n 1))) 78 [])))) 79 80 ; 5 0 2 81 (display-list ((take peter) 3)) 82 (define take-peter (take peter)) 83 ; 5 0 2 84 (display-list (take-peter 3)) 85 86 (define yin-yang 87 (lambda () 88 (lambda (m) 89 (m 0 (pair 0 (lambda (m) 90 (m 0 (pair 1 (yin-yang))))))))) 91 92 ; 0 1 0 1 0 93 (display-list ((take (yin-yang)) 5)) 27
1 ; 3 2 3 3 ; 7 4 7 5 ; 6 6 6 7 ; 1 8 1 9 ; 2 10 2 11 ; 5 0 2 1 6 12 5 13 0 14 2 15 1 16 6 17 ; 0 1 2 5 6 18 0 19 1 20 2 21 5 22 6 23 ; 5 0 2 24 5 25 0 26 2 27 ; 5 0 2 28 5 29 0 30 2 31 ; 0 1 0 1 0 32 0 33 1 34 0 35 1 36 0 28