This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ORD0 = ord('0') - 1 | |
def num_to_bs(num): | |
bs = 0 | |
for i in str(num): | |
s = 1 << ((ord(i) - ORD0) * 4) | |
l = bs & s | |
bs += (s >> 4) | |
if l != (bs & s): raise RuntimeError | |
return bs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
using namespace std; | |
struct LLNode { | |
int frame_id; | |
int meta; | |
LLNode* next; | |
LLNode(int fid) : frame_id(fid), meta(0) {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<vector> | |
int main() { | |
int cap, n; | |
std::cin >> cap >> n; | |
std::vector<int> w(n, 0), c(n, 0); | |
for (int &i : w) std::cin >> i; | |
for (int &i : c) std::cin >> i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<vector> | |
#include<climits> | |
#include<string> | |
// MCM | |
std::string make_exp(std::vector<std::vector<int>> &s, int i, int j) { | |
if (i == j) { | |
return std::string(1, 'A' + i - 1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
void merge(std::vector<int> &a, int l, int mid, int r) { | |
int p1 = l; | |
int p2 = mid + 1; | |
std::vector<int> ret(r - l + 1); | |
int i = 0; | |
while (p1 <= mid && p2 <= r) ret[i++] = a[p1] < a[p2] ? a[p1++] : a[p2++]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
void insertion_sort(std::vector<int> &a) { | |
for (int i = 1; i < a.size(); i++) { | |
int b = a[i]; | |
int j = i - 1; | |
for (; j >= 0 && b < a[j]; j--) { | |
a[j + 1] = a[j]; | |
} | |
a[j + 1] = b; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<bits/stdc++.h> | |
int argmin(std::vector<int> &a, int from) { | |
int m = a.at(from); | |
int mi = from; | |
for (int i = from; i < a.size(); i++) if (a[i] < m) { m = a[i]; mi = i; } | |
return mi; | |
} | |
void bubble_sort(std::vector<int> &a) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include"stdio.h" | |
#include"string.h" | |
size_t bisect(char **a, int len, char *elem) { | |
size_t hi = len - 1; | |
size_t lo = 0; | |
size_t mid; | |
while (1) { | |
mid = (hi + lo) >> 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include"stdio.h" | |
void iota(int *arr, int len) { | |
for (int i = 0; i < len; i++) { | |
arr[i] = i; | |
} | |
} | |
int main() { | |
int a[4][4]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include"stdlib.h" | |
#include"stddef.h" | |
#include"stdio.h" | |
typedef struct { | |
int *arr; | |
size_t len; | |
} Array; | |
Array iota(size_t len) { |
NewerOlder