Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- using namespace std;
- ifstream fin("elicop.in");
- ofstream fout("elicop.out");
- int a[105][105];
- int v[45];
- int main()
- {
- int i, j, m, n, k, l, l1, l2, c1, c2, p, nr0, nr1, x=0, raz, aux, perfecte=0, gresite=0;
- fin>>n>>m;
- for(i=1; i<=n; i++)
- {
- for(j=1; j<=m; j++)
- {
- fin>>a[i][j];
- }
- }
- fin>>k;
- for(l=1; l<=k; l++)
- {
- nr0=0;
- nr1=0;
- x=0;
- fin>>l1>>c1>>l2>>c2>>p;
- if(l1>l2)
- {
- aux=l1;
- l1=l2;
- l2=aux;
- aux=c1;
- c1=c2;
- c2=aux;
- }
- if(p!=1)
- {
- if(c1<c2)
- {
- for(i=l1; i<=l2; i++)
- {
- for(j=c1; j<=x+c1; j++)
- {
- if(a[i][j]==0)
- {
- nr0++;
- }
- else
- {
- nr1++;
- }
- }
- x++;
- }
- }
- else
- {
- for(i=l1; i<=l2; i++)
- {
- for(j=c1; j>=c1-x; j--)
- {
- if(a[i][j]==0)
- {
- nr0++;
- }
- else
- {
- nr1++;
- }
- }
- x++;
- }
- }
- }
- else
- {
- if(c1>c2)
- {
- for(i=l1; i<=l2; i++)
- {
- for(j=c1-x; j>=c2; j--)
- {
- if(a[i][j]==0)
- {
- nr0++;
- }
- else
- {
- nr1++;
- }
- }
- x++;
- }
- }
- else
- {
- for(i=l1; i<=l2; i++)
- {
- for(j=c2; j>=c1+x; j--)
- {
- if(a[i][j]==0)
- {
- nr0++;
- }
- else
- {
- nr1++;
- }
- }
- x++;
- }
- }
- }
- if(nr0==0)
- {
- perfecte++;
- }
- if(nr0>nr1)
- {
- gresite++;
- v[gresite]=l;
- }
- }
- fout<<perfecte<<endl<<gresite<<' ';
- for(i=1; i<=gresite; i++)
- {
- fout<<v[i]<<' ';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement