# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
202309 | 2020-02-15T09:15:20 Z | wjdqhdhfflavldkem12 | 곡선 자르기 (KOI17_cut) | C++14 | 440 ms | 24148 KB |
#include <stdio.h> #include <vector> #include <algorithm> #include <limits.h> using namespace std; #define LEFT 0 #define RIGHT 1 #define node pair<int, bool> int n, ansCount, inPeak, outPeak; vector<int> x, y; vector<node> LIST; bool compare(node a, node b){ return a.first < b.first; } int main(){ int i; /*변수입력*/ //꼭짓점의 개수 입력 scanf("%d", &n); //각 꼭짓점의 x, y좌표 입력 & 왼쪽 아래에 위치한 점으로 기준점으로 지정할 점을 찾는다. int xtemp, ytemp, start, xstart = INT_MAX, ystart = INT_MAX; for (i = 0; i < n; i++){ scanf("%d %d", &xtemp, &ytemp); x.push_back(xtemp); y.push_back(ytemp); if (xtemp <= xstart && ytemp < 0){ start = i; xstart = xtemp; ystart = ytemp; } } // 시작지점 이전의 점들을 시작지점 이후로 옮겨 붙인다. for (i = 0; i < start; i++){ x.push_back(x[i]); y.push_back(y[i]); } /*봉우리의 시작 기둥과 끝기둥을 찾아 입력한다.*/ //두 개의 기둥을 왼쪽 기둥과 오른쪽 기둥으로 구분하여 입력한다. int size = 0; pair<int, int> temp; for (i = start; i < n+start-1; i++){ if (y[i]<0 && y[i + 1]>0){ size++; temp.first = i; } else if (y[i]>0 && y[i + 1] < 0){ size++; temp.second = i; if (x[temp.first] < x[temp.second]){ LIST.push_back(node(x[temp.first], LEFT)); LIST.push_back(node(x[temp.second], RIGHT)); } else{ LIST.push_back(node(x[temp.first], RIGHT)); LIST.push_back(node(x[temp.second], LEFT)); } } } /*입력된 기둥을 x좌표를 기준으로 오름차순 정렬한다.*/ sort(LIST.begin(), LIST.end(), compare); /*기둥의 배치를 이용하여 원하는 봉우리의 개수를 찾는다.*/ for (i = 0; i < size; i++){ if (LIST[i].second == LEFT){ ansCount++; } else{ ansCount--; if (ansCount == 0) outPeak++; if (LIST[i - 1].second == LEFT) inPeak++; } } /*표준출력에 맞추어 출력한다.*/ printf("%d %d\n", outPeak, inPeak); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
3 | Correct | 5 ms | 296 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 4 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
3 | Correct | 5 ms | 296 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 4 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 6 ms | 376 KB | Output is correct |
19 | Correct | 8 ms | 504 KB | Output is correct |
20 | Correct | 8 ms | 632 KB | Output is correct |
21 | Correct | 8 ms | 504 KB | Output is correct |
22 | Correct | 9 ms | 632 KB | Output is correct |
23 | Correct | 9 ms | 632 KB | Output is correct |
24 | Correct | 9 ms | 632 KB | Output is correct |
25 | Correct | 8 ms | 636 KB | Output is correct |
26 | Correct | 8 ms | 504 KB | Output is correct |
27 | Correct | 8 ms | 504 KB | Output is correct |
28 | Correct | 8 ms | 632 KB | Output is correct |
29 | Correct | 9 ms | 632 KB | Output is correct |
30 | Correct | 9 ms | 632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 380 KB | Output is correct |
3 | Correct | 5 ms | 296 KB | Output is correct |
4 | Correct | 5 ms | 256 KB | Output is correct |
5 | Correct | 5 ms | 256 KB | Output is correct |
6 | Correct | 5 ms | 256 KB | Output is correct |
7 | Correct | 5 ms | 256 KB | Output is correct |
8 | Correct | 4 ms | 256 KB | Output is correct |
9 | Correct | 5 ms | 256 KB | Output is correct |
10 | Correct | 5 ms | 256 KB | Output is correct |
11 | Correct | 5 ms | 256 KB | Output is correct |
12 | Correct | 5 ms | 256 KB | Output is correct |
13 | Correct | 5 ms | 376 KB | Output is correct |
14 | Correct | 5 ms | 256 KB | Output is correct |
15 | Correct | 5 ms | 376 KB | Output is correct |
16 | Correct | 5 ms | 256 KB | Output is correct |
17 | Correct | 5 ms | 376 KB | Output is correct |
18 | Correct | 6 ms | 376 KB | Output is correct |
19 | Correct | 8 ms | 504 KB | Output is correct |
20 | Correct | 8 ms | 632 KB | Output is correct |
21 | Correct | 8 ms | 504 KB | Output is correct |
22 | Correct | 9 ms | 632 KB | Output is correct |
23 | Correct | 9 ms | 632 KB | Output is correct |
24 | Correct | 9 ms | 632 KB | Output is correct |
25 | Correct | 8 ms | 636 KB | Output is correct |
26 | Correct | 8 ms | 504 KB | Output is correct |
27 | Correct | 8 ms | 504 KB | Output is correct |
28 | Correct | 8 ms | 632 KB | Output is correct |
29 | Correct | 9 ms | 632 KB | Output is correct |
30 | Correct | 9 ms | 632 KB | Output is correct |
31 | Correct | 94 ms | 5204 KB | Output is correct |
32 | Correct | 377 ms | 20016 KB | Output is correct |
33 | Correct | 82 ms | 5072 KB | Output is correct |
34 | Correct | 317 ms | 19852 KB | Output is correct |
35 | Correct | 396 ms | 23896 KB | Output is correct |
36 | Correct | 400 ms | 24148 KB | Output is correct |
37 | Correct | 418 ms | 23984 KB | Output is correct |
38 | Correct | 401 ms | 24012 KB | Output is correct |
39 | Correct | 440 ms | 23912 KB | Output is correct |
40 | Correct | 377 ms | 20120 KB | Output is correct |
41 | Correct | 378 ms | 19876 KB | Output is correct |
42 | Correct | 398 ms | 24000 KB | Output is correct |
43 | Correct | 388 ms | 24012 KB | Output is correct |
44 | Correct | 390 ms | 23992 KB | Output is correct |
45 | Correct | 404 ms | 24088 KB | Output is correct |