[Assorted-commits] SF.net SVN: assorted: [518] configs/trunk
Brought to you by:
yangzhang
|
From: <yan...@us...> - 2008-02-27 04:00:39
|
Revision: 518
http://assorted.svn.sourceforge.net/assorted/?rev=518&view=rev
Author: yangzhang
Date: 2008-02-26 20:00:45 -0800 (Tue, 26 Feb 2008)
Log Message:
-----------
added topcoder stuff
Modified Paths:
--------------
configs/trunk/TODO
Added Paths:
-----------
configs/trunk/src/contestapplet.conf
Modified: configs/trunk/TODO
===================================================================
--- configs/trunk/TODO 2008-02-26 20:49:46 UTC (rev 517)
+++ configs/trunk/TODO 2008-02-27 04:00:45 UTC (rev 518)
@@ -1 +1,2 @@
mv bashrc.bash into here from shell-tools
+deal with topcoder
Added: configs/trunk/src/contestapplet.conf
===================================================================
--- configs/trunk/src/contestapplet.conf (rev 0)
+++ configs/trunk/src/contestapplet.conf 2008-02-27 04:00:45 UTC (rev 518)
@@ -0,0 +1,225 @@
+// vim:noet:sw=2:ts=2
+
+// TODO
+// - strip out all comments
+// - trim the unused includes/macros/typedefs/code
+
+// $BEGINREUSE$
+#include <algorithm>
+#include <cassert>
+#include <cctype>
+#include <cmath>
+#include <cstdio>
+#include <cstdlib>
+#include <deque>
+#include <functional>
+#include <iostream>
+#include <map>
+#include <queue>
+#include <set>
+#include <sstream>
+#include <stack>
+#include <string>
+#include <vector>
+using namespace std;
+
+#define dd(x) cout << #x << " = " << x << endl
+#define len length()
+#define sz size()
+#define pb(x) push_back((x));
+#define all(A) (A).begin(), (A).end()
+#define rall(A) (A).rbegin(), (A).rend()
+#define forea(it,xs) for (typeof(xs.begin()) it = xs.begin(); it != xs.end(); it++)
+#define FOR(i,xs) for (typeof((xs).size()) i = 0; i < (xs).size(); i++)
+#define FOR(i,l,h) for (typeof(l) i = (l); i < (h); i++)
+
+// CHOOSE
+//int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
+//int dx[] = {1,1,1,0,0,-1,-1,-1}, dy[] = {1,0,-1,1,-1,1,0,-1};
+
+typedef vector<int> vi;
+typedef vector<string> vs;
+typedef vector<bool> vb;
+typedef vector<vi> vvi;
+typedef vector<vs> vvs;
+typedef vector<vb> vvb;
+typedef long long ll;
+typedef vector vec; // XXX
+typedef string str;
+
+template<typename T> inline T mod(T a, T b) { return (a % b + b) % b; }
+template<typename T> inline void rev(T xs) { std::reverse(all(xs)); }
+template<typename T> inline void sort(T xs) { std::sort(all(xs)); }
+template<typename T> inline void ssort(T xs) { std::stable_sort(all(xs)); }
+template<typename T> inline void unique(T xs) { std::unique(all(xs)); }
+template<typename T> inline void uniq(T xs) { xs.erase( std::unique(all(xs)), xs.end() ); }
+template<typename T, typename U> inline void fill(T xs, U x) { std::fill(all(xs), x); }
+template<typename T, typename U> inline U minim(const T xs) { return *std::min_element(all(xs)); }
+template<typename T, typename U> inline U maxim(const T xs) { return *std::max_element(all(xs)); }
+template<typename T> inline void nextp(T xs) { return std::next_permutation(all(xs)); }
+template<typename T> inline void prevp(T xs) { return std::prev_permutation(all(xs)); }
+template<typename T> inline string tos(T x) { stringstream s; s << x; return s.str(); }
+inline int powi(int a, int b) { return int( std::pow(double(a), double(b)) ); }
+inline int powl(ll a, ll b) { return ll( std::pow(double(a), double(b)) ); }
+template<typename T> inline void pp(const T & x) { cout << x << endl; }
+
+inline ll gcd(ll a, ll b) {
+ if (a < 0 && b < 0) return gcd(-a,-b);
+ if (a == 0) return b;
+ if (b == 0) return a;
+ if (a > b) return gcd(b, a);
+ if (!(b % a)) return a;
+ return gcd(a, b % a);
+}
+
+// TODO merge the following two pieces of code together
+
+template <typename T>
+inline ostream& operator << (ostream& os, const set<T> & xs) {
+ FOR(i,xs) os << i ? ", " : "{ " << xs[i];
+ return os << " }";
+}
+
+template <typename T>
+inline ostream& operator << (ostream& os, const vector<T> & xs) {
+ FOR(i,xs) os << i ? ", " : "{ " << xs[i];
+ return os << " }";
+}
+
+template<class S,class T>
+inline ostream & operator << (ostream & os, const pair<S,T> & a) {
+ os << "(" << a.first << ", " << a.second << ")";
+ return os;
+}
+
+vs split( const string & s, const string & delim = " " ) {
+ vs res;
+ string t;
+ forea(c,s) {
+ if ( delim.find( c ) != string::npos ) {
+ if ( !t.empty() ) {
+ res.pb( t );
+ t = "";
+ }
+ } else {
+ t += c;
+ }
+ }
+ if ( ! t.empty() ) {
+ res.push_back(t);
+ }
+ return res;
+}
+
+vi ints( const str & s, const str & delim = " " ) {
+ vs ss = split( s, delim );
+ vi is;
+ forea(s,ss) is.push_back( atoi( s.c_str() ) );
+ return is;
+}
+
+// following is needed for 'main'
+#define ARRSIZE(x) (sizeof(x)/sizeof(x[0]))
+// $ENDREUSE$
+
+
+
+
+
+
+
+$BEGINCUT$
+template<typename T> void print( T a ) {
+ cerr << a;
+}
+static void print( long long a ) {
+ cerr << a << "L";
+}
+static void print( string a ) {
+ cerr << '"' << a << '"';
+}
+template<typename T> void print( vector<T> a ) {
+ cerr << "{";
+ for ( int i = 0 ; i != a.size() ; i++ ) {
+ if ( i != 0 ) cerr << ", ";
+ print( a[i] );
+ }
+ cerr << "}" << endl;
+}
+template<typename T> void eq( int n, T have, T need ) {
+ if ( have == need ) {
+ cerr << "Case " << n << " passed." << endl;
+ } else {
+ cerr << "Case " << n << " failed: expected ";
+ print( need );
+ cerr << " received ";
+ print( have );
+ cerr << "." << endl;
+ }
+}
+template<typename T> void eq( int n, vector<T> have, vector<T> need ) {
+ if( have.size() != need.size() ) {
+ cerr << "Case " << n << " failed: returned " << have.size() << " elements; expected " << need.size() << " elements." << endl;
+ cerr << " have: "; print( have );
+ cerr << " need: "; print( need );
+ return;
+ }
+ for( size_t i= 0; i < have.size(); i++ ) {
+ if( have[i] != need[i] ) {
+ cerr << "Case " << n << " failed. Expected and returned array differ in position " << i << "." << endl;
+ cerr << " have: "; print( have );
+ cerr << " need: "; print( need );
+ return;
+ }
+ }
+ cerr << "Case " << n << " passed." << endl;
+}
+static void eq( int n, string have, string need ) {
+ if ( have == need ) {
+ cerr << "Case " << n << " passed." << endl;
+ } else {
+ cerr << "Case " << n << " failed: expected ";
+ print( need );
+ cerr << " received ";
+ print( have );
+ cerr << "." << endl;
+ }
+}
+$ENDCUT$
+
+
+
+
+
+
+
+
+
+
+
+
+
+class $CLASSNAME$ {
+ public:
+ $RC$ $METHODNAME$($METHODPARMS$) {
+ $RC$ res;
+ return res;
+ }
+};
+
+
+
+
+
+
+
+$BEGINCUT$
+int main() {
+$MAINBODY$
+#ifdef WIN32
+ cin.get();
+#endif
+ return 0;
+}
+$ENDCUT$
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|