Skip to content

Instantly share code, notes, and snippets.

@evandrix
Created January 25, 2012 03:01
Show Gist options
  • Save evandrix/1674383 to your computer and use it in GitHub Desktop.
Save evandrix/1674383 to your computer and use it in GitHub Desktop.
Competitive Programming links
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fcntl.h>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unistd.h>
#include <utility>
#include <vector>
using namespace std;
#define s(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define sf(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define INF (1<<30)
#define LINF (long long) 1e18
#define EPS 1e-9
#define ABS(x) ((x)<0?-(x):(x))
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(a)-1,_b(b); i>=_b; --i)
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define mp make_pair
#define tri(a,b,c) mp(a,mp(b,c))
#define fst first
#define snd second
#define YY second.first
#define ZZ second.second
#define pb push_back
#define fill(a,v) memset(a,v,sizeof a)
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define sqr(a) ((a)*(a))
#define all(x) x.begin(),x.end()
#define SZ(v) ((int)(v.size()))
#define DREP(a) sort(all(a)); a.erase(unique(all(a)),a.end())
#define INDEX(arr,ind) (lower_bound(all(arr),ind)-arr.begin())
#define LOG(a) (cerr<<__LINE__<<": "#a" = "<<(a)<<endl)
#define DBG(...) (__VA_ARGS__)
#define debug(args...) {dbg,args; cerr<<endl;}
#define dline cerr<<endl
struct debugger
{
template<typename T> debugger& operator , (const T& v)
{
cerr<<v<<" ";
return *this;
}
} dbg;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<int,PII> TRI;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<PLL> VLL;
typedef vector<TRI> VT;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VII> VVII;
typedef vector<VLL> VVLL;
typedef vector<VT> VVT;
typedef complex<double> pt;
typedef complex<LL> pti;
const double PI = 3.1415926535897932384626433832795;
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
// pre-compute
void pre(void) {
}
void main2(int t) {
int ans = 0;
#ifdef DEBUG
debug(t, ": result", ans);
#endif
printf("%d\n", 0);
}
///////////////////////////// multiple testcases /////////////////////////////
int main(void) {
clock_t start = clock();
FILE *fin, *fout;
int T, t;
fin = fopen("/Users/lwy08/Downloads/A.in", "r");
fout = fopen("/Users/lwy08/Downloads/fb.out", "w");
pre();
fscanf(fin, "%d\n", &T);
REP(t,T) {
printf("Case #%d: ", t + 1);
fprintf(fout, "Case #%d: ", t + 1);
main2(t + 1);
}
fclose(fin);
fclose(fout);
fin = NULL;
fout = NULL;
fprintf(stderr, "*** Total time: %.3lf seconds ***\n",
((clock() - start) / (double) CLOCKS_PER_SEC));
return 0;
}
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static utilities.Constants.*;
import static utilities.IOUtils.*;
import java.io.*;
import java.util.*;
public class A
{
private static String PROBLEM_NAME = "/Users/lwy08/Downloads/A"; // .in
private static void run()
throws Exception
{
/* INPUT */
cases = INT();
for (cc = 1; cc <= cases; cc++) {
// for each case - read input
println(cc, String.format("%s", solve()));
} // end for each case
} // end run()
private static double solve()
throws IOException
{
return 0;
}
public static void main(String[] args)
throws Exception
{
Locale.setDefault(Locale.US);
init(PROBLEM_NAME);
run();
close();
}
}
import sys
import time
import math
if __name__ == "__main__":
t0 = time.time()
_i = open("/Users/lwy08/Downloads/A.in", "r")
_o = open("/Users/lwy08/Downloads/fb.out", "w")
T = int(_i.readline())
for _t in xrange(T):
line = _i.readline().split()
result = "Case #%d: %d" % (_t + 1, 0)
print result
print >> _o, result
_i.close()
_o.close()
print >> sys.stderr, "*** Total time: %.3f seconds ***" % (time.time() - t0)
for x in xrange(10):
for y in xrange(10):
for z in xrange(10):
print x,y,z
if x*y*z == 30:
break
else:
continue
break
else:
continue
break
# or
from itertools import product
for x, y in product(range(10), range(10)):
if x * y > 30:
break
http://codeforces.com/blog/entry/325
http://manavar.blogspot.com/search/label/Dynamic%20Programming
http://community.topcoder.com/stat?c=problem_statement&pm=6551&rd=9990
http://notes.tweakblogs.net/blog/7524/facebook-hacker-cup-qualification-round-problem-analysis.html
http://translate.google.com/translate?hl=en&sl=&tl=en&u=http%3A%2F%2Fcodeforces.ru%2Fblog%2Fentry%2F3762
C++ STL @ http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html
== UVA ==
UVA @ http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=9
Algorithmist DP @ http://www.algorithmist.com/index.php/Category:Dynamic_Programming
UVA toolkit @ http://uvatoolkit.com/problemssolve.php
Quest to Solve @ http://www.questtosolve.com/browse.php