Source code for submission s1117

Go to diff to previous submission

fm.cpp

  1. /*
  2.  * File: fm.c
  3.  * Author: cteam025
  4.  *
  5.  * Created on October 19, 2013, 2:52 PM
  6.  */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <limits.h>
  11.  
  12. /*
  13.  *
  14.  */
  15. int ar, ac, tr, tc;
  16. char texas[1000][1001];
  17. int tiles[1000][1000];
  18. int tilesR, tilesC;
  19.  
  20.  
  21. int minim(int a, int b){
  22. if(a<b)return a;return b;
  23. }
  24.  
  25. int main(int argc, char** argv) {
  26. while(scanf("%d%d%d%d", &ar, &ac, &tr, &tc)==4){
  27. int res=0, min=1000*1000+5;
  28. for(int i=0;i<ar;i++){
  29. scanf(" %s", texas[i]);
  30. }
  31. tilesR = ar/tr + ((ar%tr)!=0)?1:0;
  32. tilesC = ac/tc + ((ac%tc)!=0)?1:0;
  33. for(int i=0;i<tr;i++){
  34. for(int j=0;j<tc;j++){
  35. for(int k=0;k<ar;k++){
  36. for(int l=0;l<ac;l++){
  37. if(texas[k][l]=='X'){
  38. tiles[(i+k)/tr][(j+l)/tc]=1;
  39. }
  40. }
  41. }
  42. for(int k=0;k<ar;k++){
  43. for(int l=0;l<ac;l++){
  44. if(tiles[k][l]){
  45. res++;
  46. }
  47. tiles[k][l]=0;
  48. }
  49. }
  50. min = minim(min, res);
  51. res = 0;
  52. }
  53. }
  54. printf("%d\n", min);
  55. }
  56.  
  57. return (EXIT_SUCCESS);
  58. }
  59.  
  60.  

Diff to submission s1101

fm.cpp

--- c5.s1101.cteam025.fm.cpp.0.fm.cpp
+++ c5.s1117.cteam025.fm.cpp.0.fm.cpp
@@ -19,5 +19,5 @@
 
 
-int min(int a, int b){
+int minim(int a, int b){
     if(a<b)return a;return b;
 }
@@ -27,5 +27,5 @@
         int res=0, min=1000*1000+5;
         for(int i=0;i<ar;i++){
-            scanf(" %s", texas+i);
+            scanf(" %s", texas[i]);
         }
         tilesR = ar/tr + ((ar%tr)!=0)?1:0;
@@ -48,19 +48,12 @@
                     }
                 }
-                min = min(min, res);
+                min = minim(min, res);
                 res = 0;
             }
         }
+    printf("%d\n", min);
     }
     
-    
-    
-    
-    
-    
-    
-    printf("%d\n", min);
-}
-return (EXIT_SUCCESS);
+    return (EXIT_SUCCESS);
 }