Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin ("elicop.in");
- ofstream fout ("elicop.out");
- int a[105][105], n, m, k, sol[45], nsol, op1;
- void Parcurgere(int xi , int yi , int xf , int yf , int ind , int varf)
- {
- int nr0, nr1 , p , p1;
- nr0 = nr1 = 0;
- if(varf == 1)
- {
- if(yi >= yf)
- {
- while(yi >= yf)
- {
- p = xi;
- p1 = yi;
- while(p1 >= yf)
- {
- nr0 += (a[p][p1] == 0);
- nr1 += (a[p][p1] == 1);
- p++;
- p1--;
- }
- yi--;
- }
- }
- else
- {
- while(yi <= yf)
- {
- p = xi;
- p1 = yi;
- while(p1 <= yf)
- {
- nr0 += (a[p][p1] == 0);
- nr1 += (a[p][p1] == 1);
- p++;
- p1++;
- }
- yi++;
- }
- }
- }
- else
- {
- if(yf >= yi)
- {
- while(yf >= yi)
- {
- p = xf;
- p1 = yf;
- while(p1 >= yi)
- {
- nr0 += (a[p][p1] == 0);
- nr1 += (a[p][p1] == 1);
- p--;
- p1--;
- }
- yf--;
- }
- }
- else
- {
- while(yf <= yi)
- {
- p = xf;
- p1 = yf;
- while(p1 <= yi)
- {
- nr0 += (a[p][p1] == 0);
- nr1 += (a[p][p1] == 1);
- p--;
- p1++;
- }
- yf++;
- }
- }
- }
- if(!nr0)
- op1++;
- if(nr0 > nr1)
- {
- ++nsol;
- sol[nsol] = ind;
- }
- }
- int main()
- {
- int xi, yi, xf, yf, varf ;
- bool ok = false;
- fin >> n >> m;
- for(int i = 1 ; i <= n ; i++)
- for(int j = 1 ; j <= m ; j++)
- fin >> a[i][j];
- fin >> k;
- for(int i = 1 ; i <= k ; i++)
- {
- fin >> xi >> yi >> xf >> yf >> varf;
- if(xi > xf)
- {
- swap(xi, xf);
- swap(yi, yf);
- }
- Parcurgere(xi , yi , xf , yf , i , varf);
- }
- fout << op1 << "\n";
- fout << nsol << " ";
- for(int i = 1 ; i <= nsol ; i++)
- fout << sol[i] << " ";
- fout << "\n";
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement