buggy_code
stringlengths
11
625k
fixed_code
stringlengths
17
625k
bug_type
stringlengths
2
4.45k
language
int64
0
8
token_count
int64
5
200k
change_count
int64
0
100
#include <stdio.h> #define MAX 100000 #define INFINITY 2000000000 struct Card { char s; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void marge(struct Card[], int, int, int); void margeSort(struct Card[], int, int); int partition(struct Card[], int, int, int); void quickSort(struct Card[], int, int...
#include <stdio.h> #define MAX 100000 #define INFINITY 2000000000 struct Card { char s; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void marge(struct Card[], int, int, int); void margeSort(struct Card[], int, int); int partition(struct Card[], int, int, int); void quickSort(struct Card[], int, int...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
777
2
#include <stdio.h> #include <string.h> #define INFTY 200000000 #define MAX 200000 struct card { char character; int value; }; void Merge(struct card[], int, int, int, int); void MergeSort(struct card[], int, int, int); void QuickSort(struct card[], int, int, int); int Partition(struct card[], int, int, int); st...
#include <stdio.h> #include <string.h> #define INFTY 200000000 #define MAX 200000 struct card { char character; int value; }; void Merge(struct card[], int, int, int, int); void MergeSort(struct card[], int, int, int); void QuickSort(struct card[], int, int, int); int Partition(struct card[], int, int, int); st...
[["-", 64, 9, 0, 1, 0, 11, 31, 69, 71, 22], ["+", 64, 9, 0, 1, 0, 11, 31, 69, 71, 22], ["-", 0, 9, 0, 1, 0, 11, 31, 69, 71, 22], ["+", 0, 9, 0, 1, 0, 11, 31, 69, 71, 22]]
0
851
4
#include <stdio.h> #include <stdlib.h> int A[100000], A1[1000000], n, flag, cnt; char C[100000], C1[1000000]; int Partition(int p, int r) { int i, j, tmpn, x; char tmpc; x = A[r]; i = p - 1; for (j = p; j <= r - 1; j++) { if (A[j] <= x) { i = i + 1; tmpn = A[j]; A[j] = A[i]; A[i]...
#include <stdio.h> #include <stdlib.h> int A[100000], A1[1000000], n, flag, cnt; char C[100000], C1[1000000]; int Partition(int p, int r) { int i, j, tmpn, x; char tmpc; x = A[r]; i = p - 1; for (j = p; j <= r - 1; j++) { if (A[j] <= x) { i = i + 1; tmpn = A[j]; A[j] = A[i]; A[i]...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
848
2
#include <stdio.h> #define MAX 100000 #define INF 1000000000 typedef struct card { char s; int v; } Card; void merge(Card A[], int l, int m, int r) { Card R[MAX / 2 + 2], L[MAX / 2 + 2]; int i, j, k; int n1, n2; n1 = m - l; n2 = r - m; for (i = 0; i < n1; i++) { L[i] = A[l + i]; } for (i = 0;...
#include <stdio.h> #define MAX 100000 #define INF 1000000000 typedef struct card { char s; int v; } Card; void merge(Card A[], int l, int m, int r) { Card R[MAX / 2 + 2], L[MAX / 2 + 2]; int i, j, k; int n1, n2; n1 = m - l; n2 = r - m; for (i = 0; i < n1; i++) { L[i] = A[l + i]; } for (i = 0;...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
699
2
#include <stdio.h> typedef struct { int a; char c; } Card; Card A[100003], B[100003]; int partition(int, int); void quickSort(int, int); void merge(int, int, int); void mergeSort(int, int); int main() { int n, r, i, judge = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", &A[i].c); sca...
#include <stdio.h> typedef struct { int a; char c; } Card; Card A[100003], B[100003]; int partition(int, int); void quickSort(int, int); void merge(int, int, int); void mergeSort(int, int); int main() { int n, r, i, judge = 0; scanf("%d", &n); for (i = 0; i < n; i++) { scanf("%s", &A[i].c); sca...
[["-", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 64, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
700
2
#include <stdio.h> #define MAX 100000 /* Struct Declaration */ typedef struct card { char p; int num; } Card; /* Prototype Declaration */ int partition(Card *, int, int); void quickSort(Card *, int, int); void merge(Card *, int, int, int); void mergeSort(Card *, int, int); /* Global Variable */ Card L[(MAX / 2) ...
#include <stdio.h> #define MAX 100000 /* Struct Declaration */ typedef struct card { char p; int num; } Card; /* Prototype Declaration */ int partition(Card *, int, int); void quickSort(Card *, int, int); void merge(Card *, int, int, int); void mergeSort(Card *, int, int); /* Global Variable */ Card L[(MAX / 2) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
0
781
2
//============================================================================ // Name : Partition.cpp // Author : Ken // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #incl...
//============================================================================ // Name : Partition.cpp // Author : Ken // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #incl...
[["-", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 0, 9, 0, 1, 0, 16, 12, 5, 0, 6]]
1
920
2
#include <iostream> #include <utility> #include <vector> using namespace std; class Card { public: char suit; int number; Card() {} Card(const Card &card) { this->suit = card.suit; this->number = card.number; } }; void quick_sort(vector<Card *> &cards, int start, int end); void merge_sort(vector<C...
#include <iostream> #include <utility> #include <vector> using namespace std; class Card { public: char suit; int number; Card() {} Card(const Card &card) { this->suit = card.suit; this->number = card.number; } }; void quick_sort(vector<Card *> &cards, int start, int end); void merge_sort(vector<C...
[["+", 0, 57, 15, 339, 51, 16, 31, 118, 17, 143], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 17, 143], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120]]
1
848
4
#include <stdio.h> const int maxn = 100000 + 10; const long long big = 2000000000; struct card { int shu; char fu; }; card L[maxn / 2 + 2], R[maxn / 2 + 2]; void zhenghe(card a[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n1; i++) L[i] = a[left + i]; ...
#include <stdio.h> const int maxn = 100000 + 10; const long long big = 2000000000; struct card { int shu; char fu; }; card L[maxn / 2 + 2], R[maxn / 2 + 2]; void zhenghe(card a[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n1; i++) L[i] = a[left + i]; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
689
2
#include <cstdio> #define MAX 100001 #define INF 2000000000 struct Card { char suit; int value; }; Card L[MAX / 2 + 1]; Card R[MAX / 2 + 1]; void merge(Card *A, int l, int mid, int r) { int n1 = mid - l; int n2 = r - mid; int i, j; for (i = 0; i < n1; ++i) { L[i] = A[l + i]; } for (i = 0; i < n...
#include <cstdio> #define MAX 100001 #define INF 2000000000 struct Card { char suit; int value; }; Card L[MAX / 2 + 1]; Card R[MAX / 2 + 1]; void merge(Card *A, int l, int mid, int r) { int n1 = mid - l; int n2 = r - mid; int i, j; for (i = 0; i < n1; ++i) { L[i] = A[l + i]; } for (i = 0; i < n...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 20], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 47], ["-", 0, 2, 3, 4, 0, 118, 28, 69, 28, 22], ["+", 0, 2, 3, 4, 0, 118, 28, 69, 28, 22]]
1
682
6
#include <iostream> #include <utility> #include <vector> using namespace std; class card { public: char suit; int val; card() {} card(char s, int v) { suit = s; val = v; } bool operator<=(card &e) { return this->val <= e.val; } bool operator<(card &e) { return this->val < e.val; } card &operat...
#include <iostream> #include <utility> #include <vector> using namespace std; class card { public: char suit; int val; card() {} card(char s, int v) { suit = s; val = v; } bool operator<=(card &e) { return this->val <= e.val; } bool operator<(card &e) { return this->val < e.val; } card &operat...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19], ["-", 15, 339, 51, 16, 12, 16, 12, 118, 119, 120], ["+", 15, 339, 51, 16, 12, 16, 12, 118, 119, 120]]
1
756
4
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 typedef struct card { char suit; int value; } Card; Card L[MAX / 2 + 1], R[MAX / 2 + 1]; void merge(Card A[], int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) L[i] = A[lef...
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 typedef struct card { char suit; int value; } Card; Card L[MAX / 2 + 1], R[MAX / 2 + 1]; void merge(Card A[], int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) L[i] = A[lef...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
692
2
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct Card { char mark; int num; }; Card Cards1[500000]; Card Cards2[500000]; int partition(int p, int r) { int x = Cards1[r].num; int i = p - 1; for (int j = p; j < r; j++) { if (Cards1[j].num <= x) { i++; swa...
#include <algorithm> #include <iostream> #include <vector> using namespace std; struct Card { char mark; int num; }; Card Cards1[500000]; Card Cards2[500000]; int partition(int p, int r) { int x = Cards1[r].num; int i = p - 1; for (int j = p; j < r; j++) { if (Cards1[j].num <= x) { i++; swa...
[["-", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 69, 28, 22]]
1
646
2
#include <algorithm> #include <cstdlib> #include <iostream> using namespace std; #define MAX 100000 typedef pair<char, int> paCard; paCard A[MAX], B[MAX]; int Partition(int nLeft, int nRight) { int x = A[nRight].second; int nIndex = nLeft - 1; for (int i = nLeft; i < nRight; i++) // here it is nRight { if...
#include <algorithm> #include <cstdlib> #include <iostream> using namespace std; #define MAX 100000 typedef pair<char, int> paCard; paCard A[MAX], B[MAX]; int Partition(int nLeft, int nRight) { int x = A[nRight].second; int nIndex = nLeft - 1; for (int i = nLeft; i < nRight; i++) // here it is nRight { if...
[["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
1
371
2
#include <iostream> using namespace std; #define MAX 100000 #define SENTINEL 2000000000 struct Card { int number; char mark; }; int partition(Card C[], int p, int r) { int x = C[r].number; int i = p - 1; Card tmp; for (int j = p; j < r; j++) { if (C[j].number <= x) { i++; tmp = C[i]; ...
#include <iostream> using namespace std; #define MAX 100000 #define SENTINEL 2000000000 struct Card { int number; char mark; }; int partition(Card C[], int p, int r) { int x = C[r].number; int i = p - 1; Card tmp; for (int j = p; j < r; j++) { if (C[j].number <= x) { i++; tmp = C[i]; ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22]]
1
685
2
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i) #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() using namespace std; using vi = vector<int>; using i64 = int64_t; constexpr int INF = 1 << 30; constexpr int M...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i) #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() using namespace std; using vi = vector<int>; using i64 = int64_t; constexpr int INF = 1 << 30; constexpr int M...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
663
2
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i) #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() using namespace std; using vi = vector<int>; using i64 = int64_t; constexpr int INF = 1 << 30; constexpr int M...
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i) #define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define ALL(obj) (obj).begin(), (obj).end() using namespace std; using vi = vector<int>; using i64 = int64_t; constexpr int INF = 1 << 30; constexpr int M...
[["-", 0, 218, 8, 9, 0, 37, 0, 16, 17, 47], ["+", 0, 218, 8, 9, 0, 37, 0, 16, 17, 18]]
1
440
2
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <stack> using namespace std; #define MAX 100005 #define INF 0x7fffffff struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int n, int left, int mid, int right) { int i, j, ...
#include <cmath> #include <cstdio> #include <cstring> #include <iostream> #include <stack> using namespace std; #define MAX 100005 #define INF 2E9 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int n, int left, int mid, int right) { int i, j, k; in...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 51, 16, 12, 118, 28, 69, 341, 342, 0, 22], ["+", 51, 16, 12, 118, 28, 69, 341, 342, 0, 22]]
1
736
4
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <...
#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 0, 30, 0, 43, 49, 50, 51, 16, 12, 13], ["-", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 63, 118, 119, 120], ["+", 0, 2, 3, 4, 0, 2, 3, 4, 0, 22]]
1
790
5
#include <algorithm> #include <cstdio> using namespace std; #define INF 1234567890; struct Card { char suit; int value; }; Card L[300000], R[300000]; void merge(Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n1; i++) L[i] = A[left + i]; for (i...
#include <algorithm> #include <cstdio> using namespace std; #define INF 1234567890; struct Card { char suit; int value; }; Card L[100000], R[100000]; void merge(Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n1; i++) L[i] = A[left + i]; for (i...
[["-", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 80, 81, 13], ["-", 0, 1, 0, 11, 12, 118, 28, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 118, 28, 69, 28, 22]]
1
665
6
/*! if g++ -g alds_1_6_c.cpp -o alds_1_6_c.out; then ./alds_1_6_c.out < * alds_1_6_c.test; fi */ #include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <iterator> #include <map> #include <nu...
#include <algorithm> #include <cctype> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <functional> #include <iostream> #include <iterator> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #includ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
845
2
#include <iostream> using namespace std; struct card { char suit; int num; }; card A[100000]; int partition(int p, int r) { int x = A[r].num; int i = p - 1; for (int j = p; j < r; j++) { if (A[j].num <= x) { i++; swap(A[i], A[j]); } } swap(A[i + 1], A[r]); return i + 1; } void qui...
#include <iostream> using namespace std; struct card { char suit; int num; }; card A[100000]; int partition(int p, int r) { int x = A[r].num; int i = p - 1; for (int j = p; j < r; j++) { if (A[j].num <= x) { i++; swap(A[i], A[j]); } } swap(A[i + 1], A[r]); return i + 1; } void qui...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
424
2
#include <iostream> #include <string> using namespace std; struct Card { char suit; int val; }; const int MAX = 100000, SENTINEL = 2100000000; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; int cnt; void merge(Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0;...
#include <iostream> #include <string> using namespace std; struct Card { char suit; int val; }; const int MAX = 100000, SENTINEL = 2100000000; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; int cnt; void merge(Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0;...
[["+", 0, 14, 49, 53, 54, 55, 0, 56, 39, 40], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
671
3
#include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <utility> #include <vector> #define MAX 10010 using namespace std; template <typename T> class Sort { public: Sort(); Sort(vector<T> &arr) { A = arr; } vector<T> A; void dispArr() { for (int i = 0; i < A.size() - 1; i++) ...
#include <climits> #include <cmath> #include <cstdio> #include <iostream> #include <utility> #include <vector> #define MAX 10010 using namespace std; template <typename T> class Sort { public: Sort(); Sort(vector<T> &arr) { A = arr; } vector<T> A; void dispArr() { for (int i = 0; i < A.size() - 1; i++) ...
[["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
1
837
2
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; class card { char ch; int num; public: card() { this->ch = ' '; this->num = 0; } card(char a, int m) { this->ch = a, this->num = m; } void set(int m) { this->num = m; ...
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> using namespace std; class card { char ch; int num; public: card() { this->ch = ' '; this->num = 0; } card(char a, int m) { this->ch = a, this->num = m; } void set(int m) { this->num = m; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
765
2
#include <algorithm> #include <cstdio> #define MAX 100000 #define INF 2e9 struct Card { char suit; int val; }; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j; for (int i = 0; i < n1; i++) { L[i] = A[...
#include <algorithm> #include <cstdio> #define MAX 100000 #define INF 2e9 struct Card { char suit; int val; }; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j; for (int i = 0; i < n1; i++) { L[i] = A[...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 31, 22]]
1
693
2
#include <algorithm> #include <iostream> #define DUMMY 'X' #define INF 1000000001 using namespace std; int partition(pair<char, int> array[], int p, int r) { pair<char, int> x = array[r]; int i = p - 1; for (int j = p; j < r; j++) { if (array[j].second <= x.second) { i++; swap(array[i], array[j])...
#include <algorithm> #include <iostream> #define DUMMY 'X' #define INF 1000000001 using namespace std; int partition(pair<char, int> array[], int p, int r) { pair<char, int> x = array[r]; int i = p - 1; for (int j = p; j < r; j++) { if (array[j].second <= x.second) { i++; swap(array[i], array[j])...
[["+", 0, 57, 15, 339, 51, 16, 31, 118, 17, 131], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 17, 131], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120]]
1
688
4
#include <iostream> #define INF 1000000000 using namespace std; struct Card { char suit; int num; }; void merge(Card a[], int left, int mid, int right); void mergeSort(Card a[], int left, int right); int partition(Card a[], int p, int r); void quickSort(Card a[], int p, int r); bool isStable(Card a[], Card b[], i...
#include <iostream> #define INF 1000000000 using namespace std; struct Card { char suit; int num; }; void merge(Card a[], int left, int mid, int right); void mergeSort(Card a[], int left, int right); int partition(Card a[], int p, int r); void quickSort(Card a[], int p, int r); bool isStable(Card a[], Card b[], i...
[["-", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["+", 0, 14, 8, 9, 0, 43, 49, 80, 81, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
754
10
#include <iostream> #define MAX 100000 #define SENTINEL 2000000000 using namespace std; struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n1; i++) { ...
#include <iostream> #define MAX 100000 #define SENTINEL 2000000000 using namespace std; struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n1; i++) { ...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
704
2
#include <iostream> struct Card { char m; int n; int index; }; int partition(Card *a, int p, int r) { int x = a[r].n; int i = p - 1; for (int j = p; j <= r; j++) { if (a[j].n <= x) { i++; Card tmp = a[i]; a[i] = a[j]; a[j] = tmp; } } return i; } void quickSort(Card *a, in...
#include <iostream> struct Card { char m; int n; int index; }; int partition(Card *a, int p, int r) { int x = a[r].n; int i = p - 1; for (int j = p; j <= r; j++) { if (a[j].n <= x) { i++; Card tmp = a[i]; a[i] = a[j]; a[j] = tmp; } } return i; } void quickSort(Card *a, in...
[["-", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 57, 64, 9, 0, 1, 0, 2, 63, 22], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
431
8
#include <iostream> using namespace std; const int MAX = 100000; struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; inline void merge(struct Card A[], int n, int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) ...
#include <iostream> using namespace std; const int MAX = 100000; struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; inline void merge(struct Card A[], int n, int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) ...
[["-", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6], ["+", 75, 76, 0, 1, 0, 16, 12, 5, 0, 6]]
1
718
2
#include <iostream> #define N 1000000 #define INF 1000000006 using namespace std; struct card { char f; int s; }; card a[N], L[N], R[N], b[N]; int n, cnt; void merge(int l, int m, int r) { int n1 = m - l, n2 = r - m; for (int i = 0; i < n1; i++) L[i] = b[l + i]; for (int i = 0; i < n2; i++) R[i] = ...
#include <iostream> #define N 1000000 #define INF 1000000006 using namespace std; struct card { char f; int s; }; card a[N], L[N], R[N], b[N]; int n, cnt; void merge(int l, int m, int r) { int n1 = m - l, n2 = r - m; for (int i = 0; i < n1; i++) L[i] = b[l + i]; for (int i = 0; i < n2; i++) R[i] = ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
620
2
#include <iostream> #include <limits> #include <vector> using namespace std; struct TCard { int Number; char Mark; }; int Partition(vector<TCard> &A, int p, int r) { int i = p - 1; for (int j = p; j < r; j++) { if (A[j].Number <= A[r].Number) { i++; swap(A[i], A[j]); } } swap(A[i + 1],...
#include <iostream> #include <limits> #include <vector> using namespace std; struct TCard { int Number; char Mark; }; int Partition(vector<TCard> &A, int p, int r) { int i = p - 1; for (int j = p; j < r; j++) { if (A[j].Number <= A[r].Number) { i++; swap(A[i], A[j]); } } swap(A[i + 1],...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
692
2
#include <iostream> #include <string> #include <vector> using namespace std; #define MAX_LEN 50000 #define BIG 2000000000 class MergeSort { private: vector<pair<int, char>> tmp; void merge(vector<pair<int, char>> &data, int l, int m, int h) { for (int i = l; i < h; ++i) tmp[i] = data[i]; int i = l...
#include <iostream> #include <string> #include <vector> using namespace std; #define MAX_LEN 50000 #define BIG 2000000000 class MergeSort { private: vector<pair<int, char>> tmp; void merge(vector<pair<int, char>> &data, int l, int m, int h) { for (int i = l; i < h; ++i) tmp[i] = data[i]; int i = l...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
851
2
#include <iostream> #include <map> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; long long cnt; struct SSS { string str; int val; SSS(string s = "", int v = 0) : str(s), val(v){}; }; void print(vector<SSS> &data) { for (int i = 0; i...
#include <iostream> #include <map> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; long long cnt; struct SSS { string str; int val; SSS(string s = "", int v = 0) : str(s), val(v){}; }; void print(vector<SSS> &data) { for (int i = 0; i...
[["-", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 31, 118, 119, 120], ["-", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120], ["+", 0, 57, 15, 339, 51, 16, 12, 118, 119, 120]]
1
789
4
#include <iostream> #include <map> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; long long cnt; struct SSS { string str; int val; SSS(string s = "", int v = 0) : str(s), val(v){}; }; void print(vector<SSS> &data) { for (int i = 0; i...
#include <iostream> #include <map> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <vector> using namespace std; long long cnt; struct SSS { string str; int val; SSS(string s = "", int v = 0) : str(s), val(v){}; }; void print(vector<SSS> &data) { for (int i = 0; i...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
758
4
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 100000; struct Card { char suit; int value; bool operator<=(const Card &right) const { return value <= right.value; } }; Card sentinel = Card{1, 1000000000}; int merge(Card A[], int left, int mid, int right) { int n1 = mid -...
#include <algorithm> #include <iostream> using namespace std; static const int MAX = 100000; struct Card { char suit; int value; bool operator<=(const Card &right) const { return value <= right.value; } }; Card sentinel = Card{1, 1000000000}; int merge(Card A[], int left, int mid, int right) { int n1 = mid -...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
662
2
// ues the stable sort-mergesort to chek quick-sort #include <iostream> #include <limits.h> using namespace std; const int MAX = 100000; const int STN = INT_MAX; struct Card { char suit; int num; }; Card L[MAX / 2 + 2]; Card R[MAX / 2 + 2]; void merge(Card *A, int left, int mid, int right) { int n1 = mid - l...
// ues the stable sort-mergesort to chek quick-sort #include <iostream> #include <limits.h> using namespace std; const int MAX = 100000; const int STN = INT_MAX; struct Card { char suit; int num; }; Card L[MAX / 2 + 2]; Card R[MAX / 2 + 2]; void merge(Card *A, int left, int mid, int right) { int n1 = mid - l...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
669
2
#include <algorithm> #include <iostream> using namespace std; struct Card { char a; int b; }; bool compare_as_ints(Card i, Card j) { return (i.b < j.b); } int partition(Card A[], int p, int r) { Card x = A[r]; int i = p - 1; for (int j = p; j <= r - 1; j++) { if (A[j].b <= x.b) { i++; swap(...
#include <algorithm> #include <iostream> using namespace std; struct Card { char a; int b; }; bool compare_as_ints(Card i, Card j) { return (i.b < j.b); } int partition(Card A[], int p, int r) { Card x = A[r]; int i = p - 1; for (int j = p; j <= r - 1; j++) { if (A[j].b <= x.b) { i++; swap(...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
403
2
#include <iostream> #include <utility> #include <vector> using namespace std; int partition(vector<pair<char, int>> &A, int p, int r) { int i = p - 1; for (int j = p; j < r; j++) { if (A[j].second > A[r].second) continue; swap(A[++i], A[j]); } swap(A[++i], A[r]); return i; } void quick_sort(vec...
#include <iostream> #include <utility> #include <vector> using namespace std; int partition(vector<pair<char, int>> &A, int p, int r) { int i = p - 1; for (int j = p; j < r; j++) { if (A[j].second > A[r].second) continue; swap(A[++i], A[j]); } swap(A[++i], A[r]); return i; } void quick_sort(vec...
[["-", 0, 11, 12, 23, 0, 41, 15, 16, 17, 18], ["+", 0, 11, 12, 23, 0, 41, 15, 16, 17, 19]]
1
616
2
#include <cassert> #include <iostream> #include <queue> #define INF 922337203685477580 typedef long long ll; using namespace std; typedef struct { char type; ll value; } Card; int partition(Card *A, int p, int r) { int x = A[r].value; int i = p - 1; for (int j = p; j < r; j++) { if (A[j].value <= x) {...
#include <cassert> #include <iostream> #include <queue> #define INF 922337203685477580 typedef long long ll; using namespace std; typedef struct { char type; ll value; } Card; int partition(Card *A, int p, int r) { ll x = A[r].value; int i = p - 1; for (int j = p; j < r; j++) { if (A[j].value <= x) { ...
[["-", 0, 30, 0, 14, 8, 9, 0, 43, 39, 40], ["+", 0, 30, 0, 14, 8, 9, 0, 43, 39, 78]]
1
448
2
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 100005; struct card { char suit; int value; }; card A1[MAXN], A2[MAXN], L[MAXN / 2], R[MAXN / 2]; void merge(card A[], int left, int ...
#include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN = 100005; struct card { char suit; int value; }; card A1[MAXN], A2[MAXN], L[MAXN / 2], R[MAXN / 2]; void merge(card A[], int left, int ...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 22]]
1
678
2
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; const int INF = (1 << 30); const int N = 100005; struct Card { char suit; int value; } card[N], t[N]; Card L[N / 2 + 1], R[N / 2 + 1]; void _merge(Card a[], int l, int m, int r) //[l, r) { int i, j, k; int n1 = m - l; int n2 = r ...
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; const int INF = (1 << 30); const int N = 100005; struct Card { char suit; int value; } card[N], t[N]; Card L[N / 2 + 1], R[N / 2 + 1]; void _merge(Card a[], int l, int m, int r) //[l, r) { int i, j, k; int n1 = m - l; int n2 = r ...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22]]
1
644
46
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; const int INF = (1 << 30); const int N = 100005; struct Card { char suit; int value; } card[N], t[N], temp; Card L[N / 2 + 1], R[N / 2 + 1]; void _merge(Card a[], int l, int m, int r) //[l, r) { int i, j, k; int n1 = m - l; int n...
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; const int INF = (1 << 30); const int N = 100005; struct Card { char suit; int value; } card[N], t[N], temp; Card L[N / 2 + 1], R[N / 2 + 1]; void _merge(Card a[], int l, int m, int r) //[l, r) { int i, j, k; int n1 = m - l; int n...
[["-", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 8, 9, 0, 43, 49, 50, 51, 16, 12, 13]]
1
670
2
#include <iostream> #define INF 2000000000 using namespace std; struct Card { char s; int n; }; Card L[50002], R[50002]; void merge(Card a[], int l, int m, int r) { int n1 = m - l; int n2 = r - m; for (int i = 0; i < n1; i++) L[i] = a[l + i]; for (int i = 0; i < n2; i++) R[i] = a[m + i]; L[n1]....
#include <iostream> #define INF 2000000000 using namespace std; struct Card { char s; int n; }; Card L[50002], R[50002]; void merge(Card a[], int l, int m, int r) { int n1 = m - l; int n2 = r - m; for (int i = 0; i < n1; i++) L[i] = a[l + i]; for (int i = 0; i < n2; i++) R[i] = a[m + i]; L[n1]....
[["+", 31, 16, 12, 23, 0, 41, 64, 5, 0, 6], ["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["-", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 62], ["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
632
7
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int n, int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) L[i...
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int n, int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) L[i...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
729
2
#include <climits> #include <iostream> #include <vector> using namespace std; class Card { public: uint8_t suit; int32_t num; Card() { suit = 'S'; num = 1; } Card(uint8_t suit, int32_t num) : suit(suit), num(num) {} Card &operator=(int n) { num = n; return *this; } }; bool operator<(...
#include <climits> #include <iostream> #include <vector> using namespace std; class Card { public: uint8_t suit; int32_t num; Card() { suit = 'S'; num = 1; } Card(uint8_t suit, int32_t num) : suit(suit), num(num) {} Card &operator=(int n) { num = n; return *this; } }; bool operator<(...
[["-", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6], ["+", 31, 16, 12, 23, 0, 41, 75, 5, 0, 6]]
1
793
2
#include <bits/stdc++.h> #define INF 1234567890 using namespace std; int partition(int *A, char *B, int p, int r) { int x = A[r]; int i = p - 1; for (int j = p; j < r; j++) { if (A[j] <= x) { i++; swap(A[i], A[j]); swap(B[i], B[j]); } } swap(A[i + 1], A[r]); swap(B[i + 1], B[r]); ...
#include <bits/stdc++.h> #define INF 1234567890 using namespace std; int partition(int *A, char *B, int p, int r) { int x = A[r]; int i = p - 1; for (int j = p; j < r; j++) { if (A[j] <= x) { i++; swap(A[i], A[j]); swap(B[i], B[j]); } } swap(A[i + 1], A[r]); swap(B[i + 1], B[r]); ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
749
2
#include <iostream> #define M 100000 #define S 2000000000 using namespace std; struct card { int num; char d; }; void merge(card *a, int l, int m, int r) { card L[m / 2 + 2]; card R[m / 2 + 2]; int n1 = m - l; int n2 = r - m; int b = 0, c = 0; for (int i = 0; i < n1; i++) L[i] = a[l + i]; for ...
#include <iostream> #define M 100000 #define S 2000000000 using namespace std; struct card { int num; char d; }; void merge(card *a, int l, int m, int r) { card L[M / 2 + 2]; card R[M / 2 + 2]; int n1 = m - l; int n2 = r - m; int b = 0, c = 0; for (int i = 0; i < n1; i++) L[i] = a[l + i]; for ...
[["-", 0, 43, 49, 80, 81, 16, 31, 16, 31, 22], ["+", 0, 43, 49, 80, 81, 16, 31, 16, 31, 22]]
1
672
4
#include <bits/stdc++.h> #define MAX 100000 #define SENTINEL 2000000000 using namespace std; struct Card { char design; int num; }; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void mergeSort(Card[], int, int, int); int partition(Card[], int, int, int); void quickSort(Card[], int, int, int); void merge(Card[], int, int...
#include <bits/stdc++.h> #define MAX 100000 #define SENTINEL 2000000000 using namespace std; struct Card { char design; int num; }; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void mergeSort(Card[], int, int, int); int partition(Card[], int, int, int); void quickSort(Card[], int, int, int); void merge(Card[], int, int...
[["-", 0, 14, 8, 9, 0, 7, 10, 11, 31, 22], ["+", 0, 14, 8, 9, 0, 7, 10, 11, 31, 22], ["-", 0, 14, 8, 9, 0, 7, 15, 16, 31, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 31, 22], ["-", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22], ["+", 0, 14, 8, 9, 0, 7, 26, 27, 28, 22]]
1
778
6
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int n, int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) { L[...
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int n, int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) { L[...
[["-", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["+", 0, 14, 8, 9, 0, 7, 15, 16, 12, 22], ["-", 0, 57, 64, 9, 0, 1, 0, 34, 0, 21], ["+", 8, 9, 0, 57, 64, 9, 0, 1, 0, 35], ["-", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 64, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 2...
1
738
8
#include <cstdio> #include <cstring> #include <iostream> #define SENTINEL 1000000001 using namespace std; struct Card { char suit; int num; }; void merge(Card A[], int left, int mid, int right) { int nl = mid - left; int nr = right - mid; Card L[nl + 1]; Card R[nr + 1]; L[nl].num = SENTINEL; R[nr].num...
#include <cstdio> #include <cstring> #include <iostream> #define SENTINEL 1000000001 using namespace std; struct Card { char suit; int num; }; void merge(Card A[], int left, int mid, int right) { int nl = mid - left; int nr = right - mid; Card L[nl + 1]; Card R[nr + 1]; L[nl].num = SENTINEL; R[nr].num...
[["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
655
2
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; int A[MAX], n; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j, k; for (i = 0; i < n1;...
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; int A[MAX], n; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j, k; for (i = 0; i < n1;...
[["-", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["+", 0, 57, 64, 9, 0, 1, 0, 11, 12, 13], ["-", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 12, 13]]
1
757
4
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) { L[i] = A[...
#include <stdio.h> #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) { L[i] = A[...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 22]]
1
705
2
//#define FILE_INPUT_DEFINE #ifdef FILE_INPUT_DEFINE #include <fstream> #endif // FILE_INPUT_DEFINE #include <deque> #include <iostream> #include <string> #include <unordered_map> using namespace std; #define MAX 100000 struct SN { char S; int N; }; SN A[MAX]; void swap(int a, int b) { SN temp(A[a]); A[a...
//#define FILE_INPUT_DEFINE #ifdef FILE_INPUT_DEFINE #include <fstream> #endif // FILE_INPUT_DEFINE #include <deque> #include <iostream> #include <string> #include <unordered_map> using namespace std; #define MAX 100000 struct SN { char S; int N; }; SN A[MAX]; void swap(int a, int b) { SN temp(A[a]); A[a...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 60], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 79]]
1
478
2
#include <stdio.h> using namespace std; #define MAX 100000 struct Card { char suit; int value; }; Card tempCard[MAX]; void swap(Card A[], int index1, int index2) { int temp; char c; temp = A[index1].value; c = A[index1].suit; A[index1].value = A[index2].value; A[index1].suit = A[index2].suit; A[i...
#include <stdio.h> using namespace std; #define MAX 100000 struct Card { char suit; int value; }; Card tempCard[MAX]; void swap(Card A[], int index1, int index2) { int temp; char c; temp = A[index1].value; c = A[index1].suit; A[index1].value = A[index2].value; A[index1].suit = A[index2].suit; A[i...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
785
2
#include <iostream> using namespace std; #define MAX 100000 #define SENTINEL 20000000 struct Card { char suit; int value; }; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(Card A[], int n, int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) ...
#include <iostream> using namespace std; #define MAX 100000 #define SENTINEL 20000000 struct Card { char suit; int value; }; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(Card A[], int n, int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; i++) ...
[["-", 0, 11, 12, 69, 341, 342, 0, 16, 12, 13], ["+", 0, 11, 12, 69, 341, 342, 0, 16, 12, 22]]
1
711
2
#include <algorithm> #include <iostream> #include <stdio.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rep3(i, k, n) for (int i = k; i < n; i++) #define INFTY 2000000000 #define MAX 500000 using namespace std; typedef struct Card { char s; int x; } C; int n; C L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge...
#include <algorithm> #include <iostream> #include <stdio.h> #define rep(i, n) for (int i = 0; i < n; i++) #define rep3(i, k, n) for (int i = k; i < n; i++) #define INFTY 2000000000 #define MAX 500000 using namespace std; typedef struct Card { char s; int x; } C; int n; C L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
652
2
// // main.cpp // quick_sort // // Created by ???????????? on 2017/10/08. // Copyright ?? 2017 ????????????. All rights reserved. // #include <climits> #include <cmath> #include <iostream> #include <stdio.h> using namespace std; struct Card { char suit; int num; }; void swap(Card *a, Card *b) { Card temp ...
// // main.cpp // quick_sort // // Created by ???????????? on 2017/10/08. // Copyright ?? 2017 ????????????. All rights reserved. // #include <climits> #include <cmath> #include <iostream> #include <stdio.h> using namespace std; struct Card { char suit; int num; }; void swap(Card *a, Card *b) { Card temp ...
[["+", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["+", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
689
2
#include <cstdio> #include <utility> #define MAX 100000 #define SENTINEL 200000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void Merge(struct Card A[], int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; ++...
#include <cstdio> #include <utility> #define MAX 100000 #define SENTINEL 1000000001 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void Merge(struct Card A[], int left, int mid, int right) { int i, j, k; int n1 = mid - left; int n2 = right - mid; for (i = 0; i < n1; +...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["-", 0, 11, 12, 69, 341, 342, 0, 27, 28, 22], ["+", 0, 11, 12, 69, 341, 342, 0, 27, 28, 22]]
1
693
4
#include <iostream> using namespace std; #define MAX 100001 #define SENTINEL 2000000000 struct Card { char suit; int val; }; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card B[], int left, int mid, int right) { int i, j, n1, n2, k; n1 = mid - left; n2 = right - mid; for (i = 0; i < n1; i++) { ...
#include <iostream> using namespace std; #define MAX 100001 #define SENTINEL 2000000000 struct Card { char suit; int val; }; Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card B[], int left, int mid, int right) { int i, j, n1, n2, k; n1 = mid - left; n2 = right - mid; for (i = 0; i < n1; i++) { ...
[["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 62], ["+", 0, 16, 31, 16, 31, 16, 12, 5, 0, 6], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151]]
1
594
4
#include <iostream> using namespace std; const int MAX_N = 100000; const int SENTINEL = 1000000000; struct Card { char suit; int value; }; Card L[MAX_N / 2 + 2], R[MAX_N / 2 + 2]; void merge(Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n...
#include <iostream> using namespace std; const int MAX_N = 100000; const int SENTINEL = 1000000000; struct Card { char suit; int value; }; Card L[MAX_N / 2 + 2], R[MAX_N / 2 + 2]; void merge(Card A[], int n, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n...
[["-", 8, 9, 0, 57, 15, 339, 51, 16, 17, 18], ["+", 8, 9, 0, 57, 15, 339, 51, 16, 17, 19]]
1
702
2
#include <algorithm> template <class T> int partition(T &A, int first, int last) { const int pivot = A[last - 1].second; int bound = first - 1; for (int i = first; i < last; ++i) if (A[i].second <= pivot) std::swap(A[++bound], A[i]); return bound; } template <class T> void quickSort(T &A, int first, ...
#include <algorithm> template <class T> int partition(T &A, int first, int last) { const int pivot = A[last - 1].second; int bound = first - 1; for (int i = first; i < last; ++i) if (A[i].second <= pivot) std::swap(A[++bound], A[i]); return bound; } template <class T> void quickSort(T &A, int first, ...
[["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 31, 22], ["+", 8, 9, 0, 1, 0, 16, 31, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 17, 151], ["+", 0, 14, 8, 9, 0, 1, 0, 16, 12, 22]]
1
371
5
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <tuple> #include <u...
#include <algorithm> #include <bitset> #include <cmath> #include <complex> #include <cstdio> #include <fstream> #include <functional> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <tuple> #include <u...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
507
2
#include <stdio.h> #include <stdlib.h> const int MAXSIZE = 100000 + 2; const int INF = 1000000000 + 2; struct Card { char type; int data; } a[MAXSIZE], b[MAXSIZE]; struct Card L[MAXSIZE / 2 + 2], R[MAXSIZE / 2 + 2]; void Merge(struct Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right ...
#include <stdio.h> #include <stdlib.h> const int MAXSIZE = 100000 + 2; const int INF = 2000000000; struct Card { char type; int data; } a[MAXSIZE], b[MAXSIZE]; struct Card L[MAXSIZE / 2 + 2], R[MAXSIZE / 2 + 2]; void Merge(struct Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mi...
[["-", 0, 30, 0, 43, 49, 50, 51, 16, 31, 13], ["-", 0, 30, 0, 43, 49, 50, 51, 16, 17, 72], ["-", 0, 30, 0, 43, 49, 50, 51, 16, 12, 13], ["+", 36, 36, 0, 30, 0, 43, 49, 50, 51, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 72], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
707
6
#include <cstdio> #include <iostream> #define SENTINEL 1000000000 using namespace std; struct card { char c; int k; } a[100010], A[100010], temp; int partition(int p, int r) { int x = a[r].k, i = p - 1; int j; for (j = p; j < r; j++) if (a[j].k <= x) { i++; temp = a[j]; a[j] = a[i]; ...
#include <cstdio> #include <iostream> #define SENTINEL 1000000000 using namespace std; struct card { char c; int k; } a[100010], A[100010], temp; int partition(int p, int r) { int x = a[r].k, i = p - 1; int j; for (j = p; j < r; j++) if (a[j].k <= x) { i++; temp = a[j]; a[j] = a[i]; ...
[["-", 0, 2, 3, 4, 0, 118, 28, 69, 28, 22], ["+", 0, 2, 3, 4, 0, 118, 28, 69, 28, 22]]
1
622
4
#include <cmath> #include <cstdio> #include <utility> #include <vector> using namespace std; //????????¢??°??? int partition(vector<pair<char, int>> &A, int p, int r) { int x = A[r].second; int i, j; i = p - 1; for (j = p; j < r; j++) { if (A[j].second <= x) { i = i + 1; swap(A[i], A[j]...
#include <cmath> #include <cstdio> #include <utility> #include <vector> using namespace std; //????????¢??°??? int partition(vector<pair<char, int>> &A, int p, int r) { int x = A[r].second; int i, j; i = p - 1; for (j = p; j < r; j++) { if (A[j].second <= x) { i = i + 1; swap(A[i], A[j]...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
815
4
#include <climits> #include <iostream> #include <vector> using namespace std; struct Card { char suit; int val; }; int partition(vector<Card> &A, int p, int r) { int x = A[r].val; int i = p - 1; for (int j = p; j < r; ++j) { if (A[j].val <= x) { ++i; swap(A[i], A[j]); } } swap(A[i + ...
#include <climits> #include <iostream> #include <vector> using namespace std; struct Card { char suit; int val; }; int partition(vector<Card> &A, int p, int r) { int x = A[r].val; int i = p - 1; for (int j = p; j < r; ++j) { if (A[j].val <= x) { ++i; swap(A[i], A[j]); } } swap(A[i + ...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
659
2
#include <cstdio> #include <cstring> #define rep(i, n) for (int i = 0; i < (n); ++i) #define err(...) fprintf(stderr, __VA_ARGS__) constexpr int INF = 0x3f3f3f3f; struct PP { int n; char c; PP() {} bool operator>(const PP &rhs) const { return (n > rhs.n); } bool operator<(const PP &rhs) const { return (n < r...
#include <cstdio> #include <cstring> #define rep(i, n) for (int i = 0; i < (n); ++i) #define err(...) fprintf(stderr, __VA_ARGS__) constexpr int INF = 0x3f3f3f3f; struct PP { int n; char c; PP() {} bool operator>(const PP &rhs) const { return (n > rhs.n); } bool operator<(const PP &rhs) const { return (n < r...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
823
2
#include <algorithm> #include <cassert> #include <climits> #include <fstream> #include <iostream> #include <stdint.h> #include <stdio.h> using namespace std; #define DEBUG (1) #if DEBUG #define DPRINTF(...) \ do { ...
#include <algorithm> #include <cassert> #include <climits> #include <fstream> #include <iostream> #include <stdint.h> #include <stdio.h> using namespace std; #define DEBUG (0) #if DEBUG #define DPRINTF(...) \ do { ...
[["-", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59], ["+", 36, 36, 36, 36, 0, 30, 0, 58, 51, 59]]
1
1,116
2
#include <iostream> struct Card { char suit; int value; }; constexpr int MAXNUM = 100000; constexpr int SENTINEL = 2000000000; void merge(Card *A, int l, int m, int r) { int nl = m - l; int nr = r - m; Card L[MAXNUM / 2 + 2]; Card R[MAXNUM / 2 + 2]; for (int i = 0; i < nl; i++) { L[i] = A[l + i]; ...
#include <iostream> struct Card { char suit; int value; }; constexpr int MAXNUM = 100000; constexpr int SENTINEL = 2000000000; void merge(Card *A, int l, int m, int r) { int nl = m - l; int nr = r - m; Card L[MAXNUM / 2 + 2]; Card R[MAXNUM / 2 + 2]; for (int i = 0; i < nl; i++) { L[i] = A[l + i]; ...
[["-", 31, 16, 31, 16, 12, 118, 28, 69, 28, 22], ["+", 31, 16, 31, 16, 12, 118, 28, 69, 28, 22], ["-", 0, 16, 31, 16, 12, 118, 28, 69, 28, 22], ["+", 0, 16, 31, 16, 12, 118, 28, 69, 28, 22]]
1
680
4
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define SENTINEL 1000000001 #define min...
#include <algorithm> #include <array> #include <cstdio> #include <iostream> #include <list> #include <numeric> #include <queue> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define _USE_MATH_DEFINES #include <map> #include <math.h> #define SENTINEL 1000000001 #define min...
[["+", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46], ["-", 0, 57, 64, 9, 0, 57, 64, 9, 0, 46]]
1
546
2
#include <bits/stdc++.h> using namespace std; #define r(i, n) for (auto i = 0; i < n; i++) #define s(c) static_cast<int>((c).size()) typedef struct { char suit; int num; } Card; void merge(Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j, k; Card L[n1 + 1], R[n...
#include <bits/stdc++.h> using namespace std; #define r(i, n) for (auto i = 0; i < n; i++) #define s(c) static_cast<int>((c).size()) typedef struct { char suit; int num; } Card; void merge(Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j, k; Card L[n1 + 1], R[n...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
613
2
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <utility> #include <vector> using namespace std; struct Card { char suit, rank; }; bool comp(Card a, Card b) { return a.rank < b.rank; } int partition(Card A[], int p, int r) { int x = A[r].rank; int i = p - 1; for (int j ...
#include <algorithm> #include <iostream> #include <math.h> #include <stdio.h> #include <utility> #include <vector> using namespace std; struct Card { char suit; int rank; }; bool comp(Card a, Card b) { return a.rank < b.rank; } int partition(Card A[], int p, int r) { int x = A[r].rank; int i = p - 1; for (...
[["-", 0, 30, 0, 122, 8, 123, 0, 124, 0, 21], ["+", 0, 30, 0, 122, 8, 123, 0, 124, 0, 35], ["+", 0, 30, 0, 122, 8, 123, 0, 124, 39, 40], ["-", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6], ["+", 0, 1, 0, 2, 3, 4, 0, 5, 0, 6]]
1
406
5
#include <cstring> #include <iostream> #include <utility> using namespace std; #define M 1000000000 int mycount = 0; struct card { char mark; int num; }; void merge(card *A, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j; card L[n1 + 1], R[n2 + 1]; for (i = 0; i <...
#include <cstring> #include <iostream> #include <utility> using namespace std; #define M 1000000000 int mycount = 0; struct card { char mark; int num; }; void merge(card *A, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j; card L[n1 + 1], R[n2 + 1]; for (i = 0; i <...
[["-", 0, 1, 0, 11, 12, 118, 28, 69, 28, 22], ["+", 0, 1, 0, 11, 12, 118, 28, 69, 28, 22]]
1
661
2
#include <algorithm> #include <iostream> #include <vector> struct Card { char suit; int num; bool operator==(const Card &other) { return suit == other.suit && num == other.num; } bool operator!=(const Card &other) { return !operator==(other); } }; std::istream &operator>>(std::istream &is, Card &value...
#include <algorithm> #include <iostream> #include <vector> struct Card { char suit; int num; bool operator==(const Card &other) { return suit == other.suit && num == other.num; } bool operator!=(const Card &other) { return !operator==(other); } }; std::istream &operator>>(std::istream &is, Card &valu...
[["-", 0, 218, 8, 9, 0, 37, 0, 16, 17, 47], ["+", 0, 218, 8, 9, 0, 37, 0, 16, 17, 18]]
1
507
2
#include <bits/stdc++.h> using namespace std; int n; pair<char, int> A[100000]; map<int, vector<char>> m; int partition(int p, int r) { int x = A[r].second; int i = p - 1; for (int j = p; j < r; j++) { if (A[j].second <= x) { i = i + 1; swap(A[i], A[j]); } } swap(A[i + 1], A[r]); return ...
#include <bits/stdc++.h> using namespace std; int n; pair<char, int> A[100000]; map<int, vector<char>> m; int partition(int p, int r) { int x = A[r].second; int i = p - 1; for (int j = p; j < r; j++) { if (A[j].second <= x) { i = i + 1; swap(A[i], A[j]); } } swap(A[i + 1], A[r]); return ...
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
391
2
#include <climits> #include <cstdio> #include <cstdlib> #include <cstring> void merge(int *A, char *S, int left, int mid, int right) { int i, j; int n1 = mid - left; int n2 = right - mid; int L[n1 + 1]; int R[n2 + 1]; char Ls[n1 + 1]; char Rs[n2 + 1]; for (i = 0; i < n1; i++) L[i] = A[left + i]; ...
#include <climits> #include <cstdio> #include <cstdlib> #include <cstring> void merge(int *A, char *S, int left, int mid, int right) { int i, j; int n1 = mid - left; int n2 = right - mid; int L[n1 + 1]; int R[n2 + 1]; char Ls[n1 + 1]; char Rs[n2 + 1]; for (i = 0; i < n1; i++) L[i] = A[left + i]; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22], ["+", 0, 1, 0, 2, 3, 4, 0, 69, 28, 22]]
1
850
4
#include <algorithm> #include <iostream> using namespace std; struct Card { char a; int b; }; bool compare_as_ints(Card i, Card j) { return (i.b < j.b); } int partition(Card A[], int p, int r) { Card x = A[r]; int i = p - 1; for (int j = p; j <= r - 1; j++) { if (A[j].b <= x.b) { i++; swap(...
#include <algorithm> #include <iostream> using namespace std; struct Card { char a; int b; }; bool compare_as_ints(Card i, Card j) { return (i.b < j.b); } int partition(Card A[], int p, int r) { Card x = A[r]; int i = p - 1; for (int j = p; j <= r - 1; j++) { if (A[j].b <= x.b) { i++; swap(...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
418
2
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> #define ll long long #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) ...
#define _CRT_SECURE_NO_WARNINGS #include <algorithm> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <queue> #include <set> #include <string> #include <vector> #define ll long long #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
734
2
/* * ALDS1_6_C.cpp * * Created on: Apr 30, 2018 * Author: 13743 */ #include <algorithm> #include <iostream> struct Card { char c; int x; }; void merge(Card *A, int l, int mid, int r) { int n1 = mid - l; int n2 = r - mid; Card L[n1 + 1]; Card R[n2 + 1]; for (int i = 0; i < n1; i++) { L[i]...
/* * ALDS1_6_C.cpp * * Created on: Apr 30, 2018 * Author: 13743 */ #include <algorithm> #include <iostream> struct Card { char c; int x; }; void merge(Card *A, int l, int mid, int r) { int n1 = mid - l; int n2 = r - mid; Card L[n1 + 1]; Card R[n2 + 1]; for (int i = 0; i < n1; i++) { L[i]...
[["-", 31, 16, 31, 16, 12, 118, 28, 69, 28, 22], ["+", 31, 16, 31, 16, 12, 118, 28, 69, 28, 22], ["-", 0, 16, 31, 16, 12, 118, 28, 69, 28, 22], ["+", 0, 16, 31, 16, 12, 118, 28, 69, 28, 22]]
1
643
4
#include <algorithm> #include <iostream> using namespace std; struct Gard { char a; int b; }; bool compare_as_ints(Gard i, Gard j) { return (i.b < j.b); } int partition(Gard A[], int p, int r) { Gard x = A[r]; int i = p - 1; for (int j = p; j <= r - 1; j++) { if (A[j].b <= x.b) { i++; swap...
#include <algorithm> #include <iostream> using namespace std; struct Gard { char a; int b; }; bool compare_as_ints(Gard i, Gard j) { return (i.b < j.b); } int partition(Gard A[], int p, int r) { Gard x = A[r]; int i = p - 1; for (int j = p; j <= r - 1; j++) { if (A[j].b <= x.b) { i++; swap...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
408
2
#include <algorithm> #include <iostream> using namespace std; struct Card { char c; int a; }; bool compare(Card i, Card j) { return (i.a < j.a); } int partition(Card *A, int p, int r) { Card x = A[r]; int i = p - 1; for (int j = p; j <= r - 1; j++) { if (A[j].a <= x.a) { i++; swap(A[i], A[...
#include <algorithm> #include <iostream> using namespace std; struct Card { char c; int a; }; bool compare(Card i, Card j) { return (i.a < j.a); } int partition(Card *A, int p, int r) { Card x = A[r]; int i = p - 1; for (int j = p; j <= r - 1; j++) { if (A[j].a <= x.a) { i++; swap(A[i], A[...
[["-", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 0, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
399
2
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; #define infinity 2000000000 struct node { char pat; int num; }; node A[100010], B[100010]; node L[50010], R[50010]; int n; void merge(int left, int mid, int right) { int n1 = mid - left, n2 = right - mid; for (int i = 0; i < n1; i...
#include <algorithm> #include <cstdio> #include <iostream> using namespace std; #define infinity 2000000000 struct node { char pat; int num; }; node A[100010], B[100010]; node L[50010], R[50010]; int n; void merge(int left, int mid, int right) { int n1 = mid - left, n2 = right - mid; for (int i = 0; i < n1; i...
[["-", 0, 1, 0, 11, 31, 118, 28, 69, 28, 22], ["+", 0, 1, 0, 11, 31, 118, 28, 69, 28, 22], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 45], ["+", 0, 7, 8, 9, 0, 57, 64, 9, 0, 46]]
1
604
4
#include <iostream> using namespace std; #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n1; i++) { ...
#include <iostream> using namespace std; #define MAX 100000 #define SENTINEL 2000000000 struct Card { char suit; int value; }; struct Card L[MAX / 2 + 2], R[MAX / 2 + 2]; void merge(struct Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; for (int i = 0; i < n1; i++) { ...
[["-", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22], ["+", 8, 9, 0, 1, 0, 2, 3, 4, 0, 22]]
1
642
2
#include <iostream> using namespace std; struct Card { char c; int n; }; bool IsStable(Card A1[], Card A2[], int n) { for (int i = 0; i < n; i++) if (A1[i].c != A2[i].c) return false; return true; } void Marge(Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; ...
#include <iostream> using namespace std; struct Card { char c; int n; }; bool IsStable(Card A1[], Card A2[], int n) { for (int i = 0; i < n; i++) if (A1[i].c != A2[i].c) return false; return true; } void Marge(Card A[], int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; ...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
679
2
#include <algorithm> #include <iostream> using namespace std; #define INFTY 1000000001 typedef struct card { char mark; int num; } card; //安定で高速 void merge(card *A, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j; card L[n1 + 10], R[n2 + 10]; for (i = 0; i < n1; i+...
#include <algorithm> #include <iostream> using namespace std; #define INFTY 1000000001 typedef struct card { char mark; int num; } card; //安定で高速 void merge(card *A, int left, int mid, int right) { int n1 = mid - left; int n2 = right - mid; int i, j; card L[n1 + 10], R[n2 + 10]; for (i = 0; i < n1; i+...
[["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
650
2
#include <iostream> using namespace std; #define N 100001 #define SENTINEL 999999998 // Merge function void Merge(int a[], char c[], int left, int mid, int right) { int n1, n2, i, j; int L[N], R[N]; char Lc[N], Rc[N]; n1 = mid - left; n2 = right - mid; for (i = 0; i < n1; i++) { L[i] = a[left + i]...
#include <iostream> using namespace std; #define N 100001 #define SENTINEL 999999998 // Merge function void Merge(int a[], char c[], int left, int mid, int right) { int n1, n2, i, j; int L[N], R[N]; char Lc[N], Rc[N]; n1 = mid - left; n2 = right - mid; for (i = 0; i < n1; i++) { L[i] = a[left + i]...
[["-", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22]]
1
806
2
#include <iostream> using namespace std; #define N 100001 #define SENTINEL 999999998 // Merge function void Merge(int a[], char c[], int left, int mid, int right) { int n1, n2, i, j; int L[N], R[N]; char Lc[N], Rc[N]; n1 = mid - left; n2 = right - mid; for (i = 0; i < n1; i++) { L[i] = a[left + i]...
#include <iostream> using namespace std; #define N 100001 // SENTINEL is too big number #define SENTINEL 999999998 // Merge function void Merge(int a[], char c[], int left, int mid, int right) { int n1, n2, i, j; int L[N], R[N]; char Lc[N], Rc[N]; n1 = mid - left; n2 = right - mid; for (i = 0; i < n1;...
[["-", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22], ["+", 64, 9, 0, 1, 0, 11, 12, 69, 28, 22]]
1
806
2
#include <algorithm> #include <iostream> #include <vector> using namespace std; int Partition(vector<pair<char, int>> &A, int p, int r) { int x = A[r - 1].second; int i = p - 1; for (int j = p; j < r - 1; ++j) { if (A[j].second <= x) { ++i; swap(A[i], A[j]); } } swap(A[i + 1], A[r - 1]);...
#include <algorithm> #include <iostream> #include <vector> using namespace std; int Partition(vector<pair<char, int>> &A, int p, int r) { int x = A[r - 1].second; int i = p - 1; for (int j = p; j < r - 1; ++j) { if (A[j].second <= x) { ++i; swap(A[i], A[j]); } } swap(A[i + 1], A[r - 1]);...
[["-", 0, 57, 15, 339, 51, 16, 12, 16, 17, 33], ["-", 0, 57, 15, 339, 51, 16, 12, 16, 12, 13], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13]]
1
384
4
#include <iostream> #include <vector> using namespace std; struct card { char suit; int num; }; int partition_out(vector<card> &A, int q) { int n = A.size(); for (int i = 0; i < n; i++) { cout << A[i].suit << " " << A[i].num << endl; } return 0; } int partition(vector<card> &A, int p, int r) { int ...
#include <iostream> #include <vector> using namespace std; struct card { char suit; int num; }; int card_out(vector<card> &A, int q) { int n = A.size(); for (int i = 0; i < n; i++) { cout << A[i].suit << " " << A[i].num << endl; } return 0; } int partition(vector<card> &A, int p, int r) { int x = A...
[["-", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["+", 36, 36, 0, 30, 0, 14, 49, 53, 49, 22], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 17, 33], ["-", 0, 1, 0, 2, 3, 4, 0, 16, 12, 13], ["-", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22], ["+", 0, 14, 8, 9, 0, 1, 0, 2, 63, 22]]
1
740
6
/* ソートが安定(stable)かどうか確かめる 手続きを入れるより、 nがそこまで大きくないので 安定であると周知のソートアルゴリズムを使って ソートしたのと比較して一致するか見る。 */ /* 「pivotを中間に、大きいものと小さいものを交換していく」 という感じではなく、 「pivotより小さいものを探して、前の方に詰めていく(添え字iのとこ)」 という感じである。 */ #include <algorithm> #include <iostream> #include <vector> using namespace std; //カード記録用の構造体 // typedef struct CARD_TEMP ...
/* ソートが安定(stable)かどうか確かめる 手続きを入れるより、 nがそこまで大きくないので 安定であると周知のソートアルゴリズムを使って ソートしたのと比較して一致するか見る。 */ /* 「pivotを中間に、大きいものと小さいものを交換していく」 という感じではなく、 「pivotより小さいものを探して、前の方に詰めていく(添え字iのとこ)」 という感じである。 */ #include <algorithm> #include <iostream> #include <vector> using namespace std; //カード記録用の構造体 // typedef struct CARD_TEMP ...
[["-", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6], ["+", 64, 1, 0, 16, 31, 16, 12, 5, 0, 6]]
1
420
2
#include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cctype> // require tolower, toupper #include <cfloat> #include <climits> #include <cmath> // require fabs #include <cstdio> // require scanf printf #include <cstdlib> // require abs exit atof atoi #include <cstring> // requir...
#include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cctype> // require tolower, toupper #include <cfloat> #include <climits> #include <cmath> // require fabs #include <cstdio> // require scanf printf #include <cstdlib> // require abs exit atof atoi #include <cstring> // requir...
[["-", 31, 16, 31, 16, 31, 16, 12, 69, 28, 22], ["+", 31, 16, 31, 16, 31, 16, 12, 69, 28, 22], ["-", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22], ["+", 0, 1, 0, 16, 31, 16, 12, 69, 28, 22]]
1
607
4
def partition(arr, p, r) x = arr[r] i = p - 1 for j in p...r if arr[j] <= x i += 1 arr[i], arr[j] = arr[j], arr[i] end end arr[i + 1], arr[r] = arr[r], arr[i + 1] return i + 1 end n = gets.to_i arr = gets.split.map(&:to_i) index = partition(arr, 0, n - 1) for i in 0...index print arr[...
def partition(arr, p, r) x = arr[r] i = p - 1 for j in p...r if arr[j] <= x i += 1 arr[i], arr[j] = arr[j], arr[i] end end arr[i + 1], arr[r] = arr[r], arr[i + 1] return i + 1 end n = gets.to_i arr = gets.split.map(&:to_i) index = partition(arr, 0, n - 1) for i in 0...index print arr[...
[["+", 0, 88, 51, 267, 0, 475, 756, 738, 17, 72], ["+", 0, 88, 51, 267, 0, 475, 756, 738, 12, 612], ["+", 36, 36, 36, 36, 0, 493, 0, 652, 735, 22], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 62], ["+", 0, 493, 0, 652, 3, 4, 0, 557, 0, 44]]
4
164
6
def partition(a, p, r) x = a[r] i = p - 1 for j in p..r if a[j] <= x i += 1 a[j],a[i] = a[i],a[j] end a[r],a[i+1] = a[i+1],a[r] end return i + 1 end n = gets.to_i a = gets.split(" ").map(&:to_i) i = partition(a,0,n-1) puts a[0,i-1].join(" ") + " [" + a[i].to_s + "] " + a[i+1,n-i-1].join(" ")
def partition(a, p, r) x = a[r] i = p - 1 for j in p..r-1 if a[j] <= x i += 1 a[j],a[i] = a[i],a[j] end end a[r],a[i+1] = a[i+1],a[r] return i+1 end n = gets.to_i a = gets.split(" ").map(&:to_i) i = partition(a,0,n-1) puts a[0,i].join(" ") + " [" + a[i].to_s + "] " + a[i+1,n-i-1].join(" ")
[["+", 0, 88, 51, 267, 0, 475, 444, 738, 17, 33], ["+", 0, 88, 51, 267, 0, 475, 444, 738, 12, 612], ["+", 8, 736, 0, 88, 8, 170, 0, 121, 0, 444], ["-", 0, 735, 8, 736, 0, 88, 8, 170, 0, 444], ["-", 31, 738, 31, 652, 486, 742, 0, 738, 17, 33], ["-", 31, 738, 31, 652, 486, 742, 0, 738, 12, 612]]
4
169
6
def partition(a) x = a.last r = a.size i = 0 i.upto(r - 1) do |j| if a[j] <= x a[i], a[j] = a[j], a[i] i += 1 end p a end a[0..i-2].join(' ') + " [#{a[i-1]}] " + a[i..-1].join(' ') end n = gets.to_i a = gets.chomp.split.map(&:to_i) puts partition(a)
def partition(a) x = a.last r = a.size i = 0 i.upto(r - 1) do |j| if a[j] <= x a[i], a[j] = a[j], a[i] i += 1 end end a[0..i-2].join(' ') + " [#{a[i-1]}] " + a[i..-1].join(' ') end n = gets.to_i a = gets.chomp.split.map(&:to_i) puts partition(a)
[["-", 0, 652, 196, 737, 8, 736, 0, 652, 735, 22], ["-", 196, 737, 8, 736, 0, 652, 3, 4, 0, 22]]
4
130
2
def partition(a, p, r): x = a[r] i = p - 1 for j in range(r): if a[j] < x: i += 1 swap(a, i, j) swap(a, i + 1, r) return i + 1 def swap(a, i, j): tmp = a[i] a[i] = a[j] a[j] = tmp n = int(input()) a = list(map(int, input().split())) idx = partition(a, 0, len(a) - 1) if idx == 0: print('[' + str(a[0]...
def partition(a, p, r): x = a[r] i = p - 1 for j in range(p, r): if a[j] <= x: i += 1 swap(a, i, j) swap(a, i + 1, r) return i + 1 def swap(a, i, j): tmp = a[i] a[i] = a[j] a[j] = tmp n = int(input()) a = list(map(int, input().split())) idx = partition(a, 0, len(a) - 1) if idx == 0: print('[' + str...
[["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 22], ["+", 8, 196, 0, 7, 12, 652, 3, 4, 0, 21], ["-", 0, 7, 8, 196, 0, 57, 15, 666, 667, 18], ["+", 0, 7, 8, 196, 0, 57, 15, 666, 667, 19]]
5
241
4
n = int(input()) a = list(map(int, input().split())) s = 0 last = a[-1] for i in range(n-1): if a[i] <= last: tmp = a[i] a[i] = a[s] a[s] = tmp s += 1 tmp = a[-1] a[-1] = a[s] a[s] = tmp for i in range(1, s): print(a[i], end=' ') print('[' + str(a[s]) + '] ', end='') for i in ...
n = int(input()) a = list(map(int, input().split())) s = 0 last = a[-1] for i in range(n-1): if a[i] <= last: tmp = a[i] a[i] = a[s] a[s] = tmp s += 1 tmp = a[-1] a[-1] = a[s] a[s] = tmp for i in range(0, s): print(a[i], end=' ') print('[' + str(a[s]) + '] ', end='') for i in ...
[["-", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612], ["+", 0, 656, 0, 7, 12, 652, 3, 4, 0, 612]]
5
182
2
def partition(A, p, r): x = A[r] i = p-1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i + 1], A[r] = A[r], A[i + 1] return i + 1 input() A = list(map(int, input().split())) index = partition(A, 0, A[len(A) - 1]) for i in range(len(A)): if ...
def partition(A, p, r): x = A[r] i = p-1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i + 1], A[r] = A[r], A[i + 1] return i + 1 input() A = list(map(int, input().split())) index = partition(A, 0, len(A) - 1) for i in range(len(A)): if i =...
[["-", 0, 662, 12, 652, 3, 4, 0, 206, 51, 22], ["-", 0, 662, 12, 652, 3, 4, 0, 206, 0, 70], ["-", 0, 662, 12, 652, 3, 4, 0, 206, 0, 73]]
5
183
3
def partition(A, p, r): x = A[r] i = p - 1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i + 1], A[r] = A[r], A[i + 1] return i + 1 n = int(input()) A = list(map(int, input().split())) q =partition(A, 1, len(A) - 1) print(*A[:q], end = ' '...
def partition(A, p, r): x = A[r] i = p - 1 for j in range(p, r): if A[j] <= x: i += 1 A[i], A[j] = A[j], A[i] A[i + 1], A[r] = A[r], A[i + 1] return i + 1 n = int(input()) A = list(map(int, input().split())) q =partition(A, 0, len(A) - 1) print(*A[:q], end = ' '...
[["-", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612], ["+", 0, 1, 0, 662, 12, 652, 3, 4, 0, 612]]
5
174
2