Skip to content

Instantly share code, notes, and snippets.

View Cycatz's full-sized avatar
💢
La man gry!

Cycatz Cycatz

💢
La man gry!
View GitHub Profile
@Cycatz
Cycatz / TSP2.cpp
Last active June 12, 2017 14:54
TSP template
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn = 15;
int n, dis[maxn][maxn], dp[maxn][1 << maxn];
int main(){
while(scanf("%d", &n) == 1){
memset(dp, 0x3f, sizeof(dp));
// input a matrix represent the each dot-to-dot distance
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;
const int maxn = 250;
const int dx[] = {1, 0, 0, -1}, dy[] = {0, 1, -1, 0};
const char dire[] = {'e', 'n', 's', 'w'};
@Cycatz
Cycatz / [CF]580B.cpp
Created April 12, 2017 10:01
[CF]580B - Kefa and Company
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 1e5 + 5;
typedef long long LL;
LL sum[maxn];
struct Company{
int money, ship;
Company(int _m = 0, int _s = 0):money(_m),ship(_s){}
@Cycatz
Cycatz / [UVa]532.cpp
Created April 6, 2017 05:06
[UVa]532 - Dungeon Master
#include<iostream>
#include<cstdio>
#include<queue>
using namespace std ;
const int dx[6] = {0 , 0 , 0 , 0 , 1 , -1} ;
const int dy[6] = {0 , 0 , 1 , -1 , 0 , 0} ;
const int dz[6] = {1 , -1 , 0 , 0 , 0 , 0} ;
const int maxn = 30 + 5 ;
int l, r, c ;
@Cycatz
Cycatz / [UVa]514.cpp
Created April 6, 2017 05:04
[UVa]514 - Rails
#include<iostream>
#include<cstdio>
#include<stack>
using namespace std ;
const int maxn = 10000 ;
int main(){
int n , k , num[maxn];
while(scanf("%d" , &n) == 1 && n){
num[0] = 0 ;
for(;;){
@Cycatz
Cycatz / [UVa]230.cpp
Last active April 6, 2017 05:06
[UVa]230 - Borrowers
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<cstdio>
using namespace std;
typedef pair<string, string> PSS;
set<PSS> lis, temp;
map<string, string> link;
void printcode(set<PSS> x) // debug
@Cycatz
Cycatz / ZJb291.cpp
Created January 31, 2017 16:17
b291: 生態調查
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<map>
#include<set>
#include<vector>
using namespace std ;
vector<string> Vplace , Vanimal;
set<string> placeS , animalS;
map < pair <string , string> , int> quan ;
@Cycatz
Cycatz / [Uva]10161.cpp
Last active April 6, 2017 05:07
[Uva]10161 - Ant on a Chessboard
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std ;
void r(long long sum , long long k , long long &in1 , long long &in2)
{
if(sum <= k)
in1++ , in2 += sum ;
else if(sum > k)
in1 -= sum - (k + 1) , in2 += k ;