Advertisement
vlatkovski

monitor (nedovrseno)

Oct 7th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.40 KB | None | 0 0
  1. //nedovrseno
  2. #include <iostream>
  3. #include <set>
  4. #include <utility>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     int m, n, k, p; //redovi, koloni, dimenzija na slikata, broj na pikseli
  10.     cin >> m >> n >> k >> p;
  11.  
  12.     set<pair<int,int>> rasipani;
  13.  
  14.     //int arr[m][n] = {};
  15.  
  16.     for (int i = 0; i < p; i++) {
  17.         int x, y, tip;
  18.         cin >> x >> y >> tip;
  19.  
  20.         if (tip == 1) {
  21.             rasipani.insert({tip, x}); //tip=1, znaci horizontalna linija, znaci site pikseli na redot X se crni
  22.             /*for (int b = 0; b < n; b++) {
  23.                arr[x][b] = 1;
  24.             }*/
  25.         } else {
  26.             rasipani.insert({tip, y}); //tip=2, znaci vertikalna linija, znaci site pikseli na kolonata Y se crni
  27.             /*for (int a = 0; a < m; a++) {
  28.                arr[a][y] = 2;
  29.             }*/
  30.         }
  31.     }
  32.  
  33.     int best_cp = n * m;
  34.  
  35.     //cout << endl; ///IZBRISI IZBRISI IZBRISI
  36.  
  37.     for (int x = 0; x < m; x++) {
  38.         for (int y = 0; y < n; y++) {
  39.  
  40.             int crni_pikseli = 0;
  41.  
  42.             for (int a = 0; a < k; a++) {
  43.                 if (rasipani.find({1, x + a}) != rasipani.end()) {
  44.                     crni_pikseli += k;
  45.                 }
  46.             }
  47.             for (int b = 0; b < k; b++) {
  48.                 if (rasipani.find({2, y + b}) != rasipani.end()) {
  49.                     crni_pikseli += k;
  50.                 }
  51.             }
  52.  
  53.             if (crni_pikseli < best_cp) {
  54.                 best_cp = crni_pikseli;
  55.             }
  56. /*
  57.             int temp[k][k] = {};
  58.  
  59.             for (int a = 0; a < k; a++) {
  60.                 for (int b = 0; b < k; b++) {
  61.                     temp[a][b] = arr[a + x][b + y];
  62.                     arr[a + x][b + y] = 3;
  63.                 }
  64.             }
  65.  
  66.             for (int a = 0; a < m; a++) {
  67.                 for (int b = 0; b < n; b++) {
  68.                     cout << arr[a][b] << " ";
  69.                 }
  70.                 cout << endl;
  71.             }
  72.  
  73.             cout << "cp: " << crni_pikseli << endl << endl;
  74.  
  75.             for (int a = 0; a < k; a++) {
  76.                 for (int b = 0; b < k; b++) {
  77.                     arr[a + x][b + y] = temp[a][b];
  78.                 }
  79.             }*/
  80.         }
  81.     }
  82.  
  83.     cout << best_cp << endl;
  84. /*
  85.     for (int a = m; a < m; a++) {
  86.         for (int b = 0; b < n; b++) {
  87.             cout << arr[a][b] << " ";
  88.         }
  89.         cout << endl;
  90.     }
  91. */
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement