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
| #!/usr/bin/env python | |
| import urllib,re,random | |
| l = list() | |
| def randprob(): | |
| global l | |
| d = "" | |
| if len(l) == 0: | |
| d = urllib.urlopen("http://www.topcoder.com/tc?module=BasicData&c=dd_round_list") | |
| p = re.compile("<full_name>([^<>]*)<\/full_name>") |
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
| template <class T> | |
| void group2(int j, vector<vector<vector<T> > > &result, vector<bool> &used, vector<T> &path, vector<vector<T> > &path2, const vector<T> &v); | |
| template <class T> | |
| static void group1(vector<vector<vector<T> > > &result, vector<bool> &used, vector<vector<T> > &path2, const vector<T> &v){ | |
| int n = v.size(); | |
| int unused = -1; | |
| for(int i = 0; i < n; i++){ | |
| if(!used[i]) { | |
| unused = i; |
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
| typedef long long int LLI; | |
| #define SZ(x) int(x.size()) | |
| #define FOR(x,y,z) for(int x = y; y < z; x++) | |
| #define REP(x,y) FOR(x,0,y) | |
| int main(int argc, char *argv[]){ | |
| vector<bool> v(30000000,false); | |
| FOR(i,1,3000){ | |
| LLI n = i * i; |
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 <vector> | |
| #include <iostream> | |
| using namespace std; | |
| void vec_print(const vector<int> &v){ | |
| cout << "[ "; | |
| for(vector<int>::const_iterator itr = v.begin(); | |
| itr != v.end(); ++itr){ | |
| cout << *itr << " "; |
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 BrokenClock | |
| { | |
| vector<string> split(const string &str, const string &delim){ | |
| vector<string> res; | |
| size_t current = 0, found, delimlen = delim.size(); | |
| while((found = str.find(delim, current)) != string::npos){ | |
| res.push_back(string(str, current, found - current)); | |
| current = found + delimlen; | |
| } |
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 SpeedTyper | |
| { | |
| public: | |
| string lettersToPractice(string letters, vector <int> times) | |
| { | |
| vector<int> times2; | |
| int ave = 0; | |
| for(size_t i = 0; i < times.size(); i++){ | |
| int time = times[i]; | |
| if(i != 0) |
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 SimpleRotationDecoder | |
| { | |
| vector<string> split(const string &str, const string &delim){ | |
| vector<string> res; | |
| size_t current = 0, found, delimlen = delim.size(); | |
| while((found = str.find(delim, current)) != string::npos){ | |
| res.push_back(string(str, current, found - current)); | |
| current = found + delimlen; |
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 Chessboard | |
| { | |
| public: | |
| string changeNotation(string cell) | |
| { | |
| ostringstream oss; | |
| if(cell[0] >= 'a' && cell[0] <= 'h'){ | |
| int c = static_cast<int>(cell[0]) - 'a' + 1; | |
| int n = static_cast<int>(cell[1]) - '1'; |
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 <sys/file.h> | |
| #include <pthread.h> | |
| #include <assert.h> | |
| #include <semaphore.h> | |
| #include <errno.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <fcntl.h> | |
| static int locked = 0; |
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 "stdafx.h" | |
| #include "Windows.h" | |
| #include "winnls.h" | |
| #include <string> | |
| #include <cstdio> | |
| using namespace std; | |