Source code for submission s1135

Go to diff to previous submission

fp.cpp

  1. #include <vector>
  2. #include <list>
  3. #include <map>
  4. #include <set>
  5. #include <algorithm>
  6. #include <numeric>
  7. #include <utility>
  8. #include <sstream>
  9. #include <iostream>
  10. #include <iomanip>
  11. #include <cstdio>
  12. #include <cmath>
  13. #include <cstdlib>
  14. #include <string>
  15.  
  16. #define vi vector <int>
  17. #define vvi vector <vi>
  18. #define vvvi vector <vvi>
  19. #define vl vector <long long>
  20. #define vpii vector <pair <int,int> >
  21. #define mp(x,y) make_pair(x,y)
  22. #define all(x) (x).begin(),(x).end()
  23. #define sz(x) (int)(x).size()
  24. #define FOR(i,n) for(ll i=0;i<int(n);i++)
  25. #define READ(v,n) {FOR(i,n){ll x;cin>>x;v.pb(x);} }
  26. #define gmin(a,b) {if (b<a) a=b;}
  27. #define gmax(a,b) {if (b>a) a=b;}
  28. #define pb push_back
  29. #define ppb pop_back
  30. typedef long long ll;
  31. typedef unsigned long long ull;
  32. using namespace std;
  33.  
  34. vvi invert(vvi a){
  35. vvi b=a;
  36. FOR(i,5)
  37. FOR(j,5){
  38. b[i][j]=a[j][i];
  39. }
  40. return b;
  41. }
  42.  
  43. vvi rotate(vvi a){
  44. vvi b=a;
  45. FOR(i,5)
  46. FOR(j,5){
  47. b[i][j]=a[4-j][i];
  48. }
  49. int c;
  50. rep:
  51. c=0;
  52. FOR(i,5){
  53. if(b[0][i]==1)c++;
  54. }
  55. if(c==0){
  56. vvi c=b;
  57. FOR(i,5)
  58. FOR(j,5){
  59. if(i==4){c[i][j]=0;}else{c[i][j]=b[i+1][j];}
  60. }
  61. b=c;
  62. goto rep;
  63. }
  64.  
  65. rep2:
  66. c=0;
  67. FOR(i,5){
  68. if(b[i][0]==1)c++;
  69. }
  70. if(c==0){
  71. vvi c=b;
  72. FOR(i,5)
  73. FOR(j,5){
  74. if(j==4){c[i][j]=0;}else{c[i][j]=b[i][j+1];}
  75. }
  76. b=c;
  77. goto rep2;
  78. }
  79. return b;
  80. }
  81.  
  82.  
  83.  
  84. int main(){
  85. vi v(5,0);
  86. vvi w;
  87. FOR(i,5)w.pb(v);
  88. vvvi c;
  89. FOR(i,256)c.pb(w);
  90. c['F'][1][0]=1;
  91. c['F'][2][0]=1;
  92. c['F'][0][1]=1;
  93. c['F'][1][1]=1;
  94. c['F'][1][2]=1;
  95.  
  96. c['I'][0][0]=1;
  97. c['I'][0][1]=1;
  98. c['I'][0][2]=1;
  99. c['I'][0][3]=1;
  100. c['I'][0][4]=1;
  101.  
  102. c['L'][0][0]=1;
  103. c['L'][0][1]=1;
  104. c['L'][0][2]=1;
  105. c['L'][0][3]=1;
  106. c['L'][1][3]=1;
  107.  
  108. c['N'][1][0]=1;
  109. c['N'][1][1]=1;
  110. c['N'][0][2]=1;
  111. c['N'][1][2]=1;
  112. c['N'][0][3]=1;
  113.  
  114. c['P'][0][0]=1;
  115. c['P'][1][0]=1;
  116. c['P'][0][1]=1;
  117. c['P'][1][1]=1;
  118. c['P'][0][2]=1;
  119.  
  120. c['T'][0][0]=1;
  121. c['T'][1][0]=1;
  122. c['T'][2][0]=1;
  123. c['T'][1][1]=1;
  124. c['T'][1][2]=1;
  125.  
  126. c['U'][0][0]=1;
  127. c['U'][2][0]=1;
  128. c['U'][0][1]=1;
  129. c['U'][1][1]=1;
  130. c['U'][2][1]=1;
  131.  
  132. c['V'][0][0]=1;
  133. c['V'][0][1]=1;
  134. c['V'][0][2]=1;
  135. c['V'][1][2]=1;
  136. c['V'][2][2]=1;
  137.  
  138. c['W'][0][0]=1;
  139. c['W'][0][1]=1;
  140. c['W'][1][1]=1;
  141. c['W'][1][2]=1;
  142. c['W'][2][2]=1;
  143.  
  144. c['X'][1][0]=1;
  145. c['X'][0][1]=1;
  146. c['X'][1][1]=1;
  147. c['X'][2][1]=1;
  148. c['X'][1][2]=1;
  149.  
  150. c['Y'][1][0]=1;
  151. c['Y'][0][1]=1;
  152. c['Y'][1][1]=1;
  153. c['Y'][1][2]=1;
  154. c['Y'][1][3]=1;
  155.  
  156. c['Z'][0][0]=1;
  157. c['Z'][1][0]=1;
  158. c['Z'][1][1]=1;
  159. c['Z'][1][2]=1;
  160. c['Z'][2][2]=1;
  161.  
  162.  
  163. char x,y;
  164. while(cin>>x>>y){
  165.  
  166. string s="";
  167. set <string> sset;
  168. vvi aa=c[x];
  169. vvi bb=c[y];
  170.  
  171. {
  172. FOR(i,2)
  173. FOR(r,4)
  174. FOR(x,6)
  175. FOR(y,4){
  176. if((x=='I' || x=='W' || x=='X' || x=='V' || x=='U' || x=='T') && i==1){continue;}
  177. vvi a=aa;
  178. vvi p(6,vi(4,0));
  179. if(i==1){a=invert(a);}
  180. FOR(j,r){a=rotate(a);}
  181. FOR(k,5)
  182. FOR(l,5){
  183. if(a[k][l]==1 && (x+k>=6 || y+l>=4)){goto con;}
  184. if(a[k][l]==1){
  185. if(p[x+k][y+l]==1){goto con;}
  186. p[x+k][y+l]+=a[k][l];
  187. }
  188. }
  189.  
  190. FOR(ii,2)
  191. FOR(rr,4)
  192. FOR(xx,6)
  193. FOR(yy,4){
  194. if((y=='I' || y=='W' || y=='X' || y=='V' || y=='U' || y=='T') && i==1){continue;}
  195. vvi b=bb;
  196. vvi pp=p;
  197. if(ii==1){b=invert(b);}
  198. FOR(j,rr){b=rotate(b);}
  199. FOR(k,5)
  200. FOR(l,5){
  201. if(b[k][l]==1 && (xx+k>=6 || yy+l>=4)){goto con2;}
  202. if(b[k][l]==1){
  203. if(pp[xx+k][yy+l]==1){goto con2;}
  204. pp[xx+k][yy+l]+=b[k][l];
  205. }
  206. }
  207.  
  208. s="";
  209. FOR(k,6)
  210. FOR(l,4)
  211. s=s+(char)(pp[k][l]+'0');
  212.  
  213.  
  214. sset.insert(s);
  215. con2:
  216. continue;
  217. }
  218. con:
  219. continue;
  220. }
  221.  
  222. }
  223.  
  224. cin>>x>>y;
  225. s="";
  226. aa=c[x];
  227. bb=c[y];
  228.  
  229. FOR(i,2)
  230. FOR(r,4)
  231. FOR(x,6)
  232. FOR(y,4){
  233. if((x=='I' || x=='W' || x=='X' || x=='V' || x=='U' || x=='T') && i==1){continue;}
  234. vvi a=aa;
  235. vvi p(6,vi(4,0));
  236. if(i==1){a=invert(a);}
  237. FOR(j,r){a=rotate(a);}
  238. FOR(k,5)
  239. FOR(l,5){
  240. if(a[k][l]==1 && (x+k>=6 || y+l>=4)){goto con3;}
  241. if(a[k][l]==1){
  242. if(p[x+k][y+l]==1){goto con3;}
  243. p[x+k][y+l]+=a[k][l];
  244. }
  245. }
  246.  
  247. FOR(ii,2)
  248. FOR(rr,4)
  249. FOR(xx,6)
  250. FOR(yy,4){
  251. if((y=='I' || y=='W' || y=='X' || y=='V' || y=='U' || y=='T') && i==1){continue;}
  252. vvi b=bb;
  253. vvi pp=p;
  254. if(ii==1){b=invert(b);}
  255. FOR(j,rr){b=rotate(b);}
  256. FOR(k,5)
  257. FOR(l,5){
  258. if(b[k][l]==1 && (xx+k>=6 || yy+l>=4)){goto con23;}
  259. if(b[k][l]==1){
  260. if(pp[xx+k][yy+l]==1){goto con23;}
  261. pp[xx+k][yy+l]+=b[k][l];
  262. }
  263. }
  264.  
  265. s="";
  266. FOR(k,6)
  267. FOR(l,4)
  268. s=s+(char)(pp[k][l]+'0');
  269.  
  270. if(sset.find(s)!=sset.end()){cout<<"YES"<<endl;goto nextcase;}
  271. con23:
  272. continue;
  273. }
  274. con3:
  275. continue;
  276. }
  277.  
  278. cout<<"NO"<<endl;
  279. nextcase:
  280. continue;
  281.  
  282. }
  283.  
  284.  
  285.  
  286. return 0;
  287. }
  288.  
  289.  
  290.  

Diff to submission s1105

fp.cpp

--- c5.s1105.cteam012.fp.cpp.0.fp.cpp
+++ c5.s1135.cteam012.fp.cpp.0.fp.cpp
@@ -174,4 +174,5 @@
     FOR(x,6)
     FOR(y,4){
+      if((x=='I' || x=='W' || x=='X' || x=='V' || x=='U' || x=='T') && i==1){continue;}
       vvi a=aa;
       vvi p(6,vi(4,0));   
@@ -191,4 +192,5 @@
       FOR(xx,6)
       FOR(yy,4){
+        if((y=='I' || y=='W' || y=='X' || y=='V' || y=='U' || y=='T') && i==1){continue;}
         vvi b=bb;
         vvi pp=p;
@@ -229,4 +231,5 @@
     FOR(x,6)
     FOR(y,4){
+      if((x=='I' || x=='W' || x=='X' || x=='V' || x=='U' || x=='T') && i==1){continue;}
       vvi a=aa;
       vvi p(6,vi(4,0));   
@@ -246,4 +249,5 @@
       FOR(xx,6)
       FOR(yy,4){
+        if((y=='I' || y=='W' || y=='X' || y=='V' || y=='U' || y=='T') && i==1){continue;}
         vvi b=bb;
         vvi pp=p;