-
Notifications
You must be signed in to change notification settings - Fork 3
/
elicop.cpp
99 lines (93 loc) · 1.47 KB
/
elicop.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("elicop.in");
ofstream out ("elicop.out");
int n,m,eNtAf;
bool fieldMap[100][100];
char wrongElic[42];
int abs(int x)
{
if( x < 0 )return -x;
return x;
}
int min(int a,int b)
{
if(a > b)return b;
return a;
}
void solve(int k)
{
int x1,x2,y1,y2,sw;
in >> x1 >> y1 >> x2 >> y2 >> sw;
int xOff=min(x1,x2);
int yOff=min(y1,y2);
int sX = abs(x2-x1);
int sY = abs(y2-y1);
int zAf=0;
int zT = 0;
if(x2-x1==y2-y1)
{
if(sw==1)
{
for(int i = 0; i <= sX; i++)
for(int j = sY; j >= i; j--)
{
zT++;
if(fieldMap[i+xOff-1][j+yOff-1]==0)
zAf++;
}
}
else
{
for(int i = 0; i <= sX; i++)
for(int j = 0; j <= i; j++)
{
zT++;
if(fieldMap[i+xOff-1][j+yOff-1]==0)
zAf++;
}
}
}
else
{
if(sw == 1)
{
for(int i = 0; i <= sX; i++)
for(int j = 0; j <= sY-i; j++)
{
zT++;
if(fieldMap[i+xOff-1][j+yOff-1]==0)
zAf++;
}
}
else
{
for(int i = 0; i <= sX; i++)
for(int j = sY-i; j <= sY; j++)
{
zT++;
if(fieldMap[i+xOff-1][j+yOff-1]==0)
zAf++;
}
}
}
if(zAf==0)eNtAf++;
else if(zT/zAf<2)wrongElic[++wrongElic[0]]=k;
}
int main()
{
in >> n >> m;
for( int i = 0; i < n; i++)
for( int j = 0; j < m; j++)
in >> fieldMap[i][j];
int k;
in >> k;
for(int e = 1; e <= k; e++)
{
solve(e);
}
out << eNtAf << '\n';
for(int i = 0; i <= wrongElic[0];i++)
out << int(wrongElic[i]) << ' ';
}