Advertisement
AlenAntonelli

A. Inna and Choose Options

Jul 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. /// https://trello.com/c/iPvrzUgB/9-problem-a-codeforces
  2. /// http://codeforces.com/contest/400/problem/A
  3. #include <iostream>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int t;
  10.     cin>>t;
  11.    
  12.     vector< vector<int> > resp(t);
  13.    
  14.     int v[6] = {1, 2, 3, 4, 6, 12};
  15.     string s;
  16.    
  17.     for (int q=0; q<t; q++)
  18.     {
  19.         cin>>s;
  20.        
  21.         for (int p=0; p<6; p++)
  22.         {
  23.             int alto = v[p];
  24.             int ancho = v[5-p];
  25.            
  26.             bool hay_col = false;
  27.            
  28.             for(int i=0; i<ancho && !hay_col; i++) ///analizo todas las columnas, mientras no halla encontrado alguna valida
  29.             {
  30.                 bool col_valid = true;
  31.                
  32.                 for(int j=0; j<alto; j++)
  33.                     if (s[ ancho*j+i ]=='O')
  34.                         col_valid = false;
  35.                        
  36.                 if (col_valid) /// la columna a analizar el valida hasta que se demuestre lo contrario
  37.                     hay_col = true;
  38.             }
  39.            
  40.             if (hay_col)
  41.                 resp[q].push_back( alto );
  42.         }
  43.     }
  44.    
  45.     for (int q=0; q<t; q++)
  46.     {
  47.         cout<<resp[q].size();
  48.        
  49.         for (int i=0; i<resp[q].size(); i++)
  50.             cout<<" "<<resp[q][i]<<"x"<<12/resp[q][i];
  51.         cout<<endl;
  52.     }
  53.    
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement