#include #include typedef struct Q { //퀴리를 담을 구조체 int s, e, i; }Q; int main(void) { int n, m, nRoot; scanf("%d %d", &n, &m); nRoot = sqrt(n); //n의 제곱근 int arr[n+1]; //요소를 담을 배열 long long num[1000001]={}; //요소의 개수가 몇개 있는지를 나타내는 배열 (long long int으로 만들어야 곱하는 과정에서 overflow가 발생하지 않는다) Q query[m], key; for(int i=1; i=1; } int s = query[0].s, e = query[0].s-1; long long tmp = 0, ans[m]; //값은 주어진 범위 내에서..
#include #include int n, m, rootN; int num[200002]={}; //특정 숫자의 개수 int now[100001]={}; //같은 숫자들의 중복의 크기를 담음 //ex 1, 2, 3, 3, 4, 5, 5, 5 now[1] = 3, now[2] = 1, now[3] = 1; int main(void) { scanf("%d %d", &n, &m); //n m 입력 int arr[n+1]; //n개의 요소들을 담을 배열 rootN = sqrt(n); //n의 제곱근 for(int i=1; i= 1; } //mo.s 알고리즘에 의해 정렬된 쿼리들을 순차적으로 실행 int s=query[0][0], e=query[0][1], is=0; //s는 start, e는 end, is는 ..
#include #include #include #include #include using namespace std; int n, m, nSqrt, cnt=1; struct Query { //쿼리를 담을 구조체 int s, e, i; bool operator < (Query &other) { //sort에서 구조체타입의 비교 연산을 위해 연산자 오버로딩, Mo.s 알고리즘 이용 int a = s/nSqrt; int b = other.s/nSqrt; if(a != b) return a < b; //1. start/N의 제곱근이 더 작은것이 우선 return e < other.e; //2. 1.의 값이 같다면 end값이 더 작은 쿼리가 우선 } }; int main(void) { map M; //좌표압축을 ..
- Total
- Today
- Yesterday
- DP
- 16120번
- Mo.s
- java
- 세그먼트 트리
- 오프라인 쿼리
- 덱
- 누적 합
- C언어
- find
- 최대공약수
- 1835
- C++
- 백준
- 플로이드
- union
- 스택
- Krustal
- 6198
- 그래프
- BFS
- 6198번
- 누적합
- 1835번
- 트리
- DFS
- 최소 스패닝 트리
- 그리디
- 정렬
- 카드
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |