Skip to content

Instantly share code, notes, and snippets.

@nomarlo
Created November 12, 2016 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomarlo/5ef61b1de2ff1364f66f110e36bbe5b2 to your computer and use it in GitHub Desktop.
Save nomarlo/5ef61b1de2ff1364f66f110e36bbe5b2 to your computer and use it in GitHub Desktop.
/**
La idea de solución es ad-hoc.
Tener cuidado con que la fuente C5 solo deben imprimir los * y la C1 solo los caracteres, no los espacios( . )
**/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <cstdio>
//#define gc getchar_unlocked
using namespace std;
typedef vector<int> vi;
string AB [28][5], T[65];
string dashes="------------------------------------------------------------";
/**
void scanint(int &x)
{
register int c = gc();
x = 0;
for(;(c<48 || c>57);c = gc());
for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
}**/
int r,c;
string n1,n2;
string cmd,font,s;
int getX(char a){
if( a == ' ' || (int)a > 82 ) return 2;
if ( (int)a <= 73 ) return 0;
if( (int)a <= 82 ) return 1;
}
int getY (char a){
if( a == ' ' || (int)a > 82 ) return a == ' ' ? 7*8 : 7*( (int)a-83 );
if ( (int)a <= 73 ) return 7*( (int)a -65 );
if( (int)a <= 82 ) return 7*( (int)a -74 );
}
int main(){
AB[0][0]=".***.. ****.. .****. ****.. *****. *****. .****. *...*. *****.";
AB[0][1]="*...*. *...*. *...*. *...*. *..... *..... *..... *...*. ..*...";
AB[0][2]="*****. ****.. *..... *...*. ***... ***... *..**. *****. ..*...";
AB[0][3]="*...*. *...*. *..... *...*. *..... *..... *...*. *...*. ..*...";
AB[0][4]="*...*. ****.. .****. ****.. *****. *..... .***.. *...*. *****.";
AB[1][0]="..***. *...*. *..... *...*. *...*. .***.. ****.. .***.. ****..";
AB[1][1]="...*.. *..*.. *..... **.**. **..*. *...*. *...*. *...*. *...*.";
AB[1][2]="...*.. ***... *..... *.*.*. *.*.*. *...*. ****.. *...*. ****..";
AB[1][3]="*..*.. *..*.. *..... *...*. *..**. *...*. *..... *..**. *..*..";
AB[1][4]=".**... *...*. *****. *...*. *...*. .***.. *..... .****. *...*.";
AB[2][0]=".****. *****. *...*. *...*. *...*. *...*. *...*. *****. ......";
AB[2][1]="*..... *.*.*. *...*. *...*. *...*. .*.*.. .*.*.. ...*.. ......";
AB[2][2]=".***.. ..*... *...*. .*.*.. *.*.*. ..*... ..*... ..*... ......";
AB[2][3]="....*. ..*... *...*. .*.*.. **.**. .*.*.. ..*... .*.... ......";
AB[2][4]="****.. .***.. .***.. ..*... *...*. *...*. ..*... *****. ......";
while(cin>>cmd){
for(int i=0;i<63;i++)
T[i]="............................................................";
while(cmd!=".EOP"){
int x,y;
cin>>font;
cin>>r;
if(cmd==".P"){
cin>>c;
c--;
getline(cin,s); // s=" |ABC DE|" ;
if(font=="C5"){
for(int i=2;s[i]!='|' && c<=60;i++){
x = getX(s[i]);
y = getY(s[i]);
for(int a=0;a<5;a++){
for(int e=0;e<6 && r+a<=60 && c+e<60 ;e++){
T[r+a][c+e] = AB[x][a][y+e]=='*' ? AB[x][a][y+e] : T[r+a][c+e];
}
}
c+=6;
}
}
else{
for(int i=2;s[i]!='|' && c<60;i++){
T[r][c]=s[i]==' '? T[r][c] == '.' ? '.':'*' :s[i];
c++;
}
}
}
else if(cmd==".L"){
c=0;
getline(cin,s);
if(font=="C5"){
for(int i=2;s[i]!='|' && c<60;i++){
x = getX(s[i]);
y = getY(s[i]);
for(int a=0;a<5;a++){
for(int e=0;e<6 && r+a<=60 && c+e<60 ;e++){
T[r+a][c+e] = AB[x][a][y+e]=='*' ? AB[x][a][y+e] : T[r+a][c+e];
}
}
c+=6;
}
}
else{
for(int i=2;s[i]!='|' && c<60;i++){
T[r][c]=s[i]==' '? T[r][c] == '.' ? '.':'*':s[i];
c++;
}
}
}
else if(cmd==".R"){
c=59;
getline(cin,s);
if(font=="C5"){
for(int i=s.size()-2;s[i]!='|' && c>=0;i--){
x = getX(s[i]);
y = getY(s[i])+5;
for(int a=0;a<5;a++){
for(int e=0;e<6 && r+a<=60 && c-e>=0 ;e++){
T[r+a][c-e] = AB[x][a][y-e] == '*' ? AB[x][a][y-e] : T[r+a][c-e];
}
}
c-=6;
}
}
else{
for(int i=s.size()-2;s[i]!='|' && c>=0;i--){
T[r][c]=s[i]==' '? T[r][c] == '.' ? '.':'*':s[i];
c--;
}
}
}
else if(cmd==".C"){
int i;
int tam;
getline(cin,s);
tam=s.size()-3;
if(font=="C5"){
c=30-( (tam*6)/2 );
for(int i=2;s[i]!='|' && c<60;i++){
if(c>=-6){
x = getX(s[i]);
y = getY(s[i]);
for(int a=0;a<5;a++){
for(int e=0;e<6 && r+a<=60 && c+e<60 ;e++){
if(c+e>=0)
T[r+a][c+e] = AB[x][a][y+e]=='*' ? AB[x][a][y+e] : T[r+a][c+e];;
}
}
}
c+=6;
}
}
else{
c=30-(tam/2);
for(int i=2;s[i]!='|' && c<60;i++,c++){
if(c>=0)
T[r][c]=s[i]==' '? T[r][c] == '.' ? '.':'*':s[i];
}
}
}
cin>>cmd;
}
for(int i=1;i<=60;i++){
cout<<T[i];
cout<<"\n";
}
cout<<"\n"<<dashes<<"\n\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment