This file contains hidden or 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
| // from https://github.com/spakin/disjoint | |
| class disjoint_set { | |
| private: | |
| typedef struct { | |
| int rank; | |
| int parent; | |
| } element; | |
| vector<element> set_list; | |
| public: | |
| explicit disjoint_set(int size) { |
This file contains hidden or 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
| import re | |
| import json | |
| fixset = {} | |
| # Get this file from http://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt | |
| with open('UnicodeData.txt', 'r') as data: | |
| for line in data: | |
| lineData = line.split(';') | |
| if lineData[5] != '': | |
| g = re.search(r'^<.+> (.+)$', lineData[5]) | |
| if g is not None and g.group(1) is not None: |
This file contains hidden or 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 <unordered_set> | |
| #include <vector> | |
| using namespace std; | |
| class graph { | |
| private: | |
| typedef struct { | |
| int to; |
This file contains hidden or 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
| class bit_set { | |
| private: | |
| uint8_t *data; | |
| public: | |
| explicit bit_set(int size) { | |
| // (size + 7) / 8 is ceiling of size / 8 | |
| data = new uint8_t[(size + 7) / 8](); | |
| } | |
| void set(int index) { |
This file contains hidden or 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
| # Simple FFMPEG scripts I use to convert videos or audios | |
| # The ones with h264_nvenc codec only work with NVidia graphic cards. You also need to install the drives to use them | |
| # The hevc_nvenc codec is pretty fast but the output file size is terrible. So I won't include that in. (Special thanks to Erfan Mojibi) | |
| # The libx265 provides better quality to file size. So we can increase the crf in it (source: https://trac.ffmpeg.org/wiki/Encode/H.265#ConstantRateFactorCRF) | |
| # The tag is provided by @alirezahabib | |
| # Simple convert from webm to mp4. ACC audio codec at 128kb/s. Change 24 to change the quality (higher is worse) | |
| ffmpeg -i in.webm -r 10 -vf "scale=-2:720" -c:v h264_nvenc -cq:v 24 -profile:v high -c:a aac -b:a 128k -strict experimental out.mp4 | |
| ffmpeg -i in.webm -r 10 -vf "scale=-2:720" -c:v libx264 -crf 24 -c:a aac -b:a 128k -strict experimental out.mp4 | |
| ffmpeg -i in.webm -r 10 -vf "scale=-2:720" -c:v libx265 -crf 28 -c:a aac -b:a 128k -tag:v hvc1 -strict experimental out.mp4 |
This file contains hidden or 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
| package util | |
| import ( | |
| "encoding/csv" | |
| "fmt" | |
| "io" | |
| "reflect" | |
| ) | |
| // StreamCsv converts an array of an struct to csv |
This file contains hidden or 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
| use std::net::{TcpStream}; | |
| use std::io::{Write, BufReader, BufRead}; | |
| /// Connects to api.ipify.org and returns your IP address | |
| /// Note that this method does not use any proxies | |
| fn get_ip() -> Result<String, String> { | |
| // at first, try to to connect to ipify | |
| match TcpStream::connect("api.ipify.org:80") { | |
| Ok(mut stream) => { | |
| // create the request header; This is a const value |
This file contains hidden or 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
| #!/bin/bash | |
| # A simple script to generate C testcases based on inputs for Quera | |
| # Place your input files in a folder called "raw-input" with the format of *.txt | |
| # Then run the program with the code filename as the argument and then this script will generate | |
| # the answers based on your program | |
| # Compile the program | |
| gcc -O3 -o program "$1" -lm # I include the math library as well | |
| # Create the output folders if needed | |
| mkdir -p "in" "out" | |
| # Loop all test cases |
This file contains hidden or 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
| /** | |
| Maze example: | |
| 1e11111111111 | |
| 1*0*0*0*0*0*1 | |
| 1110111111101 | |
| 1*1*0*1*0*1*1 | |
| 1011111010101 | |
| 1*0*0*0*1*0*1 | |
| 11111111111e1 | |
| */ |
This file contains hidden or 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
| @echo off | |
| setlocal EnableDelayedExpansion | |
| javac %1 | |
| set /A Counter=1 | |
| set ClassName=%1 | |
| set ClassName=%ClassName:~0,-5% | |
| :loop | |
| set "i=in%Counter%.txt" | |
| set "o=out%Counter%.txt" |