fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
  5. #define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
  6. #define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
  7. #define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
  8. #define SZ(S) ((int) ((S).size()))
  9.  
  10. #define DEBUG(x) { cout << #x << " = " << x << endl; }
  11. #define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
  12. #define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }
  13.  
  14. string brail[10][3] = {
  15. {".*", "**", ".."}, //0
  16. {"*.", "..", ".."}, //1
  17. {"*.", "*.", ".."}, //2
  18. {"**", "..", ".."}, //3
  19. {"**", ".*", ".."}, //4
  20. {"*.", ".*", ".."}, //5
  21. {"**", "*.", ".."}, //6
  22. {"**", "**", ".."}, //7
  23. {"*.", "**", ".."}, //8
  24. {".*", "*.", ".."}, //9
  25. };
  26.  
  27. int main() {
  28. ios :: sync_with_stdio(false); cin.tie(NULL);
  29. cout << (fixed) << setprecision(6);
  30. int n;
  31. while (cin >> n && n) {
  32. char typ; cin >> typ;
  33. // DEBUG(n);
  34. // DEBUG(typ);
  35. if (typ == 'S') {
  36. string a[3];
  37. REP(t,3) a[t] = "";
  38.  
  39. string dig; cin >> dig;
  40. REP(i,dig.size()) {
  41. int u = dig[i] - '0';
  42. REP(t,3) {
  43. if (i) a[t] += ' ';
  44. a[t] += brail[u][t];
  45. }
  46. }
  47. REP(t,3) cout << a[t] << endl;
  48. }
  49. else {
  50. string a[3];
  51. REP(t,3) {
  52. a[t] = "";
  53. REP(i,2*n) {
  54. char c; cin >> c;
  55. a[t] += c;
  56. }
  57. }
  58. // PR0(a, 3);
  59. REP(turn,n) {
  60. int start = 2 * turn;
  61. REP(dig,10) {
  62. if (brail[dig][0] == a[0].substr(start,2)
  63. && brail[dig][1] == a[1].substr(start, 2)
  64. && brail[dig][2] == a[2].substr(start, 2)) {
  65. cout << dig;
  66. break;
  67. }
  68. }
  69. }
  70. cout << endl;
  71. }
  72. }
  73. return 0;
  74. }
  75.  
  76.  
Success #stdin #stdout 0s 3472KB
stdin
10
S
1234567890
3
B
*. *. **
.. *. ..
.. .. ..
2
S
00
0
stdout
*. *. ** ** *. ** ** *. .* .*
.. *. .. .* .* *. ** ** *. **
.. .. .. .. .. .. .. .. .. ..
123
.* .*
** **
.. ..