# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15516 |
2015-07-12T08:45:41 Z |
pichulia |
흑백 이미지 찾기 (kriii3_G) |
C++ |
|
10000 ms |
12888 KB |
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
int n, m;
int p,q;
int a[1003][1003];
int b[1004][1004];
int c[1004][1004];
int gcd(int p,int q)
{
if(p<0)p=-p;
if(q<0)q=-q;
if(p==0)return q;
if(q==0)return p;
while(p%q){int t=p%q;p=q;q=t;}
return q;
}
int main()
{
int i, j ,k, l;
scanf("%d %d",&n,&m);
for(i=0;i<n;i++)
for(j=0;j<m;j++)
scanf("%d",&a[i][j]);
scanf("%d %d",&p,&q);
for(i=0;i<p;i++)
for(j=0;j<q;j++)
scanf("%d",&b[i][j]);
int g = 0;
k= b[0][0];
for(i=0;i<p;i++)
for(j=0;j<q;j++)
{
b[i][j] -= k;
g = gcd(g,b[i][j]);
}
bool special = false;
if(g>0)
for(i=0;i<p;i++)
for(j=0;j<q;j++)
b[i][j] /= g;
else
special = true;
int cnt=0;
for(i=0;i<=n-p;i++)
for(j=0;j<=m-q;j++)
{
if(special)
{
cnt++;
continue;
}
int t = a[i][j];
int g = 0;
for(k=0;k<p;k++)
for(l=0;l<q;l++)
{
c[k][l] = a[i+k][j+l] - t;
g = gcd(g,c[k][l]);
}
if(g>0)
for(k=0;k<p;k++)
for(l=0;l<q;l++)
c[k][l] /= g;
for(k=0;k<p;k++)
{
for(l=0;l<q;l++)
if(c[k][l]!=b[k][l])
break;
if(l<q)break;
}
if(k<p)
{
for(k=0;k<p;k++)
{
for(l=0;l<q;l++)
if(c[k][l]!=-b[k][l])
break;
if(l<q)break;
}
if(k==p)
cnt++;
}
else
cnt++;
}
printf("%d\n",cnt);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
12888 KB |
Output is correct |
2 |
Correct |
0 ms |
12888 KB |
Output is correct |
3 |
Correct |
0 ms |
12888 KB |
Output is correct |
4 |
Correct |
3 ms |
12888 KB |
Output is correct |
5 |
Correct |
0 ms |
12888 KB |
Output is correct |
6 |
Correct |
0 ms |
12888 KB |
Output is correct |
7 |
Correct |
20 ms |
12888 KB |
Output is correct |
8 |
Correct |
17 ms |
12888 KB |
Output is correct |
9 |
Correct |
14 ms |
12888 KB |
Output is correct |
10 |
Correct |
14 ms |
12888 KB |
Output is correct |
11 |
Correct |
11 ms |
12888 KB |
Output is correct |
12 |
Correct |
7 ms |
12888 KB |
Output is correct |
13 |
Correct |
10 ms |
12888 KB |
Output is correct |
14 |
Correct |
10 ms |
12888 KB |
Output is correct |
15 |
Correct |
33 ms |
12888 KB |
Output is correct |
16 |
Correct |
5 ms |
12888 KB |
Output is correct |
17 |
Correct |
3 ms |
12888 KB |
Output is correct |
18 |
Correct |
0 ms |
12888 KB |
Output is correct |
19 |
Correct |
0 ms |
12888 KB |
Output is correct |
20 |
Correct |
3 ms |
12888 KB |
Output is correct |
21 |
Correct |
61 ms |
12888 KB |
Output is correct |
22 |
Correct |
58 ms |
12888 KB |
Output is correct |
23 |
Correct |
55 ms |
12888 KB |
Output is correct |
24 |
Correct |
0 ms |
12888 KB |
Output is correct |
25 |
Correct |
49 ms |
12888 KB |
Output is correct |
26 |
Correct |
14 ms |
12888 KB |
Output is correct |
27 |
Correct |
0 ms |
12888 KB |
Output is correct |
28 |
Correct |
8 ms |
12888 KB |
Output is correct |
29 |
Correct |
9 ms |
12888 KB |
Output is correct |
30 |
Correct |
11 ms |
12888 KB |
Output is correct |
31 |
Correct |
14 ms |
12888 KB |
Output is correct |
32 |
Correct |
6 ms |
12888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
10000 ms |
12884 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |