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
# Maintainer: Thorsten Wißmann <edu@thorsten-wissmann.de> | |
pkgname=kattis-problemtools | |
pkgver=v1.20201230 | |
pkgrel=1 | |
pkgdesc="Tools to manage problem packages using the Kattis problem package format" | |
arch=('i686' 'arm' 'x86_64') | |
url="https://github.com/Kattis/problemtools" | |
license=('MIT') | |
depends=('python' 'gmp' 'java-environment' 'plastex' 'python-yaml') | |
makedepends=('python-setuptools' 'boost') |
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
// Say you have an integer array of length n. Then this monstrosity sorts it, slowly. | |
void cursed_sort(int* a, int n) { | |
int*q,i; | |
for(i=0;i<n;++i) | |
for(q=a;q+1<a+n;++q) | |
if(*q>*(q+1)) | |
*q^=*(q+1)^=*q^=*(q+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 <iostream> | |
#include <cstring> | |
#define MAX_LETTERS 600005 | |
#define ALPHABET_SIZE 26 | |
using namespace std; | |
// These two structures should be intiialized to all 0 | |
// (0 is the root and should never be the child of another node) | |
int trie[MAX_LETTERS][ALPHABET_SIZE]; |
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
Hello Challenge! |
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
import Data.List.Split | |
valid :: String -> Bool | |
valid "" = False | |
valid s = not $ foldr (\a b -> b || a `elem` ["::", "import", "->", "module" ]) False $ words s | |
count :: String -> Int | |
count s = if valid s then length . concat $ words s else 0 | |
main = do |
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
public class Trie { | |
final static int ALPHABET_SIZE = 26; | |
Trie[] children; | |
public Trie() { | |
this.children = new Trie[ALPHABET_SIZE]; | |
} | |
// return true if the word added is new. | |
public boolean insert(String s) { |
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
import qualified Data.ByteString.Char8 as BS | |
import Data.Char | |
oneString :: String -> Int -> String | |
oneString s n = map (\x -> chr $ (ord x) + n) s | |
allStrings :: String -> [BS.ByteString] | |
allStrings s = map (BS.pack . oneString s) [-65..165] | |
showByteString :: Char -> Char |
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
N = length(perm); | |
do { | |
print(perm); | |
} while (next_permutation(perm, perm + N)); |
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
for (int i = 0; i < N; i++) { | |
dist[i] = INFINITY; | |
} | |
dist[start] = 0; | |
for (int k = 0; k < N - 1; k++) { | |
for (int i = 0; i < N; i++) { | |
for (int e = 0; e < adj[i].size(); e++) { | |
int j = adj[i][e].vertex; |
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
// Assume N is the number of vertices | |
for (int k = 0; k < N; k++) { | |
for (int i = 0; i < N; i++) { | |
for (int j = 0; j < N; j++) { | |
dist[i][j] = min(dist[i][j], | |
dist[i][k] + dist[k][j]); | |
} | |
} | |
} |
NewerOlder