반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 성적평가
- 퇴사통보
- 백트래킹
- Kafka
- Docker
- softeer
- OFFSET
- 6987
- 파라메트릭
- 소프티어
- 기술면접
- 매개변수탐색
- BOJ
- 물채우기
- dfs
- incr
- 이분탐색
- msSQL
- 처우산정
- @P0
- upper_bound
- 13908
- compose
- 연결요소
- 오퍼레터
- boj #19237 #어른 상어
- 백준
- 경력
- BFS
- 처우협의
Archives
- Today
- Total
기술 블로그
10804번 카드 역배치 본문
728x90
반응형
https://www.acmicpc.net/problem/10804
주어진 인덱스 범위 안에서 내림차순 하는 줄로 착각했다.
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 | #include <iostream> #include <queue> #include <stack> #include <cstdio> #include <vector> #include <cstring> #include <string> #include <math.h> #include <algorithm> #include <map> using namespace std; vector<int> v; void change(int left, int right) { while (1) { swap(v.at(left), v.at(right)); ++left; --right; if (left >= right) break; } } int main(void) { for (int i = 1; i <= 20; i++) { v.push_back(i); } int left = 0, right = 0; for (int i = 0; i < 10; i++) { scanf("%d %d", &left, &right); --left; --right; change(left, right); } for (auto i : v) printf("%d ", i); printf("\n"); return 0; } | cs |
728x90
반응형
'알고리즘 문제 > BOJ' 카테고리의 다른 글
2512번 예산 (0) | 2018.12.13 |
---|---|
4690번 완전 세제곱 (0) | 2018.12.09 |
2503번 숫자 야구 (0) | 2018.12.09 |
1021번 회전하는 큐 (0) | 2018.12.09 |
1057번 토너먼트 (0) | 2018.12.07 |