Submission #15536

#TimeUsernameProblemLanguageResultExecution timeMemory
15536gs14004흑백 이미지 찾기 (kriii3_G)C++14
0 / 101
0 ms1296 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; typedef pair<int,int> pi; int a[105][105], b[105][105]; int n, m, r, c; bool ccw(pi a, pi b, pi c){ int dx1 = b.first - a.first; int dy1 = b.second- a.second; int dx2 = c.first - a.first; int dy2 = c.second - a.second; return 1ll * dx1 * dy2 != 1ll * dy1 * dx2; } vector<pi> v; bool compare(int x, int y){ v.clear(); for(int i=1; i<=r; i++){ for(int j=1; j<=c; j++){ v.push_back(pi(a[x+i-1][y+j-1], b[i][j])); } } for(int i=0; i<(int)v.size() - 2; i++){ if(ccw(v[i],v[i+1],v[i+2]) == 0){ continue; } return 0; } for(int i=0; i<(int)v.size()-1; i++){ if(v[i].first == v[i+1].first && v[i].second != v[i+1].second){ return 0; } } return 1; } int main(){ scanf("%d %d",&n,&m); for(int i=1; i<=n; i++){ for(int j=1; j<=m; j++){ scanf("%d",&a[i][j]); } } scanf("%d %d",&r,&c); for(int i=1; i<=r; i++){ for(int j=1; j<=c; j++){ scanf("%d",&b[i][j]); } } int ret = 0; for(int i=1; i<=n-r+1; i++){ for(int j=1; j<=m-c+1; j++){ if(compare(i,j)) ret++; } } printf("%d",ret); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...