'Algospot'에 해당되는 글 1건

  1. 2015.05.11 Algospot DRAWRECT - Javascript(Node.js)

Algospot DRAWRECT 제출답안

작성 : Javascript (Node.js)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var input = [];
var size = 0;
var x= 0,x1= 0,x1cnt = 0 , y = 0,y1 = 0,y1cnt = 0, xcnt = 0, ycnt = 0;
require('readline')
.createInterface(process.stdin, {})
.on('line'function(line) { 
    if(size == 0)
    {
        size= line.trim();    
    }else
    {
 
        if(x == 0){
            x = line.split(" ")[0];
            xcnt = 1;
            y = line.split(" ")[1];
            ycnt = 1;    
        }else{
            if(x == line.split(" ")[0]){
                xcnt++;
            }else{
                if(x1 == 0){
                    x1 = line.split(" ")[0];
                    x1cnt = 1;    
                }else{
                    x1cnt++;
                }
                
            }
            if(y == line.split(" ")[1]){
                ycnt++;
            }else{
                if(y1 == 0){
                    y1 = line.split(" ")[1];
                    y1cnt = 1;    
                }else{
                    y1cnt++;
                }
                
            }
        }
        if(xcnt+x1cnt == 3){
            var result = xcnt == 1 ? x : x1;
            var result1 = ycnt == 1 ? y : y1; 
            input.push({x :result, y:result1});
 
            x = 0,x1= 0,y= 0,y1= 0,xcnt= 0,x1cnt = 0,ycnt = 0,y1cnt = 0;
        }
    }
}).on('close'function() {
    for (var i = 0;  i < size; i++)
        console.log(input[i].x + " " + input[i].y);
});
cs


'Algospot' 카테고리의 다른 글

Algospot DRAWRECT - Javascript(Node.js)  (0) 2015.05.11
Posted by 사용자 guru_k

댓글을 달아 주세요