Skip to content

Commit a3084b9

Browse files
committed
From the old laptop
1 parent 013c4cf commit a3084b9

File tree

85 files changed

+4315
-62
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+4315
-62
lines changed

Bomberman.cpp

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
#include<iostream>
2+
#include<queue>
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include <ctype.h>
6+
7+
8+
using namespace std;
9+
10+
struct Tparent{
11+
int i,j;
12+
Tparent(int i, int j) : i(i), j(j) {}
13+
Tparent(){};
14+
bool operator == (const Tparent &uni){
15+
return(i==uni.i && j==uni.j);
16+
}
17+
18+
};
19+
20+
struct Tpuerta{
21+
int i,j;
22+
double prob;
23+
Tpuerta(int i, int j, double prob) : i(i), j(j), prob(prob) {}
24+
Tpuerta(int i, int j) : i(i), j(j), prob(0) {}
25+
Tpuerta(){};
26+
bool operator == (const Tpuerta &uni){
27+
return(i==uni.i && j==uni.j);
28+
}
29+
30+
};
31+
32+
char grid[20][20];
33+
bool visited[20][20];
34+
Tparent parent[20][20];
35+
Tpuerta puertas[10];
36+
int arr[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1,};
37+
int n;
38+
int steps=0;
39+
40+
41+
42+
void bfs(int start_i, int start_j){
43+
queue <Tparent> q;
44+
q.push(Tparent(start_i,start_j));
45+
visited[start_i][start_j] = true;
46+
47+
while(!q.empty()){
48+
Tparent v = q.front();
49+
q.pop();
50+
for(int k=0; k < 4; k++){
51+
int ti = v.i + arr[k][0];
52+
int tj = v.j + arr[k][1];
53+
54+
if(ti>=0 && ti<n && tj>=0 && tj<n){
55+
if(!visited[ti][tj]){
56+
visited[ti][tj] = true;
57+
if(grid[ti][tj]=='.'){
58+
q.push(Tparent(ti,tj));
59+
parent[ti][tj]= Tparent(v);
60+
//cout<<v.i<<" "<<v.j<<" is parent of "<< ti << " "<<tj<<endl;
61+
}else if(isdigit(grid[ti][tj])){
62+
parent[ti][tj]= Tparent(v);
63+
}
64+
65+
}
66+
}
67+
}
68+
}
69+
70+
}
71+
72+
void shortest_path(Tparent start, Tparent end){
73+
if(start == end || end == Tparent(-1,-1)){
74+
}else{
75+
steps++;
76+
shortest_path(start, parent[end.i][end.j]);
77+
78+
}
79+
80+
}
81+
82+
int main(){
83+
int cases;
84+
int nPuerta;
85+
int bomberX;
86+
int bomberY;
87+
88+
cin>>cases;
89+
while(cases--){
90+
cin>>n;
91+
for(int i=0;i<n;i++){
92+
for(int j=0;j<n;j++){
93+
char c;
94+
cin>>c;
95+
if(c=='B'){
96+
bomberX=i;
97+
bomberY=j;
98+
}else if(isdigit(c)){
99+
int puert= c - '0';
100+
//cout<<puert<<" ";
101+
puertas[puert]=Tpuerta(i,j);
102+
}
103+
grid[i][j] = c;
104+
visited[i][j]=false;
105+
parent[i][j]=Tparent(-1,-1);
106+
}
107+
}
108+
bfs(bomberX,bomberY);
109+
110+
cin>>nPuerta;
111+
for(int i=0;i<nPuerta;i++){
112+
cin>>puertas[i].prob;
113+
}
114+
double sum=0;
115+
for(int i=0; i<nPuerta;i++){
116+
steps=0;
117+
shortest_path(Tparent (bomberX,bomberY), Tparent (puertas[i].i,puertas[i].j));
118+
sum+=(double)(steps * (puertas[i].prob * 0.01));
119+
}
120+
cout.precision(2);
121+
cout<<fixed<<sum<<endl;
122+
123+
}
124+
125+
126+
127+
128+
return 0;
129+
}

Live Archive/4215 - Feynman.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
4215 - Feynman
3+
ACM-ICPC Live Archive
4+
Esteban Arango Medina
5+
6+
7+
*/
8+
9+
#include<iostream>
10+
11+
using namespace std;
12+
13+
int main(){
14+
int n;
15+
while((cin>>n) && n){cout<<(2*n + 1)*n*(n+1)/6<<endl;}
16+
return 0;
17+
}

Live Archive/4233 - Cryptoquote.cpp

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
4233 - Cryptoquote
3+
ACM-ICPC Live Archive
4+
Esteban Arango Medina
5+
6+
*/
7+
8+
#include<iostream>
9+
#include<string>
10+
11+
using namespace std;
12+
13+
int main(){
14+
int cases;
15+
int cont=1;
16+
17+
string message;
18+
string alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
19+
string newAlphabet;
20+
21+
cin>>cases;
22+
getline(cin,message);
23+
24+
while(cases){
25+
getline(cin,message);
26+
getline(cin,newAlphabet);
27+
for(int i=0;i < message.size();i++){
28+
for(int j=0;j<26;j++){
29+
if(message[i]==alphabet[j]){
30+
message[i]=newAlphabet[j];
31+
break;
32+
}
33+
}
34+
}
35+
cout<<cont<<" "<<message<<endl;
36+
cont++;
37+
cases--;
38+
}
39+
40+
return 0;
41+
}

PKU/3507 - Judging Olympia.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
3507 - Judging Olympia
3+
PKU Online Judge
4+
Esteban Arango Medina
5+
6+
*/
7+
#include<iostream>
8+
9+
using namespace std;
10+
11+
int main(){
12+
int grades[6];
13+
bool fin=false;
14+
while(!fin){
15+
int max=0,min=11,total=0;
16+
for(int i=0;i<6;i++){
17+
cin>>grades[i];
18+
if(grades[i]>max){max=grades[i];}
19+
if(grades[i]<min){min=grades[i];}
20+
total+=grades[i];
21+
}
22+
if(total!=0){cout<<(double)(total-min-max)/4<<endl;}
23+
else{fin=true;}
24+
}
25+
return 0;
26+
}

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Almost all of them in c++.
33

44
####Online judge
5+
* [UVa Online Judge](http://uva.onlinejudge.org/)
6+
* [ZOJ](http://acm.zju.edu.cn/)
7+
* [Live Archive](http://livearchive.onlinejudge.org/)
8+
* [PKU](http://poj.org/)
59
* [CodeForces](http://codeforces.com/)
610
* [Interviewstreet](https://www.interviewstreet.com/)
711
* [Sphere Online Judge](http://www.spoj.pl/)

SPOJ/11031 - Bank Robbers.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
11031 - Bank Robbers
3+
SPOJ
4+
Esteban Arango Medina
5+
*/
6+
#include <algorithm>
7+
#include <iostream>
8+
#include <iterator>
9+
#include <numeric>
10+
#include <sstream>
11+
#include <fstream>
12+
#include <cassert>
13+
#include <climits>
14+
#include <cstdlib>
15+
#include <cstring>
16+
#include <string>
17+
#include <cstdio>
18+
#include <vector>
19+
#include <cmath>
20+
#include <queue>
21+
#include <deque>
22+
#include <stack>
23+
#include <list>
24+
#include <map>
25+
#include <set>
26+
using namespace std;
27+
28+
int main(){
29+
int n,m;
30+
31+
while(scanf("%d %d",&n,&m)!=EOF){
32+
printf("%d\n",n+m);
33+
}
34+
return 0;
35+
}

SPOJ/6256 - Inversion Count.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1+
/*
2+
6256 - Inversion Count
3+
SPOJ
4+
Esteban Arango Medina
5+
6+
Solution:
7+
Make a new array of size 'MaxElement' of the given array, then, back to front get the sum of each until inv[i]-1 (no including i),
8+
and add 1 to postion inv[i]. Then print the sum. And that's the number of inversions.
9+
Fenwick tree.
110
2-
using namespace std;
11+
Notes.
12+
http://community.topcoder.com/tc?module=Static&d1=tutorials&d2=binaryIndexedTrees
13+
*/
314
#include <algorithm>
415
#include <iostream>
516
#include <iterator>
@@ -20,7 +31,7 @@ using namespace std;
2031
#include <list>
2132
#include <map>
2233
#include <set>
23-
34+
using namespace std;
2435

2536
int get(vector<int> *tree,int i){
2637
int sum = 0;

SPOJ/902 - Hangover.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
902 - Hangover
3+
Sphere Online Judge
4+
Esteban Arango Medina
5+
6+
*/
7+
8+
#include <cstdio>
9+
10+
int main (){
11+
double num,temp;
12+
while(scanf("%lf",&num) && num ){
13+
temp=0;
14+
int resp=1;
15+
while(temp<=num){
16+
temp+=(double) 1/(resp+1);
17+
resp++;
18+
}
19+
printf("%d card(s)\n",resp-1);
20+
}
21+
22+
return 0;
23+
}

SPOJ/julka.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Esteban Arango Medina
55
66
Solution:
7-
Simply show the advantage of Java over C++ = BigInteger. :P
7+
Simply shows the advantage of Java over C++ = BigInteger. :P
88
*/
99
import java.io.BufferedReader;
1010
import java.io.File;

TJU/11000 - Bee.cpp

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
11000 - Bee
3+
TJU Online Judge
4+
Esteban Arango Medina
5+
6+
7+
*/
8+
9+
#include<iostream>
10+
#include<vector>
11+
12+
using namespace std;
13+
14+
int main(){
15+
16+
int n;
17+
18+
cin>>n;
19+
20+
while(n!=-1){
21+
22+
vector <long long int> fib;
23+
fib.push_back(0);
24+
fib.push_back(1);
25+
26+
for (int i = 2; i < n+4; i++){
27+
fib.push_back(fib[i-1] + fib[i-2]);
28+
}
29+
cout<<fib[n+2]-1<<" "<<fib[n+3]-1<<endl;
30+
cin>>n;
31+
}
32+
return 0;
33+
}

0 commit comments

Comments
 (0)