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 <assert.h> | |
#include <stdlib.h> | |
#define MAX(A, B) ((A)>(B)?(A):(B)) | |
static void print_paren(int n); | |
static void do_print(int n, int* idx, int k); | |
static void print_result(int n, int* idx); |
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<stdlib.h> | |
#include<assert.h> | |
static void swap(int* data, int c) { | |
for (int i=0; c > 0; i+=2, --c) { | |
int tmp = data[i]; | |
data[i] = data[i+1]; | |
data[i+1] = tmp; | |
} |
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 java.util.*; | |
public class LowerBound { | |
private LowerBound() {} | |
final static class Node { | |
Node left, right; | |
final int val; | |
public Node(int val) { |
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 final class Zigzag { | |
private Zigzag() {} | |
/** | |
* given an array of integer, returns the maximun length of zig-zag | |
* subsequence | |
*/ | |
public static int zigzagSequence(int[] arr) { | |
if (arr.length < 2) { |
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<stdlib.h> | |
#include<assert.h> | |
#include<stdbool.h> | |
#define DUP (-1) | |
#define INVALID (-2) | |
static int comp(int a, int b, int c, int d) { | |
if (a == c) { |
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 java.util.*; | |
/** | |
* SRM 181 Div 1 - 3rd | |
*/ | |
public class KiloManX { | |
public static int leastShots(String[] damageChart, int[] bossHealth) { | |
final int size = bossHealth.length; | |
final int rows = 1 << 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
import java.util.*; | |
public final class Escape { | |
private static final int size = 501; | |
private static final int NotSeen = -1; | |
private enum Type { | |
Normal, Harmful, Deadly | |
} |
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 java.util.*; | |
public final class PathFinding { | |
static final class State { | |
final int ax, ay, bx, by; | |
final int hash; | |
State(int ax, int ay, int bx, int by) { | |
this.ax = ax; |
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 java.util.*; | |
public final class Circuits { | |
public static int howLong(String[] connects, String[] costs) { | |
final int size = connects.length; | |
final int[][] m = new int[size][size]; | |
for (int i=0; i<size; ++i) { | |
String c = connects[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 <stdio.h> | |
struct padded { | |
short s; | |
int i; | |
}; | |
int main(int argc, char **argv) { | |
// this should give in memory (8 bytes): | |
// 0xffff1234, 0x00005678 |
OlderNewer