fork(1) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <string>
  9. #include <queue>
  10. #include <stack>
  11. #include <algorithm>
  12. #define dibs reserve
  13. #define OVER9000 1234567890
  14. #define tisic 47
  15. #define soclose 10e-7
  16. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  17. #define chocolate win
  18. #define ff first
  19. #define ss second
  20. #define uint unsigned int
  21. // mylittlepony
  22. using namespace std;
  23.  
  24. int main() {
  25. int T;
  26. cin >> T;
  27. for(int i =0; i < T; i++) {
  28. int N;
  29. cin >> N;
  30. map<string,int> row;
  31. map<string,int> col;
  32. map< pair<string,string>, string> M;
  33. for(int i =0; i < N; i++) {
  34. string s,t,u;
  35. cin >> s >> t >> u;
  36. M[make_pair(s,t)] =u;
  37. row[s] =0;
  38. col[t] =0;}
  39. int a =0;
  40. ALL_THE(row,it) {it->ss =a; a++;}
  41. a =0;
  42. ALL_THE(col,it) {it->ss =a; a++;}
  43.  
  44. vector<string> V(3+2*row.size());
  45. for(int i =0; i < V.size(); i++) {
  46. for(int j =0; j < 5+4*col.size(); j++) {
  47. if(i%2 == 0) V[i] +="-";
  48. else V[i] +=" ";}
  49. if(i%2 == 0) for(int j =0; j < V[i].length(); j +=4) V[i][j] ='+';
  50. else for(int j =0; j < V[i].length(); j +=4) V[i][j] ='|';}
  51. ALL_THE(M,it) {
  52. int x =row[it->ff.ff], y =col[it->ff.ss];
  53. for(int j =0; j < (it->ss).length(); j++) V[2*x+3][4*y+5+j] =(it->ss)[j];
  54. }
  55. ALL_THE(row,it) for(int j =0; j < (it->ff).length(); j++)
  56. V[2*(it->ss)+3][1+j] =(it->ff)[j];
  57. ALL_THE(col,it) for(int j =0; j < (it->ff).length(); j++)
  58. V[1][4*(it->ss)+5+j] =(it->ff)[j];
  59. for(int i =0; i < V.size(); i++) cout << V[i] << "\n";}
  60. return 0;}
  61.  
  62. // look at my code
  63. // my code is amazing
Success #stdin #stdout 0s 3444KB
stdin
2
9
R1 P1 C1
R1 P2 C2
R1 P3 C3
R1 P4 C4
R2 P1 C5
R2 P5 C6
R2 P6 C7
R2 P7 C8
R3 P5 C9
1
R1 P1 CCC
stdout
+---+---+---+---+---+---+---+---+
|   |P1 |P2 |P3 |P4 |P5 |P6 |P7 |
+---+---+---+---+---+---+---+---+
|R1 |C1 |C2 |C3 |C4 |   |   |   |
+---+---+---+---+---+---+---+---+
|R2 |C5 |   |   |   |C6 |C7 |C8 |
+---+---+---+---+---+---+---+---+
|R3 |   |   |   |   |C9 |   |   |
+---+---+---+---+---+---+---+---+
+---+---+
|   |P1 |
+---+---+
|R1 |CCC|
+---+---+