problem_id
stringlengths 6
6
| user_id
stringlengths 10
10
| time_limit
float64 1k
8k
| memory_limit
float64 262k
1.05M
| problem_description
stringlengths 48
1.55k
| codes
stringlengths 35
98.9k
| status
stringlengths 28
1.7k
| submission_ids
stringlengths 28
1.41k
| memories
stringlengths 13
808
| cpu_times
stringlengths 11
610
| code_sizes
stringlengths 7
505
|
---|---|---|---|---|---|---|---|---|---|---|
p03804 | u594956556 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["N, M = map(int, input().split())\nA = [input() for _ in range(N)]\nB = [input() for _ in range(N)]\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n \n for k in range(M):\n if A[i+k][j:j+M] != B[k]:\n break\n else:\n print('Yes')\n exit()\n \n break\n\nprint('No')", "N, M = map(int, input().split())\nA = [input() for _ in range(N)]\nB = [input() for _ in range(M)]\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n \n for k in range(M):\n if A[i+k][j:j+M] != B[k]:\n break\n else:\n print('Yes')\n exit()\n\nprint('No')\n"] | ['Runtime Error', 'Accepted'] | ['s395446636', 's585396521'] | [3064.0, 3060.0] | [18.0, 18.0] | [291, 275] |
p03804 | u601913978 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["import sys\nn, m = map(int, input().split())\nn_list = [list(input()) for i in range(n)]\nm_list = [list(input()) for i in range(m)]\n\ndef bunkatu(x, y):\n global n_list\n lis = []\n for i in range(y, y + m):\n lis.append(n_list[i][x: x + m])\n return lis\n\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n tmp = bunkatu(i, j)\n if m_list == tmp:\n print('YES')\n sys.exit(0)\nprint('NO')", "import sys\nn, m = map(int, input().split())\nn_list = [list(input()) for i in range(n)]\nm_list = [list(input()) for i in range(m)]\n\ndef bunkatu(x, y):\n global n_list\n lis = []\n for i in range(y, y + m):\n lis.append(n_list[i][x: x + m])\n return lis\n\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n tmp = bunkatu(i, j)\n if m_list == tmp:\n print('Yes')\n sys.exit(0)\nprint('No')"] | ['Wrong Answer', 'Accepted'] | ['s900186956', 's211540978'] | [3064.0, 3064.0] | [23.0, 25.0] | [439, 439] |
p03804 | u609738635 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['# -*- coding: utf-8 -*-\n\ndef solve(N, M, A, B):\n \n include = False\n for h in range(N-M+1):\n for w in range(N-M+1):\n match = True\n for i in range(M):\n for j in range(M):\n if(A[h+i][w+j] != B[i][j]):\n match = False\n if(match):\n include = True\n \n print("Yes" if include else "No")\n \n \nif __name__ == \'__main__\':\n N, M = map(int, input().split())\n A, B = [], []\n for i in range(N):\n A.append(input())\n for j in range(M):\n B.append(input())\n\n solve(N, M, A, B', '# -*- coding: utf-8 -*-\n\ndef solve(N, M, A, B):\n include = False\n for h in range(N-M+1):\n for w in range(N-M+1):\n match = True\n for i in range(M):\n for j in range(M):\n if(A[h+i][w+j] != B[i][j]):\n match = False\n if(match):\n include = True\n\n print("Yes" if include else "No")\n\nif __name__ == \'__main__\':\n N, M = map(int, input().split())\n A, B = [], []\n for i in range(N):\n A.append(input())\n for j in range(M):\n B.append(input())\n\n solve(N, M, A, B)'] | ['Runtime Error', 'Accepted'] | ['s150193123', 's877926689'] | [3064.0, 3064.0] | [17.0, 93.0] | [616, 599] |
p03804 | u612721349 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n, m = map(int, input().split())\nnp = [input() for _ in range(n)]\nmp = [input() for _ in range(m)]\nfor i in range(n-m-1):\n for j in range(n-m-1):\n f = True\n for k in range(m):\n if np[i+k][j:j+m] != mp[i+k]:\n f = False\n if f:\n print("Yes")\n exit(0)\nelse:\n print("No")', 'n, m = map(int, input().split())\nnp = [input() for _ in range(n)]\nmp = [input() for _ in range(m)]\nfor i in range(n-m+1):\n for j in range(n-m+1):\n f = True\n for k in range(m):\n if np[i+k][j:j+m] != mp[k]:\n f = False\n if f:\n print("Yes")\n exit(0)\nelse:\n print("No")\n'] | ['Runtime Error', 'Accepted'] | ['s870817189', 's732413865'] | [3064.0, 3060.0] | [18.0, 24.0] | [301, 299] |
p03804 | u619197965 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m=[int(i) for i in input().split()]\na=[input() for i in range(n)]\nb=[input() for i in range(m)]\nfor i in range(m):\n for j in range(len(b[i])):\n if b[i][j]!=a[i][j]:\n result=True\n break\nprint("No" if result else "Yes")', 'n,m=[int(i) for i in input().split()]\na=[input() for i in range(n)]\nb=[input() for i in range(m)]\nresult=True\nfor i in range(m):\n if (b[i] in a[i])==False:\n result=False\n break\nprint("Yes" if result else "No")'] | ['Runtime Error', 'Accepted'] | ['s367430668', 's000239008'] | [3060.0, 3188.0] | [17.0, 19.0] | [251, 226] |
p03804 | u622568141 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["# -*- coding: utf-8 -*-\nimport sys\nimport math\nimport numpy as np\n\n\ndef main():\n \n # M = int(input())\n N, M = map(int, input().split())\n sA = ''.join([input() for i in range(N)])\n sB = ''.join([input() for i in range(M)])\n A = np.array([s for s in sA]).reshape(N,N)\n B = np.array([s for s in sB]).reshape(M,M)\n\n \n result = np.zeros((N-M,N-M), dtype=bool)\n for i in range(N-M+1):\n for j in range(N-M+1):\n result[i,j] = (A[i:i+M, j:j+M] == B).all()\n\n \n if result.any():\n print('Yes')\n else:\n print('No')\n\n\nif __name__ == '__main__':\n main()\n", "# -*- coding: utf-8 -*-\nimport sys\nimport math\nimport numpy as np\n\n\ndef main():\n \n # M = int(input())\n N, M = map(int, input().split())\n sA = ''.join([input() for i in range(N)])\n sB = ''.join([input() for i in range(M)])\n A = np.array([s for s in sA]).reshape(N,N)\n B = np.array([s for s in sB]).reshape(M,M)\n\n \n result = np.zeros((N-M+1,N-M+1), dtype=bool)\n for i in range(N-M+1):\n for j in range(N-M+1):\n result[i,j] = (A[i:i+M, j:j+M] == B).all()\n\n \n if result.any():\n print('Yes')\n else:\n print('No')\n\n\nif __name__ == '__main__':\n main()\n"] | ['Runtime Error', 'Accepted'] | ['s152276666', 's014625030'] | [20656.0, 20668.0] | [282.0, 289.0] | [661, 665] |
p03804 | u626468554 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['#n = int(input())\n#n,k = map(int,input().split())\n#x = list(map(int,input().split()))\n\n\nN,M = map(int,input().split())\nA = [list(input()) for _ in range(N)]\nB = [list(input()) for _ in range(M)]\n\nflg1 = 1\nflg2 = 0\nfor i in range(N-M):\n if flg2:\n break\n for j in range(N-M):\n if flg2:\n break\n flg1 = 1\n \n for k in range(M):\n if not(flg1):\n break\n for l in range(M):\n if A[i+k][j+l]==B[k][l]:\n continue\n else:\n flg1 = 0\n else:\n if flg1:\n print("Yes")\n flg2 = 1\nelse:\n print("No")', '#n = int(input())\n#n,k = map(int,input().split())\n#x = list(map(int,input().split()))\n\n\nN,M = map(int,input().split())\nA = [list(input()) for _ in range(N)]\nB = [list(input()) for _ in range(M)]\n\nflg1 = 1\nflg2 = 0\nfor i in range(N-M+1):\n if flg2:\n break\n for j in range(N-M+1):\n if flg2:\n break\n flg1 = 1\n \n for k in range(M):\n if not(flg1):\n break\n for l in range(M):\n if A[i+k][j+l]==B[k][l]:\n continue\n else:\n flg1 = 0\n else:\n if flg1:\n print("Yes")\n flg2 = 1\nelse:\n if not(flg2):\n print("No")'] | ['Wrong Answer', 'Accepted'] | ['s811088494', 's989724774'] | [3064.0, 3064.0] | [22.0, 23.0] | [685, 711] |
p03804 | u637175065 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return list(map(int, input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\n\ndef main():\n n,m = LI()\n a = []\n for i in range(n):\n t = 0\n for c in S():\n t <<= 1\n if c == '#':\n t += 1\n a.append(t)\n\n b = []\n for i in range(m):\n t = 0\n for c in S():\n t <<= 1\n if c == '#':\n t += 1\n b.append(t)\n\n mask = 2**m-1\n for i in range(n-m+1):\n for j in range(n-m+1):\n f = True\n for k in range(m):\n ak = (a[k+j] >> i) & mask\n if ak != b[k]:\n f = False\n break\n if f:\n return 'YES'\n return 'NO'\n\n\nprint(main())\n", "import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time\n\nsys.setrecursionlimit(10**7)\ninf = 10**20\nmod = 10**9 + 7\n\ndef LI(): return list(map(int, input().split()))\ndef II(): return int(input())\ndef LS(): return input().split()\ndef S(): return input()\n\n\ndef main():\n n,m = LI()\n a = []\n for i in range(n):\n t = 0\n for c in S():\n t <<= 1\n if c == '#':\n t += 1\n a.append(t)\n\n b = []\n for i in range(m):\n t = 0\n for c in S():\n t <<= 1\n if c == '#':\n t += 1\n b.append(t)\n\n mask = 2**m-1\n for i in range(n-m+1):\n for j in range(n-m+1):\n f = True\n for k in range(m):\n ak = (a[k+j] >> i) & mask\n if ak != b[k]:\n f = False\n break\n if f:\n return 'Yes'\n return 'No'\n\n\nprint(main())\n"] | ['Wrong Answer', 'Accepted'] | ['s735299481', 's280187648'] | [6924.0, 5536.0] | [74.0, 53.0] | [968, 968] |
p03804 | u637824361 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int, input().split())\nA = [input() for i in range(N)]\nB = [input() for i in range(M)]\ni = 0\nwhile(i <= N - M):\n x = A[i].find(B[0])\n while(N - M >= x >= 0):\n for j in range(1,M):\n if A[i+j][x-1:x-1+M] != B[j]:\n x = A[i].find(B[0], x+1)\n break\n else:\n print("Yes")\n exit()\n i += 1\nprint("No")\n', 'N, M = map(int, input().split())\nA = [input() for i in range(N)]\nB = [input() for i in range(M)]\ni = 0\nwhile(i <= N - M):\n x = A[i].find(B[0])\n while(N - M >= x and x >= 0):\n for j in range(1,M):\n if A[i+j][x:x+M] != B[j]:\n x = A[i].find(B[0], x+1)\n break\n else:\n print("Yes")\n exit()\n i += 1\nprint("No")\n'] | ['Wrong Answer', 'Accepted'] | ['s204885735', 's470646754'] | [3064.0, 3064.0] | [18.0, 18.0] | [389, 391] |
p03804 | u655975843 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 2):\n for i in range(n - m + 2):\n if A[j][i: i + m] == B[0][:]:\n for k in range(m):\n if A[j + k][i: i + m] == B[k][:]:\n flag = 1\n continue\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n for k in range(m):\n if A[j + k][i: i + m] == B[k]:\n flag = 1\n continue\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n if A[j][i: i + m] == B[0][:]:\n for k in range(m):\n if A[j + k][i: i + m] == B[k][:]:\n flag = 1\n continue\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n flag = 1\n for k in range(m):\n if A[j + k][i: i + m] != B[k]:\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n if A[j][i:] == B[0][:]:\n for k in range(m):\n if A[j + k][i:] == B[k][:]:\n flag = 1\n continue\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\n# if m > n:\n# print('No')\n# exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n if A[j][i: i + m] == B[0][:]:\n for k in range(m):\n if A[j + k][i: i + m] == B[k][:]:\n flag = 1\n continue\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n if A[j][i: i + m] == B[0][:]:\n for k in range(m):\n if A[j + k][i: i + m] == B[k][:]:\n flag = 1\n continue\n elif A[j + k][i: i + m] != B[k][:]:\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = map(int, input().split())\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n flag = 1\n for k in range(m):\n if A[j + k][i: i + m] != B[k]:\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n for k in range(m):\n if A[j + k][i: i + m] == B[k][:]:\n flag = 1\n continue\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\n# if m > n:\n# print('No')\n# exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n flag = 1\n for k in range(m):\n if A[j + k][i: i + m] != B[k]:\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = list(map(int, input().split()))\nA = []\nB = []\nfor i in range(n):\n A.append([input()])\nfor i in range(m):\n B.append([input()])\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n if A[j][i:] == B[j][:]:\n for k in range(m - 1):\n if A[j + k][i:] == B[j + k][:]:\n flag = 1\n continue\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n", "n, m = map(int, input().split())\nA = []\nB = []\nfor i in range(n):\n A.append(input())\nfor i in range(m):\n B.append(input())\nif m > n:\n print('No')\n exit(0)\nfor j in range(n - m + 1):\n for i in range(n - m + 1):\n flag = 0\n for k in range(m):\n if A[j + k][i: i + m] == B[k][:]:\n flag = 1\n continue\n flag = 0\n break\n if flag == 1:\n print('Yes')\n exit(0)\nprint('No')\n"] | ['Runtime Error', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s086849101', 's208740452', 's237263336', 's335879799', 's469999370', 's510637486', 's581997407', 's668418536', 's678479610', 's816728423', 's822278895', 's162005067'] | [3064.0, 3064.0, 3064.0, 3064.0, 3064.0, 3064.0, 3064.0, 3188.0, 3064.0, 3064.0, 3188.0, 3064.0] | [19.0, 19.0, 18.0, 19.0, 19.0, 19.0, 19.0, 20.0, 20.0, 19.0, 18.0, 18.0] | [550, 473, 550, 448, 538, 556, 610, 442, 476, 454, 546, 483] |
p03804 | u665415433 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["def solve(n, m, NUM):\n for i in range(len(m)):\n if n[NUM + i] is not m[i]:\n return -1\n return 1\n\n\nN, M = [int(i) for i in input().split()]\nn_pic = [input() for i in range(N)]\nm_pic = [input() for i in range(M)]\nnum = 0\nif M is 1:\n for n in n_pic:\n if -1 is not n.find(m_pic[0]):\n print('Yes')\n exit()\n print('No')\n exit()\n\nfor n in range(len(n_pic)):\n for n_len in range(N - M + 1):\n while -1 is not solve(n_pic[n+num], m_pic[num], n_len):\n num += 1\n print(num)\n if num is M:\n print('Yes')\n exit()\n num = 0\nprint('No')\n", "def solve(n, m, NUM):\n for i in range(len(m)):\n if n[NUM + i] is not m[i]:\n return -1\n return 1\n\n\nN, M = [int(i) for i in input().split()]\nn_pic = [input() for i in range(N)]\nm_pic = [input() for i in range(M)]\nnum = 0\nif M is 1:\n for n in n_pic:\n if -1 is not n.find(m_pic[0]):\n print('Yes')\n exit()\n print('No')\n exit()\n\nfor n in range(N - M + 1):\n for n_len in range(N - M + 1):\n while -1 is not solve(n_pic[n + num], m_pic[num], n_len):\n num += 1\n if num is M:\n print('Yes')\n exit()\n num = 0\nprint('No')\n"] | ['Runtime Error', 'Accepted'] | ['s076571041', 's659651102'] | [3064.0, 3064.0] | [19.0, 19.0] | [661, 639] |
p03804 | u668253056 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import numpy as np\nimport sys\nN = int(input())\nM = int(input())\nA = []\nB = []\ndef change(n):\n if(n==\'#\'):\n return True;\n return False;\n\nfor i in range(N):\n temp = input()\n A.append(list(map(change, temp)))\nfor i in range(M):\n temp = input()\n B.append(list(map(change, temp)))\nA = np.array(A)\nB = np.array(B)\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if (B== A[i:M+j, i:M+j]).all():\n print("Yes")\n sys.exit()\n\nprint("No")\n', 'import numpy as np\nimport sys\ntemp = input().split()\nN = int(temp[0])\nM = int(temp[1])\nA = []\nB = []\ncheck = False\ndef change(n):\n if(n==\'#\'):\n return True;\n return False;\n\nfor i in range(N):\n temp = input()\n A.append(list(map(change, temp)))\nfor i in range(M):\n temp = input()\n B.append(list(map(change, temp)))\nA = np.array(A)\nB = np.array(B)\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if (B== A[i:M+i, j:M+j]).all():\n check = True\n break\n if check:\n break\n\nif check:\n print("Yes")\nelse:\n print("No")\n'] | ['Runtime Error', 'Accepted'] | ['s549996123', 's739075849'] | [12756.0, 18596.0] | [299.0, 1093.0] | [451, 538] |
p03804 | u668503853 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N,M=map(int,input().split())\nA=[input() for _ in range(N)]\nB=[input() for _ in range(M)]\nans="No"\nfor i in range(N-M+1):\n for j in range(len(A[0])-len(B[0])+1):\n t = 0\n for k in range(len(B[0])):\n for l in range(M):\n if A[k+q][l+p] == B[q][p]:\n t += 1\n if t==len(B[0])*M:\n ans="Yes"\n exit()\nprint(ans)', 'N,M=map(int,input().split())\nA=[input() for _ in range(N)]\nB=[input() for _ in range(M)]\nans="No"\nfor i in range(N-M+1):\n for j in range(len(A[0])-len(B[0])+1):\n t = 0\n for k in range(len(B[0])):\n for l in range(M):\n if A[k+q][l+p] == B[q][p]:\n t += 1\n if t==len(B[0])*M:\n ans="Yes"\n break\nprint(ans)', 'N,M=map(int,input().split())\nA=[input() for _ in range(N)]\nB=[input() for _ in range(M)]\nans="No"\nfor i in range(N-M+1):\n for j in range(len(A[0])-len(B[0])+1):\n t = 0\n for k in range(len(B[0])):\n for l in range(M):\n if A[i+l][j+k] == B[l][k]:\n t += 1\n if t==len(B[0])*M:\n ans="Yes"\n exit()\nprint(ans)\n', 'N,M=map(int,input().split())\nA=[input() for _ in range(N)]\nB=[input() for _ in range(M)]\nans="No"\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if [a[j:j+M] for a in A[i:i+M]]==B: \n ans="Yes"\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s518237596', 's522816441', 's988687865', 's201892790'] | [3064.0, 3064.0, 3064.0, 3060.0] | [17.0, 17.0, 161.0, 20.0] | [342, 341, 343, 216] |
p03804 | u670180528 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["t,*a=open(0);n,m=map(int,t.split());r=range(n-m+1)\nprint('YNeos'[all(a[n:]!=[t[j:j+m]for t in a[i:i+m]]for i in r for j in r)::2])", 'x,*c=open(0);n,m=map(int,x.split());o=n-m+1;print("YNeos"[all(any(c[p//o+q//m][p%o+q%m]!=c[n+q//m][q%m]for q in range(m*m))for p in range(o*o))::2])'] | ['Wrong Answer', 'Accepted'] | ['s750393609', 's702709904'] | [3060.0, 3060.0] | [21.0, 19.0] | [130, 148] |
p03804 | u672475305 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n,m = map(int,input().split())\nA = [list(input()) for _ in range(n)]\nB = [list(input()) for _ in range(m)]\nans = False\nfor i in range(n-m+1):\n for j in range(n-m+1):\n flg = True\n for e, k in enumerate(range(m)):\n if A[i+e][j:j+m+1] != B[k]:\n flg = False\n if flg:\n ans = True\n break\nprint('YES' if ans else 'NO')", "n,m = map(int,input().split())\nA = [list(input()) for _ in range(n)]\nB = [list(input()) for _ in range(m)]\nans = False\nfor i in range(n-m+1):\n for j in range(n-m+1):\n flg = True\n for e, k in enumerate(range(m)):\n if A[i+e][j:j+m] != B[k]:\n flg = False\n if flg:\n ans = True\n break\nprint('Yes' if ans else 'No')\n"] | ['Wrong Answer', 'Accepted'] | ['s975345927', 's704440911'] | [3064.0, 3060.0] | [26.0, 26.0] | [383, 382] |
p03804 | u681917640 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int, input().split())\n\nA = [ input() for _ in range(N) ]\nB = [ input() for _ in range(M) ]\n\nfor i in range(N-M+1):\n for _ in range(A[i].count(B[0])):\n l = A[i].index(B[0], l)\n result = True\n for k in range(1, M):\n if B[k] != A[i+k][l:l+len(B[k])]:\n result = False\n break\n if result:\n print("Yes")\n exit()\n l += 1\n \nprint("No")', 'N, M = map(int, input().split())\n\nA = [ input() for _ in range(N) ]\nB = [ input() for _ in range(M) ]\n\nfor i in range(N-M):\n for j in range(A[i].count(B[0])-1):\n l = A[i].index(B[0], j)\n result = True\n for k in range(1, M):\n if B[k] != A[i+k][l:l+len(B[k])]:\n result = False\n break\n if result:\n print("Yes")\n exit()\n \nprint("No")', 'N, M = map(int, input().split())\n\nA = [ input() for _ in range(N) ]\nB = [ input() for _ in range(M) ]\n\nfor i in range(N-M+1):\n l = 0\n for _ in range(A[i].count(B[0])):\n l = A[i].index(B[0], l)\n result = True\n for k in range(1, M):\n if B[k] != A[i+k][l:l+len(B[k])]:\n result = False\n break\n if result:\n print("Yes")\n exit()\n l += 1\n \nprint("No")'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s194162671', 's806652412', 's834486627'] | [3064.0, 3064.0, 3064.0] | [17.0, 17.0, 18.0] | [387, 376, 395] |
p03804 | u682997551 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["import sys\n\nN, M = map(int, input().split())\nA = [input() for _ in range(N)]\nB = [input() for _ in range(M)]\n\nfor i in range(N - M + 1):\n if i >= M:\n break\n\n matched = True\n for j in range(N - M + 1):\n if A[i][j:j+M] == B[i][j:j+M]:\n continue\n else:\n matched = False\n break\n if matched:\n print('Yes')\n sys.exit()\n\nprint('No')", "import sys\n\nN, M = map(int, input().split())\nA = [input() for _ in range(N)]\nB = [input() for _ in range(M)]\n\nfor i in range(N - M + 1):\n for j in range(N - M + 1):\n matched = True\n\n for k in range(M):\n if A[i+k][j:j+M] == B[k]:\n continue\n else:\n matched = False\n break\n \n if matched:\n print('Yes')\n sys.exit()\n\nprint('No')"] | ['Wrong Answer', 'Accepted'] | ['s351034887', 's888970410'] | [3064.0, 3064.0] | [17.0, 18.0] | [405, 439] |
p03804 | u686036872 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int, input().split())\na = []\nb = []\nfor i in range(N):\n a.append(input())\nc = 0\nfor i in range(M):\n b.append(input())\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n s1 = a[i][j:j+M] \n s2 = b[k]\n if s1 != s2:\n break\n else:\n print("Yes")\nprint("No")', 'N, M = map(int, input().split())\nlist = []\nfor i in range(H):\n list.append(input())\ncount = 0\nfor i in range(M):\n x = input()\n for j in list:\n if x in j:\n count+=1\nprint("No" if count=0 else "Yes")', 'N, M = map(int, input().split())\na = []\nb = []\nfor i in range(N):\n a.append(input())\nc = 0\nfor i in range(M):\n b.append(input())\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n if a[i+k][j:j+M] == b[k]:\n c += 1\n if c == M:\n print("Yes")\n break\nprint("No")', 'N, M = map(int, input().split())\na = []\nb = []\nfor i in range(N):\n a.append(input())\nc = 0\nans = "No"\nfor i in range(M):\n b.append(input())\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n if a[i+k][j:j+M] == b[k]:\n c += 1\n if c == M:\n ans = "Yes"\n break\n c = 0\nprint(ans)'] | ['Wrong Answer', 'Runtime Error', 'Wrong Answer', 'Accepted'] | ['s097145246', 's428445024', 's657875249', 's141714994'] | [3064.0, 2940.0, 3064.0, 3064.0] | [19.0, 17.0, 22.0, 23.0] | [361, 216, 346, 369] |
p03804 | u688375653 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import numpy as np\n\nN,M = map(int, input().split())\n\nA=[]\nfor i in range(N):\n A.append(list(input()))\n\nB=[]\nfor j in range(M):\n B.append(list(input()))\n\nA=np.asarray(A)\nB=np.asarray(B)\nflg=False\nif (A == B).all():\n flg=True\n \nfor x in range(N-M):\n for y in range(N-M):\n if (A[x:x+M,y:y+M] == B).all():\n flg=True\nif flg:\n print("Yes")\nelse:\n print("No")', 'import numpy as np\n\nN,M = map(int, input().split())\n\nA=[]\nfor i in range(N):\n A.append(list(input()))\n\nB=[]\nfor j in range(M):\n B.append(list(input()))\n\nA=np.asarray(A)\nB=np.asarray(B)\nflg=False\n\n \nfor x in range(N-M):\n for y in range(N-M):\n if (A[x:x+M,y:y+M] == B).all():\n flg=True\nif flg:\n print("Yes")\nelse:\n try:\n if (A == B).all():\n print("Yes")\n else:\n print("No")\n except:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s311809134', 's582002346'] | [12500.0, 13044.0] | [152.0, 170.0] | [389, 473] |
p03804 | u690536347 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['def f():\n n,m=map(int,input().split())\n o=[input() for _ in range(n)]\n p=[input() for _ in range(m)]\n for i in range(n-m+1):\n for j in range(n-m+1):\n for k in range(i,n-m+1):\n for l in range(j,n-m+1):\n if p[k-i][l-j]!=o[k][l]:\n return False\n return True\n\nif f():\n print("Yes")\nelse:\n print("No")', 'def func():\n n,m=map(int,input().split())\n o=[input() for _ in range(n)]\n p=[input() for _ in range(m)]\n q=[]\n for i in range(n-m+1):\n for j in range(n-m+1):\n fl=True\n for k in range(m):\n for l in range(m):\n if p[k][l]!=o[i+k][j+l]:\n fl=False\n q.extend([fl])\n return q\n\na=func()\nif sum(a):\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Accepted'] | ['s260405479', 's074200236'] | [3064.0, 3064.0] | [17.0, 95.0] | [337, 375] |
p03804 | u696444274 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n = int(input())\n\na = list(map(int, input().split()))\ncheck = False\nfor i in range(n):\n if a[i] % 2 != 0:\n check = True\n break\ncount = 0\nwhile check == False:\n for i in range(n):\n a[i] /= 2\n if a[i] % 2 != 0:\n check = True\n break\n count += 1\nprint(count)\n', 'n, m = list(map(int, input().split()))\n#a = list(map(int, input().split()))\na = []\nb = []\nfor i in range(n):\n a.append(input())\nfor i in range(m):\n b.append(input())\n\nfor i in range(n-m+1):\n for j in range(len(a[0])-len(b[0])+1):\n count = 0\n if b[0] == a[i][j:j+len(b[0])]:\n # print("aaaa")\n for k in range(m):\n if b[k] == a[i+k][j:j+len(b[0])]:\n count += 1\n if count == m:\n print("Yes")\n exit()\n# print(count)\nprint("No")\n'] | ['Runtime Error', 'Accepted'] | ['s396294996', 's988623669'] | [3060.0, 3064.0] | [17.0, 18.0] | [354, 543] |
p03804 | u697658632 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["import sys\nn, m = map(int, input().split())\na = []\nfor i in range(n):\n a.append(list(input()))\nb = []\nfor i in range(m):\n b.append(list(input()))\nfor i in range(n - m + 1):\n for j in range(n - m + 1):\n if a[i:i+m][j:j+m] == b:\n print('Yes')\n sys.exit()\nprint('No')\n", "import sys\nn, m = map(int, input().split())\na = []\nfor i in range(n):\n a.append(list(input()))\nb = []\nfor i in range(m):\n b.append(list(input()))\nfor i in range(n - m + 1):\n for j in range(n - m + 1):\n if [c[j:j+m] for c in a[i:i+m]] == b:\n print('Yes')\n sys.exit()\nprint('No')\n"] | ['Wrong Answer', 'Accepted'] | ['s907156941', 's930872343'] | [3060.0, 3064.0] | [18.0, 22.0] | [281, 294] |
p03804 | u702786238 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import numpy as np\n\nN, M = map(int, input().split())\n\nAs = np.array([["." for n in range(N)] for nn in range(N)])\nfor n in range(N):\n As[n,:] = np.array(list(input()))\n \nBs = np.array([["." for n in range(M)] for nn in range(M)])\nfor m in range(M):\n Bs[m,:] = np.array(list(input()))\n \nok = False\nfor i in range(N-M+1):\n for j in range(N-M+1):\n print(As[i:i+M,j:j+M])\n print()\n if (As[i:i+M,j:j+M] == Bs).all():\n ok = True\n break\nif ok:\n print("Yes")\nelse:\n print("No")\n', 'import numpy as np\n\nN, M = map(int, input().split())\n\nAs = np.array([["." for n in range(N)] for nn in range(N)])\nfor n in range(N):\n As[n,:] = np.array(list(input()))\n \nBs = np.array([["." for n in range(M)] for nn in range(M)])\nfor m in range(M):\n Bs[m,:] = np.array(list(input()))\n \nok = False\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if (As[i:i+M,j:j+M] == Bs).all():\n ok = True\n break\nif ok:\n print("Yes")\nelse:\n print("No")\n'] | ['Wrong Answer', 'Accepted'] | ['s292145240', 's458518964'] | [14180.0, 13020.0] | [853.0, 177.0] | [496, 457] |
p03804 | u704563784 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n, m = map(int, input().split())\na = [input() for _ in range(n)]\nb = [input() for _ in range(m)]\n\nif n == m:\n if a == b:\n print('Yes')\n else:\n print('No')\n exit()\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n c = [l[j:j+m] for l in a[i:i+m]]\n print(c)\n if c == b:\n print('Yes')\n exit()\n\nprint('No')", "n, m = map(int, input().split())\na = [input() for _ in range(n)]\nb = [input() for _ in range(m)]\n\nif n == m:\n if a == b:\n print('Yes')\n else:\n print('No')\n exit()\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n c = [l[j:j+m] for l in a[i:i+m]]\n if c == b:\n print('Yes')\n exit()\n\nprint('No')\n\n"] | ['Wrong Answer', 'Accepted'] | ['s510869223', 's167637057'] | [3444.0, 3060.0] | [25.0, 20.0] | [370, 355] |
p03804 | u728483880 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int,input().split())\nA = [str(input()) for _ in range(N)]\nB = [str(input()) for _ in range(M)]\n \nres = "No"\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n if(A[i+k][j:j+M] != B[k]):\n break\n if(k==M-1):\n res="yes"\n \nprint(res)', 'N, M = map(int,input().split())\nA = [str(input()) for _ in range(N)]\nB = [str(input()) for _ in range(M)]\n \nres = "No"\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n if(A[i+k][j:j+M] != B[k]):\n break\n if(k==M-1):\n res="Yes"\n \nprint(res)'] | ['Wrong Answer', 'Accepted'] | ['s908674472', 's774107191'] | [3064.0, 3064.0] | [19.0, 19.0] | [295, 295] |
p03804 | u728498511 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['from sys import exit\nn, m = map(int, input().split())\ns1 = " ".join([input() for _ in range(n)])\ns2 = [input() for _ in range(m)]\nflag = True\n\ni = 0\nwhile i < m:\n try:\n if s1.count(s2[i]) == 0:\n print("No")\n exit()\n ind = s1.index(s2[i])\n s1 = list(s1)\n del s1[ind]\n s1 = "".join(s1)\n if s1[ind+n+1:ind+n+m+1:] == s2[i+1]:\n i += 1\n except:\n print("No")\n exit()\nprint("Yes")', 'from sys import exit\nn, m = map(int, input().split())\ns1 = " ".join([input() for _ in range(n)])\ns2 = [input() for _ in range(m)]\nflag = True\n\ni = 0\nwhile i < m:\n #try:\n if s1.count(s2[i]) == 0:\n print("No")\n exit()\n ind = s1.index(s2[i])\n s1 = list(s1)\n del s1[ind]\n s1 = "".join(s1)\n if s1[ind+n+1:ind+n+m+1:] == s2[i+1]:\n i += 1\n #except:\n """print("No")\n exit()"""\nprint("Yes")', 'n, m = map(int, input().split())\na = [input() for i in range(n)]\nb = [input() for i in range(m)]\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if a[i][j] == b[0][0]:\n cnt = 0\n for k in range(m):\n if a[i+k][j:j+m] == b[k]: cnt+=1\n if cnt == m:\n print("Yes")\n exit()\nprint("No")'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s125317860', 's823279128', 's086288132'] | [3064.0, 3064.0, 3064.0] | [20.0, 20.0, 20.0] | [468, 476, 367] |
p03804 | u729133443 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["t,*a=open(0);n,m=map(int,t.split());r=range(n-m+1);print('YNeos'[all(a[n:]!=[t[j:j+m]for t in a[i:i+m]]for i in r for j in r)::2])", "t,*a=open(0);n,m=map(int,t.split());r=range(n-m+1);print('YNeos'[all(a[n:-1]!=[t[j:j+m]for t in a[i:i+m]]for i in r for j in r)::2])", "n,m,*a=open(0).read().split();n,m=int(n),int(m);r=range(n-m+1);print('YNeos'[all(a[n:]!=[t[j:j+m]for t in a[i:i+m]]for i in r for j in r)::2])"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s952359924', 's972821018', 's195237251'] | [3060.0, 3060.0, 2940.0] | [20.0, 20.0, 20.0] | [130, 132, 142] |
p03804 | u732870425 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int, input().split())\nA = [input() for _ in range(N)]\nB = [input() for _ in range(M)]\n\nfor y in range(N-M+1):\n for x in range(N-M+1):\n for k in range(M):\n if A[y+k][x:x+M] != B[y]:\n break\n else:\n print("Yes")\n exit()\nprint("No")', 'import sys\n\nN, M = map(int, input().split())\nA = [input() for _ in range(N)]\nB = [input() for _ in range(M)]\n\nfor y in range(N-M+1):\n for x in range(N-M+1):\n for k in range(M):\n if A[y+k][x:x+M] != B[k]:\n break\n else:\n print("Yes")\n sys.exit()\nprint("No")'] | ['Runtime Error', 'Accepted'] | ['s730365893', 's162691805'] | [3060.0, 3064.0] | [17.0, 18.0] | [304, 320] |
p03804 | u734876600 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m = map(int,input().split())\na = []\nb = []\nfl = False\nfor i in range(n):\n a.append(list(input()))\nfor i in range(m):\n b.append(list(input()))\nfor i in range(n - m + 1):\n if b[0] in a[i]:\n tmp = a[i].find(b[0])\n if m == 1:\n fl = True\n for j in range(1,m):\n if a[i+j][tmp:tmp+m] != b[j]:\n fl = False\n break\n fl = True\n if fl:\n break\n if fl:\n print("Yes")\nelse:\n print("No")', 'n,m = map(int,input().split())\na = []\nb = []\nfl = False\nfor i in range(n):\n a.append(list(input()))\nfor i in range(m):\n b.append(list(input()))\nfor i in range(n - m + 1):\n if b[0] in a[i]:\n tmp = a[i].find(b[0])\n if m == 1:\n fl = True\n for j in range(1,m):\n if a[i+j][tmp:tmp+m] != b[j]:\n fl = False\n break\n fl = True\n if fl:\n break\nif fl:\n print("Yes")\nelse:\n print("No")', 'n,m = map(int,input().split())\na = [input() for _ in range(n)]\nb = [input() for _ in range(m)]\nfl = False\nfor i in range(n - m + 1):\n if b[0] in a[i]:\n tmp = a[i].find(b[0])\n if m == 1:\n fl = True\n for j in range(1,m):\n if a[i+j][tmp:tmp+m] != b[j]:\n fl = False\n break\n fl = True\n if fl:\n break\nif fl:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s047192937', 's295325465', 's761663300'] | [3064.0, 3064.0, 3064.0] | [17.0, 18.0, 17.0] | [489, 481, 437] |
p03804 | u735069283 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["import numpy as np\nN,M = map(int,input().split())\nA = np.array([list(input()) for _ in range(N)])\nB = np.array([list(input()) for _ in range(M)])\n\nhantei = False\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if (A[i:M+i,j:M+j] == B).all:\n hantei = True\n print(A[i:M+i,j:M+j])\nprint('Yes' if hantei else'No')", "import numpy as np\nN,M = map(int,input().split())\nA = np.array([list(input()) for _ in range(N)])\nB = np.array([list(input()) for _ in range(M)])\n\nhantei = False\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n C=np.array(A[i:i+M,j:j+M])\n if (C==B).all():\n hantei = True\nprint('Yes' if hantei else 'No')"] | ['Wrong Answer', 'Accepted'] | ['s777552449', 's579989623'] | [15104.0, 12432.0] | [846.0, 176.0] | [324, 315] |
p03804 | u736729525 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = [int(x) for x in input().split()]\n\nA = [None]*N\nfor i in range(N):\n A[i] = input()\n\nB = [None]*M\nfor i in range(M):\n B[i] = input()\n\ndef check():\n for x in range(N-M+1):\n for y in range(N-M+1):\n if all(all(A[r+x][c+y] == B[r][c] for c in range(M)) for r range(M))\n return "Yes"\n return "No"\nprint(check())\n\n', 'M, N = [int(x) for x in input().split()]\n\nA = [None]*N\nfor i in range(N):\n A[i] = input()\n\nB = [None]*M\nfor i in range(M):\n B[i] = input()\n\ndef check():\n for x in range(N-M+1):\n for y in range(N-M+1):\n for r in range(M):\n if all(A[r+x][c+y] == B[r][c] for c in range(M)):\n return "Yes"\n return "No"\nprint(check())\n\n', 'N, M = [int(x) for x in input().split()]\n\nA = [None]*N\nfor i in range(N):\n A[i] = input()\n\nB = [None]*M\nfor i in range(M):\n B[i] = input()\n\ndef check():\n for x in range(N-M+1):\n for y in range(N-M+1):\n match = True\n for r in range(M):\n if not all(A[r+x][c+y] == B[r][c] for c in range(M)):\n match = False\n break\n if match:\n return "Yes"\n\n return "No"\nprint(check())\n\n'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s195289111', 's312831739', 's870423773'] | [2940.0, 3064.0, 3064.0] | [17.0, 18.0, 19.0] | [359, 379, 487] |
p03804 | u748311048 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n, m = map(int, input().split())\na = list()\nfor _ in range(n):\n a.append(str(input()))\nb = list()\nfor _ in range(m):\n b.append(str(input()))\n\nfor H in range(n if m == 1 else n-m+1):\n for W in range(n if m == 1 else n-m+1):\n for M in range(m):\n cnt = 0\n if a[H+M][0+W:m+W] == b[M]:\n cnt+=1\n if cnt==m:\n print('Yes')\n exit()\n\nprint('No')\n", "n, m = map(int, input().split())\na = list()\nfor _ in range(n):\n a.append(str(input()))\nb = list()\nfor _ in range(m):\n b.append(str(input()))\n\nfor H in range(n if m == 1 else n-m+1):\n for W in range(n if m == 1 else n-m+1):\n cnt = 0\n for M in range(m):\n if a[H+M][0+W:m+W] == b[M]:\n cnt+=1\n if cnt==m:\n print('Yes')\n exit()\n\nprint('No')\n"] | ['Wrong Answer', 'Accepted'] | ['s898631226', 's213173314'] | [3064.0, 3064.0] | [23.0, 23.0] | [418, 414] |
p03804 | u757030836 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m = map(int,input().split())\na = [[str(i) for i in input()]for _ in range(n)]\nb = [[str(i) for i in input()]for _ in range(m)]\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n c =0\n for k in range(m):\n for l in range(m):\n if a[i+k][j+l] == b[k][l]:\n c +=1\n print(c)\n \n print(c)\n if c == m**2:\n print("Yes")\n exit()\n \n \n \nprint("No")', 'n,m = map(int,input().split())\na = [[str(i) for i in input()]for _ in range(n)]\nb = [[str(i) for i in input()]for _ in range(m)]\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n c =0\n for k in range(m):\n for l in range(m):\n if a[i+k][j+l] == b[k][l]:\n c +=1\n \n \n \n if c == m**2:\n print("Yes")\n exit()\n \n \n \nprint("No")\n\n'] | ['Wrong Answer', 'Accepted'] | ['s450540513', 's741608373'] | [4240.0, 3064.0] | [284.0, 151.0] | [411, 397] |
p03804 | u757117214 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N,M=map(int,input().split())\na=[]\nfor i in range(N):\n a.append([i for i in input()])\nb=[]\nfor i in range(M):\n b.append([i for i in input()]) \nflg=True\nfor iS in range(0,N-M+1):\n for ie in range(iS,M):\n flg=True \n for js in range(0,N-M+1):\n for je in range(js,M):\n print(a[ie][je],b[ie][je])\n if a[ie][je]!=b[ie][je]:\n flg=False\n break\nprint(flg) ', 'n,m=map(int,input().split())\na=[]\nfor i in range(n):\n a.append([i for i in input()])\nb=[]\nb_flg=False\n\nfor i in range(m):\n b.append([i for i in input()])\n \nfor i in range(n-m+1):\n flg=True\n if b_flg:\n break\n for j in range(n-m+1):\n if not flg:\n break\n for k in range(m):\n if not flg:\n break\n for l in range(m):\n if a[i+k][j+l]==b[k][l]:\n flg=True\n else:\n flg=False\n if flg:\n b_flg=True\n break\nif b_flg:\n print("YES")\nelse:\n print("NO")\n \n ', 'n,m=map(int,input().split())\na=[]\nfor i in range(n):\n a.append([i for i in input()])\nb=[]\nb_flg=False\n\nfor i in range(m):\n b.append([i for i in input()])\n \nfor i in range(n-m+1):\n flg=True\n if b_flg:\n break\n for j in range(n-m+1):\n if not flg:\n break\n for k in range(m):\n if not flg:\n break\n for l in range(m):\n if a[i+k][j+l]==b[k][l]:\n flg=True\n else:\n flg=False\n if flg:\n b_flg=True\n break\nif b_flg:\n print("Yes")\nelse:\n print("No")\n \n '] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s281371328', 's294469653', 's867525858'] | [3824.0, 3064.0, 3064.0] | [40.0, 17.0, 18.0] | [397, 537, 537] |
p03804 | u757274384 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m = map(int, input().split())\n\nA = [input() for i in range(n)]\nB = [intpu() for j in range(m)]\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if A[i][j:j+m] == B[0]:\n if all(A[i+k][j:j+m] == B[k] for k in range(1,M)):\n print("Yes")\n exit()\nprint("No")', 'n,m = map(int, input().split())\n\nA = [input() for i in range(n)]\nB = [input() for j in range(m)]\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if A[i][j:j+m] == B[0]:\n if all(A[i+k][j:j+m] == B[k] for k in range(1,M)):\n print("Yes")\n exit()\nprint("No")\n', 'n,m = map(int, input().split())\n\nA = [input() for i in range(n)]\nB = [input() for j in range(m)]\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if A[i][j:j+m] == B[0]:\n if all(A[i+k][j:j+m] == B[k] for k in range(1,m)):\n print("Yes")\n exit()\nprint("No")\n'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s052707846', 's409589723', 's300232125'] | [3064.0, 3064.0, 3060.0] | [18.0, 18.0, 18.0] | [278, 279, 279] |
p03804 | u759412327 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import numpy as np\n\nN,M = map(int,input().split())\nA = np.array([list(input()) for i in range(N)])\nB = np.array([list(input()) for i in range(M)])\nf = 0\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if (A[i:i+M,j:j+M]==B).all():\n f = 1\n\nif f:\n print("Yes"):\nelse:\n print("No")', 'import numpy as np\nN,M = map(int,input().split())\nA = np.array([list(input()) for n in range(N)])\nB = np.array([list(input()) for m in range(M)])\na = "No"\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if (A[i:i+M,j:j+M]==B).all():\n a = "Yes"\n\nprint(a)'] | ['Runtime Error', 'Accepted'] | ['s750719488', 's785246803'] | [2940.0, 27088.0] | [17.0, 122.0] | [290, 263] |
p03804 | u759482921 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import sys\n\ninput_num = input().split()\nN = int(input_num[0])\nM = int(input_num[1])\n\nAB = [input() for i in range(0, N + M)]\nA = AB[0: N]\nB = AB[N:]\n\ndiff = N - M\nmatches = []\nfor i in range(0, diff+1):\n l = 0\n while N - l > diff:\n index = A[i][l:].find(B[0])\n if index != -1 and i <= diff:\n matches.append((index, l, i))\n l += 1\nif len(matches) == 0:\n print("No")\n sys.exit()\nprint(matches)\ncount_no = []\nfor m, l, i in matches:\n for a, b in zip(A[i:], B):\n if a[l:].find(b) != m:\n count_no.append(0)\n break\nif len(count_no) == len(matches):\n print("No")\nelse:\n print("Yes")', 'import sys\n\ninput_num = input().split()\nN = int(input_num[0])\nM = int(input_num[1])\n\nAB = [input() for i in range(0, N + M)]\nA = AB[0: N]\nB = AB[N:]\n\ndiff = N-M+1\ntop = 0\nind = 0\nfor i in range(0, diff):\n print(i)\n ind = A[i].find(B[0])\n if ind != -1:\n top += i\n break\nelse:\n print("No")\n sys.exit()\nfor i in range(0, len(B)):\n if A[i + top].find(B[i]) != ind:\n print("No")\n break\nelse:\n print("Yes")', 'import sys\ninput_num = input().split()\nN = int(input_num[0])\nM = int(input_num[1])\n\nAB = [input() for i in range(0, N + M)]\nA = AB[0: N]\nB = AB[N:]\n\ndiff = N - M\nmatches = []\nfor i in range(0, diff+1):\n l = 0\n while N - l > diff:\n index = A[i][l:].find(B[0])\n if index != -1 and i <= diff:\n matches.append((index, l, i))\n l += 1\nif len(matches) == 0:\n print("No")\n sys.exit()\ncount_no = []\nfor m, l, i in matches:\n for a, b in zip(A[i:], B):\n if a[l:].find(b) != m:\n count_no.append(0)\n break\nif len(count_no) == len(matches):\n print("No")\nelse:\n print("Yes")'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s605086818', 's949129795', 's671320294'] | [3064.0, 3064.0, 3064.0] | [19.0, 17.0, 18.0] | [657, 449, 641] |
p03804 | u761320129 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["N,M = map(int,input().split())\nA = [input() for i in range(N)]\nB = [input() for i in range(M)]\n\ndef match(ofs_x, ofs_y):\n for ar,br in zip(A[ofs_y:], B):\n if ar[ofs_x:] != br:\n return False\n return True\n\nfor y in range(N-M+1):\n for x in range(N-M+1):\n if match(x,y):\n print('YES')\n exit()\nprint('NO')", "N,M = map(int,input().split())\nA = [input() for i in range(N)]\nB = [input() for i in range(M)]\n\ndef match(ofs_x, ofs_y):\n for ar,br in zip(A[ofs_y:], B):\n if ar[ofs_x : ofs_x + M] != br:\n return False\n return True\n\nfor y in range(N-M+1):\n for x in range(N-M+1):\n if match(x,y):\n print('Yes')\n exit()\nprint('No')"] | ['Wrong Answer', 'Accepted'] | ['s263500234', 's813281005'] | [3064.0, 3064.0] | [19.0, 18.0] | [356, 367] |
p03804 | u762420987 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int, input().split())\nAlist = [list(input()) for _ in range(N)]\nBlist = [list(input()) for _ in range(M)]\nfrom sys import exit\nfor i in range(N - M):\n for j in range(N - M):\n if Alist[i:i + M][j:j + M] == Blist:\n print("Yes")\n exit()\nprint("No")\n', 'N, M = map(int, input().split())\nA = [list(input()) for _ in range(N)]\nB = [list(input()) for _ in range(M)]\ndef check(dx, dy):\n cut_A = [[] for _ in range(M)]\n for i in range(dx, dx + M):\n for j in range(dy, dy + M):\n cut_A[i-dx].append(A[i][j])\n return cut_A == B\n\nfor dx in range(N-M+1):\n for dy in range(N-M+1):\n if check(dx, dy):\n print("Yes")\n exit()\nprint("No")\n'] | ['Wrong Answer', 'Accepted'] | ['s804145904', 's263906365'] | [3060.0, 3064.0] | [18.0, 80.0] | [289, 428] |
p03804 | u766407523 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["N, M = map(int, input().split())\nA, B = [], []\nfor i in range(N):\n A.append(input())\nfor i in range(M):\n B.append(input())\nans = 'No'\nend = 0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n temp = []\n for k in range(1, M):\n temp.append(A[i+k][j:])\n if temp == B:\n ans = 'Yes'\n end = 1\n break\n if end == 1:\n break\nprint(ans)", "N, M = map(int, input().split())\nA, B = [], []\nfor i in range(N):\n A.append(input())\nfor i in range(M):\n B.append(input())\nans = 'No'\nend = 0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n temp = []\n for k in range(M):\n temp.append(A[i+k][j:j+M])\n if temp == B:\n ans = 'Yes'\n end = 1\n break\n if end == 1:\n break\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s329482483', 's527097522'] | [3064.0, 3064.0] | [22.0, 23.0] | [407, 407] |
p03804 | u766646838 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["N,M = map(int,input().split())\na = []\nc = []\nfor i in range(N):\n b = list(input())\n a+=b\nfor i in range(M):\n b = list(input())\n c+=b\nf = False\nfor i in range(N*N):\n if f == True:\n break\n count=0\n if N*N-(i)<M*M:\n break\n flag = True\n if c[0] == a[i]:\n if N-((i+1)%N)>M:\n continue\n num = i\n for j in range(M):\n for k in range(M):\n print(c[count],a[num])\n if c[count] == a[num]:\n \n num+=1\n count+=1\n elif c[count]!=a[num]:\n flag =False\n break\n num+=N-M\n if flag == False:\n print(i)\n break \n if j == M-1:\n f = True\n \n else:\n continue\nif f == False:\n print('No')\nelse:\n print('Yes')", "N,M = map(int,input().split())\na = []\nc = []\nfor i in range(N):\n b = list(input())\n a+=b\nfor i in range(M):\n b = list(input())\n c+=b\n#print(c,a)\nf = False\nfor i in range(N*N):\n if f == True:\n break\n if N*N-i<M*M:\n break\n if M>1 and i//N==N-1:\n break\n count=0\n flag = True\n #print(i,c[0],a[i])\n if c[0] == a[i]:\n if N-((i)%N)<M:\n continue\n num = i\n for j in range(M):\n for k in range(M):\n #print(c[count],a[num])\n if c[count] == a[num]:\n \n num+=1\n count+=1\n elif c[count]!=a[num]:\n flag =False\n break\n num+=N-M\n if flag == False:\n #print(i)\n break \n if j == M-1:\n f = True\n \n else:\n continue\nif f == False:\n print('No')\nelse:\n print('Yes')\n \n "] | ['Wrong Answer', 'Accepted'] | ['s325616967', 's078203819'] | [9176.0, 9296.0] | [23.0, 30.0] | [735, 818] |
p03804 | u777923818 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['# -*- coding: utf-8 -*-\nA = []\nB = []\nN, M = list(map(int, input().split()))\n\nfor n in range(N):\n A.append(input())\nfor n in range(M):\n B.append(input())\n\ndef match(r, c):\n for i, row in enumerate(range(r, r+M)):\n if A[row][c:c+M] != B[i]:\n return False\n return True\n\nok = 0\n\nfor r in range(N-M+1):\n if ok == 0:\n for c in range(N-M+1):\n if match(r, c):\n print("YES")\n ok = 1\n \nif not ok:\n print("No")', '# -*- coding: utf-8 -*-\nA = []\nB = []\nN, M = list(map(int, input().split()))\n\nfor n in range(N):\n A.append(input())\nfor n in range(M):\n B.append(input())\n\ndef match(r, c):\n for i, row in enumerate(range(r, r+M)):\n# print("{} : {} {}".format(A[row][c:c+M], B[i], A[row][c:c+M]==B[i]))\n if A[row][c:c+M] != B[i]:\n return False\n return True\n\nok = 0\n\nfor r in range(N-M+1):\n if ok == 1:\n break\n else:\n for c in range(N-M+1):\n if match(r, c):\n print("YES")\n ok = 1\n break\n \nif not ok:\n print("No")', '# -*- coding: utf-8 -*-\nA = []\nB = []\nN, M = list(map(int, input().split()))\n\nfor n in range(N):\n A.append(input())\nfor n in range(M):\n B.append(input())\n\ndef match(r, c):\n for i, row in enumerate(range(r, r+M)):\n# print("{} : {} {}".format(A[row][c:c+M], B[i], A[row][c:c+M]==B[i]))\n if A[row][c:c+M] != B[i]:\n return False\n return True\n\nok = 0\n\nfor r in range(N-M+1):\n if ok == 1:\n break\n else:\n for c in range(N-M+1):\n if match(r, c):\n print("Yes")\n ok = 1\n break\n \nif not ok:\n print("No")'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s774742212', 's998427160', 's511187640'] | [3064.0, 3064.0, 3064.0] | [18.0, 18.0, 18.0] | [495, 620, 620] |
p03804 | u778814286 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["N, M = map(int,input().split())\n\ntg = [list(map(int,input().split())) for _ in range(N)]\n\n\ntmpl = [list(map(int,input().split())) for _ in range(M)]\n\n\nfor i in range(0,N-M+1):\n for j in range(0,N-M+1):\n if tmpl[0] == tg[i][j:j+M]:\n for k in range(i+1,i+M):\n if tmpl[k] != tg[i+k][j:j+M]: break\n else:\n print('Yes')\n exit()\nprint('No')", "N, M = map(int,input().split())\n\ntg = [input() for _ in range(N)]\n\n\ntmpl = [input() for _ in range(M)]\n\n\nfor i in range(0,N-M+1):\n for j in range(0,N-M+1):\n if tmpl[0] == tg[i][j:j+M]:\n if N == 1:\n print('Yes')\n exit()\n for k in range(1,M):\n if tmpl[k] != tg[i+k][j:j+M]: break\n else:\n print('Yes')\n exit()\nprint('No')\n"] | ['Runtime Error', 'Accepted'] | ['s994638011', 's260751137'] | [3064.0, 3064.0] | [17.0, 18.0] | [468, 472] |
p03804 | u779455925 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['4 1\n....\n....\n....\n....\n#\n', 'N,M=map(int,input().split())\nA=[input() for i in range(N)]\nB=[input() for i in range(M)]\n\nfor X in range(N-M+1):\n for Y in range(N-M+1):\n flag=1\n for x in range(M):\n for y in range(M):\n if B[x][y]!=A[x+X][y+Y]:\n flag=0\n break\n if not flag:\n break\n if flag:\n print("Yes")\n exit()\nprint("No")\n'] | ['Runtime Error', 'Accepted'] | ['s850708566', 's957535220'] | [2940.0, 3060.0] | [18.0, 18.0] | [26, 427] |
p03804 | u787562674 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int, input().split())\n\n\n\nA = [input() for j in range(N)]\nB = [input() for j in range(M)]\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n if A[i+k][j:j+k] != B[k]:\n break\n else:\n print("Yes")\n exit()\nelse:\n print("No")', 'N, M = map(int, input().split())\n\n\n\nA = [input() for j in range(N)]\nB = [input() for j in range(M)]\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n if A[i+k][j:j+M] != B[k]:\n break\n else:\n print("Yes")\n exit()\nelse:\n print("No")'] | ['Wrong Answer', 'Accepted'] | ['s343325885', 's441926970'] | [3064.0, 3060.0] | [18.0, 18.0] | [429, 429] |
p03804 | u790710233 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n, m = map(int, input().split())\n\nclass Image:\n def __init__(self, n):\n self.matrix = [list(input()) for _ in range(n)]\n self.n = n\n\n def isIncluded(self, a):\n for i in range(a.n):\n for j in range(a.n):\n if a.matrix[i][j] == self.matrix[0][0]:\n if j+self.n <= a.n and i+self.n <= a.n:\n template = [a.matrix[i+k][j:j+self.n]\n for k in range(self.n)]\n print(template)\n if template == self.matrix:\n return True\n return False\n\n\na = Image(n)\nb = Image(m)\n\nprint("Yes" if b.isIncluded(a) else "No")\n', 'n, m = map(int, input().split())\n\nclass Image:\n def __init__(self, n):\n self.matrix = [list(input()) for _ in range(n)]\n self.n = n\n\n def isIncluded(self, a):\n for i in range(a.n-self.n+1):\n for j in range(a.n-self.n+1):\n template = [row[j:j+self.n] for row in a.matrix[i:i+self.n]]\n if template == self.matrix:\n return True\n return False\n\n\na = Image(n)\nb = Image(m)\n\nprint("Yes" if b.isIncluded(a) else "No")\n'] | ['Wrong Answer', 'Accepted'] | ['s607972061', 's117384538'] | [4084.0, 3064.0] | [37.0, 22.0] | [703, 504] |
p03804 | u798260206 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["A=[input() for _ in range(N)]\nB=[input() for _ in range(M)]\nans='No'\n \nfor i in range(N-M+1):\n for j in range(N-M+1):\n cnt=0\n if A[i][j:j+M] ==B[0]:\n for k in range(1,M):\n if A[i+k][j:j+M] == B[k]:\n cnt+=1\n if cnt==M-1:\n ans='Yes'\n \nprint(ans)", "N,M=map(int,input().split())\nA=[input() for _ in range(N)]\nB=[input() for _ in range(M)]\nans='No'\n \nfor i in range(N-M+1):\n for j in range(N-M+1):\n cnt=0\n if A[i][j:j+M] ==B[0]:\n for k in range(1,M):\n if A[i+k][j:j+M] == B[k]:\n cnt+=1\n if cnt==M-1:\n ans='Yes'\n \nprint(ans)"] | ['Runtime Error', 'Accepted'] | ['s493082000', 's988583140'] | [3064.0, 3064.0] | [17.0, 18.0] | [346, 375] |
p03804 | u798818115 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['# coding: utf-8\n# Your code here!\nN,M=map(int,input().split())\n\nAN=[]\nfor _ in range(N):\n AN.append(list(input()))\n \nprint(AN)\n\nAM=[]\nfor _ in range(M):\n AM.append(list(input()))\n\nprint(AM)\n', '# coding: utf-8\n# Your code here!\nN,M=map(int,input().split())\n\nAN=[]\nfor _ in range(N):\n AN.append(list(input()))\n \n#print(AN)\n\nAM=[]\nfor _ in range(M):\n AM.append(list(input()))\n\n#print(AM)\nfor i in range(N-M+1):\n for j in range(N-M+1):\n #print(i,j)\n flag=True\n for k in range(M):\n if AN[i+k][j:j+M]!=AM[k]:\n \n flag=False\n if flag:\n print("Yes")\n exit()\n \nprint("No")'] | ['Wrong Answer', 'Accepted'] | ['s032213968', 's410740735'] | [3060.0, 3064.0] | [18.0, 26.0] | [199, 507] |
p03804 | u803647747 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int, input().split())\nA_list = []\nB_list = []\n\nfor _ in range(N):\n A_list.append(list(input()))\nfor _ in range(M):\n B_list.append(list(input()))\n \nmatch_list =[]\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if B_list[0] == A_list[i][j:(j+M)]:\n match_list.append([i, j])\n else:\n pass\n\nflag =0\nfor k in match_list:\n flag =0\n for l in range(M):\n print(A_list[k[0]+l][k[1]:k[1]+M])\n print(B_list[k[0]+l])\n \n if A_list[k[0]+l][k[1]:k[1]+M] ==B_list[k[0]+l]:\n flag += 1\n else:\n break\n \n if flag == M:\n print("Yes")\n break', 'N, M = map(int, input().split())\nA_list=[input()for i in range(N)]\nB_list=[input()for i in range(M)]\n\nwhole_flag = 0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n flag = 0\n for k in range(M):\n if B_list[k] == A_list[i+k][j:j+M]:\n flag += 1\n else:\n pass\n if flag == M:\n whole_flag += 1\n \nprint("Yes" if whole_flag >0 else "No")'] | ['Runtime Error', 'Accepted'] | ['s144589650', 's845623792'] | [3064.0, 3060.0] | [18.0, 23.0] | [658, 426] |
p03804 | u814986259 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N,M=map(int,input.split())\nA=[""]*N\nB=[""]*M\nfor i in range(N):\n A[i]=input()\nfor i in range(M):\n B[i]=input()\nflag=False\nfor i in range(N-M)\n if B[0] in A[i]:\n for j in range(1,M):\n if B[j] in A[i+j]:\n if j = M - 1:\n print("Yes")\n exit(0)\n else:\n continue\n else:\n break\n \nprint("No")', 'N,M=map(int,input.split())\nA=[""]*N\nB=[""]*M\nfor i in range(N):\n A[i]=input()\nfor i in range(M):\n B[i]=input()\n \nfor i in range(N-M):\n if B[0] in A[i]:\n for j in range(1,M):\n if B[j] in A[i+j]:\n if j = M - 1:\n print("Yes")\n exit(0)\n else:\n continue\n else:\n break\n \nprint("No")', 'N,M=map(int,input().split())\nA=[""]*N\nB=[""]*M\nfor i in range(N):\n A[i]=input()\nfor i in range(M):\n B[i]=input()\n \nA_tmp=[""]*M\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n A_tmp[k]=A[j+k][i:i+M]\n if A_tmp==B:\n print("Yes")\n exit(0)\n\nprint("No")'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s023063773', 's061072848', 's621025177'] | [2940.0, 2940.0, 3064.0] | [17.0, 17.0, 23.0] | [377, 370, 293] |
p03804 | u820357030 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = (int(i) for i in input().split())\na = []\nb = []\nfor i in range(N):\n data = list(input())\n a.append(data)\nfor i in range(M):\n data = list(input())\n b.append(data)\n\nprint(a[0])\n \nL = N-M\n\ndef check(i,j):\n ans=True\n for line in range(L+1):\n for row in range(L+1):\n if (a[i+line][j+row]!=b[line][row]):\n ans=False\n return ans\n \nfor i in range(L+1):\n for j in range(L+1):\n ans=check(i,j)\n print(ans)\n', "N, M = (int(i) for i in input().split())\na = []\nb = []\nfor i in range(N):\n data = list(input())\n a.append(data)\nfor i in range(M):\n data = list(input())\n b.append(data)\n\n#N=4\n#M=2\n#a=[['a','s','a','s'],['a','a','s','s'],['s','a','a','s'],['s','a','a','a']]\n#b=[['s','a'],['a','s']]\n\nL = N-M\n\ndef check(i,j):\n ans=True\n for line in range(M):\n if (ans==False):\n break\n for row in range(M):\n if (a[i+line][j+row]!=b[line][row]):\n ans=False\n break\n return ans\n\nans=False\nfor i in range(L+1):\n if(ans==True):\n break\n for j in range(L+1):\n ansnow=check(i,j)\n # print(ansnow,i,j)\n if(ansnow==True):\n ans=True\n break\nif(ans==True):\n print('Yes')\nelse:\n print('No')\n "] | ['Wrong Answer', 'Accepted'] | ['s836623719', 's399170606'] | [3064.0, 3064.0] | [23.0, 25.0] | [491, 809] |
p03804 | u841623074 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N,M=map(int,input().split())\nA=[input()for i in range(N)]\nB=[input()for i in range(M)]\nb=\'\'\na=\'no\'\nfor i in range(M):\n b+=B[i]\nfor i in range(N-M+2):\n if B[0]in A[0] and B[1] in A[1]:\n for j in range(N-M+2):\n a=\'\'\n for k in range(M):\n a+=A[i+k][j:j+M]\n if a==b:\n print("Yes")\n exit()\nprint("No")', 'N,M=map(int,input().split())\nA=[input()for i in range(N)]\nB=[input()for i in range(M)]\nb=\'\'\na=\'no\'\nfor i in range(M):\n b+=B[i]\nprint(b)\nfor i in range(N-M+1):\n if B[0]in A[i] and B[1] in A[i+1]:\n for j in range(N-M+1):\n a=\'\'\n for k in range(M):\n a+=A[i+k][j:j+M]\n if a==b:\n print("Yes")\n exit()\nprint("No") \n', 'N,M=map(int,input().split())\nA=[input()for i in range(N)]\nB=[input()for i in range(M)]\nb=\'\'\na=\'no\'\nfor i in range(M):\n b+=B[i]\nfor i in range(N-M+1):\n if B[0]in A[i] and B[1] in A[i+1]:\n for j in range(N-M+2):\n a=\'\'\n for k in range(M):\n a+=A[i+k][j:j+M]\n if a==b:\n print("Yes")\n exit()\nprint("No")', 'N,M=map(int,input().split())\nA=[input()for i in range(N)]\nB=[input()for i in range(M)]\nb=\'\'\na=\'no\'\nfor i in range(M):\n b+=B[i]\nfor i in range(N-M+1):\n if B[0]in A[i] :\n for j in range(N-M+1):\n a=\'\'\n for k in range(M):\n a+=A[i+k][j:j+M]\n if a==b:\n print("Yes")\n exit()\nprint("No") \n'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s071990011', 's577030329', 's689738827', 's522810004'] | [3064.0, 3064.0, 3064.0, 3064.0] | [20.0, 18.0, 21.0, 19.0] | [362, 399, 364, 372] |
p03804 | u842388336 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import numpy as np\n\nn,m=map(int,input().split())\na=np.zeros([n,n])\nb=np.zeros([m,m])\nmap_ = {".":1,"#":-1}\n\nfor i in range(n):\n temp = list(input())\n temp = [map_[c] for c in temp]\n a[i,:] = np.array(temp)\n \nfor i in range(m):\n temp = list(input())\n temp = [map_[c] for c in temp]\n b[i,:] = np.array(temp)\n\nflag=False\nfor i in range(n-m+1):\n for j in range(n-m+1):\n temp_a = a[i:i+m,j:j+m]\n print(temp_a)\n check=np.sum(temp_a*b,axis=1)\n check=np.sum(check,axis=0)\n print(check)\n if check==m*m:\n flag=True\n break\n else:\n pass\nif flag:\n print("Yes")\nelse:\n print("No")', 'import numpy as np\n\nn,m=map(int,input().split())\na=np.zeros([n,n])\nb=np.zeros([m,m])\nmap_ = {".":1,"#":-1}\n\nfor i in range(n):\n temp = list(input())\n temp = [map_[c] for c in temp]\n a[i,:] = np.array(temp)\n \nfor i in range(m):\n temp = list(input())\n temp = [map_[c] for c in temp]\n b[i,:] = np.array(temp)\n\nflag=False\nfor i in range(n-m+1):\n for j in range(n-m+1):\n temp_a = a[i:i+m,j:j+m]\n check=np.sum(temp_a*b,axis=1)\n check=np.sum(check,axis=0)\n if check==m*m:\n flag=True\n break\n else:\n pass\nif flag:\n print("Yes")\nelse:\n print("No")'] | ['Wrong Answer', 'Accepted'] | ['s497398109', 's835409319'] | [12756.0, 12516.0] | [2110.0, 202.0] | [612, 577] |
p03804 | u845937249 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["import sys\nif sys.platform == 'ios':\n\tsys.stdin = open('input_file.txt')\n\t\n\nn,m = map(int,input().split())\n\na = [str(input()) for i in range(n)]\nb = [str(input()) for i in range(m)]\n\ns = [ [0]*m for i in range(m) ]\n\nans = 0\n\nfor i in range(n-m+1):\n\tfor j in range(n-m+1):\n\t\tfor k in range(m):\n\t\t\t#print(i,j,k)\n\t\t\ts[k] = a[i+k][j:j+m]\n\t\t#print(s)\n\t\t\n\t\tif s == b :\n\t\t\tprint(i,j,s)\n\t\t\tans = ans +1\n\nprint('Yes' if ans >= 1 else 'No')\n\t\t\t\n", "import sys\nif sys.platform == 'ios':\n\tsys.stdin = open('input_file.txt')\n\t\n\nn,m = map(int,input().split())\n\na = [str(input()) for i in range(n)]\nb = [str(input()) for i in range(m)]\n\ns = [ [0]*m for i in range(m) ]\n\nans = 0\n\nfor i in range(n-m+1):\n\tfor j in range(n-m+1):\n\t\tfor k in range(m):\n\t\t\t#print(i,j,k)\n\t\t\ts[k] = a[i+k][j:j+m]\n\t\t#print(s)\n\t\t\n\t\tif s == b :\n\t\t\t#print(i,j,s)\n\t\t\tans = ans +1\n\nprint('Yes' if ans >= 1 else 'No')\n\t\t\t\n"] | ['Wrong Answer', 'Accepted'] | ['s515712568', 's511142054'] | [3064.0, 3064.0] | [23.0, 23.0] | [435, 436] |
p03804 | u853900545 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n,m = map(int,input().split())\n\na = []\nb = []\n\nfor i in range(n):\n a.append(input())\nfor i in range(m):\n b.append(input())\n\ni = 0\nk = 0\nans = 'No'\nfor k in range(n-m):\n while i + m <= n:\n if a[k][i:i+m:] == b[k]:\n for j in range(m):\n if all()\n ans = 'Yes'\n \n i += 1\nprint('No')", "def is_equal(i,j,m):\n d = 0\n for k in range(m):\n if a[i+k][0][j:j+m] == b[k][0][::]:\n d = 0\n else:\n return False\n if d == 0:\n return True\n\nn,m = map(int,input().split())\na = [0]*n\nb = [0]*m\nfor i in range(n):\n a[i] = list(input().split())\nfor i in range(m):\n b[i] = list(input().split())\n\nfor i in range(n-m+1):\n ans = 0\n for j in range(n-m+1):\n if is_equal(i,j,m):\n ans =1\n break\n if ans == 1:\n break\nif ans == 1:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Accepted'] | ['s424809420', 's315773377'] | [2940.0, 3064.0] | [18.0, 19.0] | [348, 556] |
p03804 | u856169020 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N, M = map(int, input().split())\nn = []\nm = []\nfor i in range(N):\n s = str(input())\n row = []\n for j in range(N):\n if s[i] == "#":\n row.append(1)\n else:\n row.append(0)\n n.append(row)\nfor i in range(M):\n s = str(input())\n row = []\n for j in range(M):\n if s[i] == "#":\n row.append(1)\n else:\n row.append(0)\n m.append(row)\n \ndef search(a,b):\n mr = mc = 0\n for r in range(a, a+M):\n for c in range(b, b+M):\n if n[r][c] != m[mr][mc]:\n return False\n mc += 1\n mr += 1 \n return True\n\nans = 0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if search(i,j):\n ans = 1\n break\n if ans:\n break\nif ans:\n print("Yes")\nelse:\n print("No")', 'N, M = map(int, input().split())\nn = []\nm = []\nfor i in range(N):\n s = str(input())\n row = []\n for j in range(N):\n if s[j] == "#":\n row.append(1)\n else:\n row.append(0)\n n.append(row)\nfor i in range(M):\n s = str(input())\n row = []\n for j in range(M):\n if s[i] == "#":\n row.append(1)\n else:\n row.append(0)\n m.append(row)\n \ndef search(a,b):\n mr = mc = 0\n for r in range(a, a+M):\n for c in range(b, b+M):\n if n[r][c] != m[mr][mc]:\n return False\n mc += 1\n mr += 1\n mc = 0\n return True\n\nans = 0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if search(i,j):\n ans = 1\n break\n if ans:\n break\nif ans:\n print("Yes")\nelse:\n print("No")', 'N, M = map(int, input().split())\nn = []\nm = []\nfor i in range(N):\n s = str(input())\n row = []\n for j in range(N):\n if s[j] == "#":\n row.append(1)\n else:\n row.append(0)\n n.append(row)\nfor i in range(M):\n s = str(input())\n row = []\n for j in range(M):\n if s[j] == "#":\n row.append(1)\n else:\n row.append(0)\n m.append(row)\n \ndef search(a,b):\n mr = mc = 0\n for r in range(a, a+M):\n for c in range(b, b+M):\n if n[r][c] != m[mr][mc]:\n return False\n mc += 1\n mr += 1\n mc = 0\n return True\n\nans = 0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n if search(i,j):\n ans = 1\n break\n if ans:\n break\nif ans:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s532439885', 's644709083', 's533760069'] | [3064.0, 3064.0, 3064.0] | [18.0, 18.0, 19.0] | [704, 714, 714] |
p03804 | u861141787 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n, m = map(int, input().split())\na = [list(input()) for _ in range(n)]\nb = [list(input()) for _ in range(m)]\n\nsi, sj = 0, 0\nc = 0\nwhile si < n - m:\n ni, nj = si, sj\n rest = m ** 2\n for i in range(m):\n nj = sj\n for j in range(m):\n print(ni, nj, i, j)\n if a[ni][nj] != b[i][j]:\n break\n nj +=1\n rest -= 1\n ni += 1\n print()\n if rest == 0:\n print("Yes")\n exit()\n sj += 1\n if sj > n - m:\n si += 1\n sj = 0\n\nprint("No")\n ', 'n, m = map(int, input().split())\na = [list(input()) for _ in range(n)]\nb = [list(input()) for _ in range(m)]\n\nsi, sj = 0, 0\nc = 0\nwhile si <= n - m:\n ni, nj = si, sj\n rest = m ** 2\n for i in range(m):\n nj = sj\n for j in range(m):\n \n if a[ni][nj] != b[i][j]:\n break\n nj +=1\n rest -= 1\n ni += 1\n # print()\n if rest == 0:\n print("Yes")\n exit()\n sj += 1\n if sj > n - m:\n si += 1\n sj = 0\n\nprint("No")\n '] | ['Wrong Answer', 'Accepted'] | ['s209241282', 's812178727'] | [4060.0, 3064.0] | [96.0, 34.0] | [549, 554] |
p03804 | u863841238 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m = map(int,input().split())\na=[]\nfor _ in [0]*n:\n a += [list(input())]\nb=[]\nfor _ in [0]*m:\n b += [list(input())]\n\nprint(a,b)\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if [k[j:m+1] for k in a[i:m+1]] == b:\n print("Yes")\n exit()\nprint("No")', 'n,m = map(int,input().split())\na=[]\nfor _ in [0]*n:\n a += [list(input())]\nb=[]\nfor _ in [0]*m:\n b += [list(input())]\n\nprint(a,b)\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if [k[j:m] for k in a[i:m]] == b:\n print("Yes")\n exit()\nprint("No")\n', "n,m = map(int,input().split())\na = []\nb = []\n\nfor _ in range(n):\n a += [list(input())]\nfor _ in range(m):\n b += [list(input())]\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if [k[j:m+j] for k in a[i:m+i]] == b:\n print('Yes')\n exit()\nprint('No')\n"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s505450295', 's955037671', 's426362717'] | [3064.0, 3060.0, 3064.0] | [20.0, 19.0, 22.0] | [265, 262, 287] |
p03804 | u875600867 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import re\nN,M=map(int, input().split())\n\nA=[]\nB=[]\n\nfor n in range(N):\n A.append(input())\n\nfor m in range(M):\n B.append(input())\n \n\nfor m in range(M):\n for n in range(N):\n \n \n span =[m.span() for m in re.finditer(B[m], A[n])]\n print(span)\n if span==[]:\n continue\n allgood=False\n \n if M==1:\n print("Yes")\n exit()\n for i in range(n+1, M):\n print((B[i],A[i][span[0][0]:span[0][1]]))\n if (B[i]==A[i][span[0][0]:span[0][1]]):\n allgood=True\n continue\n else:\n allgood=False\n break\n if allgood==True:\n print("Yes")\n exit()\n\nprint("No")\n\n', 'import re\nN,M=map(int, input().split())\n\nA=[]\nB=[]\n\nfor n in range(N):\n A.append(input())\n\nfor m in range(M):\n B.append(input())\n \nif N<M:\n print("No")\n exit()\n\nfor n in range(N):\n \n \n span =[m.span() for m in re.finditer(B[0], A[n])]\n #print(span)\n if span==[]:\n continue\n allgood=False\n for sp in span:\n for i in range(min(M,N)):\n if n+i>=N:\n allgood=False\n break\n #print(n)\n #print((B[i],A[n+i][span[0][0]:span[0][1]]))\n if (B[i]==A[n+i][sp[0]:sp[1]]):\n allgood=True\n continue\n else:\n allgood=False\n break\n if allgood==True:\n print("Yes")\n exit()\n\nprint("No")'] | ['Wrong Answer', 'Accepted'] | ['s793751644', 's060175288'] | [3700.0, 3188.0] | [34.0, 19.0] | [876, 880] |
p03804 | u878372089 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m = map(int,input().strip().split())\nns,ms = [],[]\nfor _ in range(n):\n ns.append(input().strip())\nfor _ in range(m):\n ms.append(input().strip())\n\nallFlag = 0\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if ns[i][j:j+m] == ms[0]:\n Flag = 1\n for k in range(m):\n if ns[i+k][j:j+m]!=ms[k]:\n Flag = 0\n if Flag:\n print("Yes")\n allFlag = 1\nif not allFlag:\n print("No")', 'n,m = map(int,input().strip().split())\nns,ms = [],[]\nfor _ in range(n):\n ns.append(input().strip())\nfor _ in range(m):\n ms.append(input().strip())\n\nallFlag = 0\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if ns[i][j:j+m] == ms[0]:\n Flag = 1\n for k in range(m):\n if ns[i+k][j:j+m]!=ms[k]:\n Flag = 0\n if Flag and not allFlag:\n print("Yes")\n allFlag = 1\nif not allFlag:\n print("No")'] | ['Wrong Answer', 'Accepted'] | ['s074879283', 's808291014'] | [3064.0, 3064.0] | [18.0, 18.0] | [482, 498] |
p03804 | u883232818 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["N, M = map(int, input().split())\n\nA = []\nB = []\n\nfor i in range(N):\n A.append(list(input()))\n\nfor i in range(M):\n B.append(list(input()))\n\nans = True\n\nfor i in range(M):\n if A[i] not in B[i]:\n ans = False\n break\n\nprint('Yes' if ans == True else 'No')", "\nN, M = map(int, input().split())\n\nA = []\nB = []\n\nfor i in range(N):\n A.append(list(input()))\n\nfor i in range(M):\n B.append(list(input()))\n\nans = True\n\nfor i in range(M):\n if not A[i] in B[i]:\n ans = False\n break\n\nprint('Yes' if ans == True else 'No')", "\nN, M = map(int, input().split())\n\nA = []\nB = []\n\nfor i in range(N):\n A.append(input())\n\nfor i in range(M):\n B.append(input())\nans = True\n\nfor i in range(M):\n if B[i] not in A[i]:\n ans = False\n break\n\nprint('Yes' if ans == True else 'No')"] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s409075570', 's416021147', 's790112829'] | [3064.0, 3064.0, 3064.0] | [19.0, 17.0, 17.0] | [273, 274, 261] |
p03804 | u884323674 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import numpy as np\n\nN, M = map(int, input().split())\nA = np.array([[i for i in input()] for j in range(N)])\nB = np.array([[i for i in input()] for j in range(M)])\n\nfound = False\nfor i in range(N-M+1):\n for j in range(N-M+1):\n P = A[i:i+M,j:j+M]\n if (P == B).all():\n print("Yes")\n found = True\n break\nif not found:\n print("No")', 'import numpy as np\n\nN, M = map(int, input().split())\nA = np.array([[i for i in input()] for j in range(N)])\nB = np.array([[i for i in input()] for j in range(M)])\n\nfound = False\nfor i in range(N-M+1):\n for j in range(N-M+1):\n P = A[i:i+M,j:j+M]\n if (P == B).all():\n print("Yes")\n found = True\n break\n if found: break\nif not found:\n print("No")'] | ['Wrong Answer', 'Accepted'] | ['s759614863', 's286497522'] | [12416.0, 12416.0] | [174.0, 166.0] | [379, 399] |
p03804 | u886655280 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["\n\nN, M = map(int, input().split())\nA_list = []\nfor n in range(N):\n a = input()\n A_list.append(a)\n\nB_list = []\nfor m in range(M):\n b = input()\n B_list.append(b)\n\ndiff = N - m\n\nfor i in range(diff):\n is_same = False\n for j in range(diff):\n for b in range(M):\n if B_list[b] == A_list[i][j: j + M]:\n is_same = True\n else:\n is_same = False\n break\n else:\n continue\n break\n\n if is_same:\n print('Yes')\n exit()\n\n else:\n continue\n\nprint('No')\n\n\n# 5 3\n# ..#..\n# ..#.#\n# .....\n# #..#.\n# .....\n# ...\n# ..#\n# #.#\n", "\n\nN, M = map(int, input().split())\nA_list = []\nfor n in range(N):\n a = input()\n A_list.append(a)\n\nB_list = []\nfor m in range(M):\n b = input()\n B_list.append(b)\n\ndiff = N - m\n\nfor i in range(diff):\n is_same = False\n for j in range(diff):\n for b in range(M):\n if B_list[b] == A_list[i + b][j: j + M]:\n is_same = True\n else:\n is_same = False\n break\n\n if is_same:\n print('Yes')\n exit()\n\n else:\n continue\n\nprint('No')\n\n\n# 5 3\n# ..#..\n# ..#.#\n# .....\n# #..#.\n# .....\n# ...\n# ..#\n# #.#\n"] | ['Wrong Answer', 'Accepted'] | ['s792227559', 's339053076'] | [3064.0, 3064.0] | [17.0, 18.0] | [694, 661] |
p03804 | u888337853 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import sys\n\n# import re\nimport math\nimport collections\n\nimport bisect\nimport itertools\nimport fractions\n# import functools\nimport copy\nimport heapq\nimport decimal\n# import statistics\nimport queue\nimport numpy as np\n\nsys.setrecursionlimit(10000001)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\n\ndef main():\n n, m = ns()\n matA = [list(input()) for _ in range(n)]\n matB = [list(input()) for _ in range(m)]\n\n a = np.array(matA)\n b = np.array(matB)\n\n for i in range(n - m + 1):\n for j in range(n - m + 1):\n if np.all(a[j:j + m, i:i + m] == b):\n print("Yes")\n # exit(0)\n\n print("No")\n\n\nif __name__ == \'__main__\':\n main()\n', 'import sys\n\n# import re\nimport math\nimport collections\n\nimport bisect\nimport itertools\nimport fractions\n# import functools\nimport copy\nimport heapq\nimport decimal\n# import statistics\nimport queue\nimport numpy as np\n\nsys.setrecursionlimit(10000001)\nINF = 10 ** 16\nMOD = 10 ** 9 + 7\n\nni = lambda: int(sys.stdin.readline())\nns = lambda: map(int, sys.stdin.readline().split())\nna = lambda: list(map(int, sys.stdin.readline().split()))\n\n\n# ===CODE===\n\n\ndef main():\n n, m = ns()\n matA = [list(input()) for _ in range(n)]\n matB = [list(input()) for _ in range(m)]\n\n a = np.array(matA)\n b = np.array(matB)\n\n for i in range(n - m + 1):\n for j in range(n - m + 1):\n if np.all(a[j:j + m, i:i + m] == b):\n print("Yes")\n exit(0)\n\n print("No")\n\n\nif __name__ == \'__main__\':\n main()\n'] | ['Wrong Answer', 'Accepted'] | ['s416731770', 's234877488'] | [22448.0, 13580.0] | [285.0, 174.0] | [857, 855] |
p03804 | u888512581 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["N, M = map(int, input().split())\nA = list()\nB = list()\nans = 'No'\nfor i in range(N):\n A.append(input())\n\nfor i in range(M):\n B.append(input())\n\nfor i in range(N - M +1):\n for j in range(N - M +1):\n count = 0\n for row in range(M):\n for col in range(M):\n if B[row][col] == A[i + row][j + col]:\n count += 1\n if count == N*M:\n print('Yes')\n else:\n print(ans)", "N, M = map(int, input().split())\nA = list()\nB = list()\nans = 'No'\nfor i in range(N):\n A.append(input())\n\nfor i in range(M):\n B.append(input())\n\nfor i in range(N - M +1):\n for j in range(N - M +1):\n count = 0\n for row in range(M):\n for col in range(M):\n if B[row][col] == A[i + row][j + col]:\n count += 1\n if count == N*M:\n ans == 'Yes'\n \nprint(ans)", "N, M = map(int, input().split())\nA = list()\nB = list()\nans = 'No'\nfor i in range(N):\n A.append(input())\n\nfor i in range(M):\n B.append(input())\n\nfor i in range(N - M +1):\n for j in range(N - M +1):\n count = 0\n for row in range(M):\n for col in range(M):\n if B[row][col] == A[i + row][j + col]:\n count += 1\n if count == N*M:\n ans == 'Yes'\n\nprint(ans)", "N, M = map(int, input().split())\nA = list()\nB = list()\nans = 'No'\nfor i in range(N):\n A.append(input())\n\nfor i in range(M):\n B.append(input())\n\nfor i in range(N - M +1):\n for j in range(N - M +1):\n count = 0\n for row in range(M):\n for col in range(M):\n if B[row][col] == A[i + row][j + col]:\n count += 1\n if count == M * M:\n ans == 'Yes'\n\nprint(ans)", "N, M = map(int, input().split())\nA = [list(input()) for i in range(N)]\nB = [list(input()) for i in range(M)]\nans = 'No'\nfor i in range(N - M + 1):\n for j in range(N - M + 1):\n count = 0\n for row in range(M):\n for col in range(M):\n if B[row][col] == A[i + row][j + col]:\n count += 1\n if count == M * M:\n ans = 'Yes'\n\nprint(ans)"] | ['Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s121640274', 's203222477', 's338871291', 's562213377', 's090478306'] | [3444.0, 3064.0, 3064.0, 3064.0, 3064.0] | [176.0, 168.0, 170.0, 166.0, 148.0] | [459, 442, 433, 435, 406] |
p03804 | u896741788 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m=map(int,input().split())\nl=[input() for i in range(n)]\nml=[input() for i in range(m)]\nfor i in range(n-m+1):\n for j in range(n-m+1):\n for h in range(m):\n if ml[h]!=l[i][j:j+m]:break\n else:print("Yes");exit()\nprint("No")', 'n,m=map(int,input().split())\nl=[input() for i in range(n)]\nml=[input() for i in range(m)]\nfor i in range(n-m+1):\n for j in range(n-m+1):\n for h in range(m):\n if ml[h]!=l[i+h][j:j+m]:break\n else:print("Yes");exit()\nprint("No")'] | ['Wrong Answer', 'Accepted'] | ['s643836369', 's881671154'] | [3064.0, 3064.0] | [19.0, 18.0] | [235, 237] |
p03804 | u905582793 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N,M = map(int,input())\nA = [input() for _ in range(N)]\nB = [input() for _ in range(N)]\nans = 0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(i,i+M):\n for l in range(j,j+M):\n if A[k][l] != B[k][l]:\n break\n if A[k][l] == B[k][l] and k == i+M-1 and l == j+M-1:\n ans = 1\n else:\n continue\n break\nif ans == 0:\n print("No")\nelse:\n print("Yes")', 'N,M = map(int,input().split())\nA = [input() for _ in range(N)]\nB = [input() for _ in range(M)]\nans = 0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(i,i+M):\n for l in range(j,j+M):\n if A[k][l] != B[k-i][l-j]:\n break\n if A[k][l] == B[k-i][l-j] and k == i+M-1 and l == j+M-1:\n ans = 1\n else:\n continue\n break\n\nif ans == 0:\n print("No")\nelse:\n print("Yes")'] | ['Runtime Error', 'Accepted'] | ['s502446534', 's367966823'] | [3064.0, 3064.0] | [17.0, 21.0] | [407, 430] |
p03804 | u911575040 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n,m=map(int,input().split())\na=[input() for _ in range(n)]\nb=[input() for _ in range(m)]\nr=any(a[i:i+m][j:j+m]==b for i in range(n-m+1) for j in range(n-m+1))\nprint('Yes' if r else 'No')", "n,m=map(int,input().split())\nA=[input() for _ in range(n)]\nB=[input() for _ in range(m)]\n \nans='No'\n \nfor i in range(n-m+1):\n for j in range(n-m+1):\n C=[A[i+k][j:j+m] for k in range(m)]\n if B==C:\n ans='Yes'\n \nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s556912080', 's173989641'] | [3060.0, 3064.0] | [18.0, 21.0] | [186, 254] |
p03804 | u914797917 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["N,M=map(int, input().split())\nA = [input() for i in range(N)]\nB = [input() for i in range(M)]\n\nflag=0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n if A[i+k][j:j+M]!=B[k]:\n break\n \n else:\n flag=1\n print('!')\nprint('Yes' if flag==1 else 'No')", "N,M=map(int, input().split())\nA = [input() for i in range(N)]\nB = [input() for i in range(M)]\n\nflag=0\nfor i in range(N-M+1):\n for j in range(N-M+1):\n for k in range(M):\n if A[i+k][j:j+M]!=B[k]:\n break\n \n else:\n flag=1\nprint('Yes' if flag==1 else 'No')"] | ['Wrong Answer', 'Accepted'] | ['s673861230', 's092740614'] | [3064.0, 3188.0] | [19.0, 19.0] | [337, 320] |
p03804 | u927534107 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m=map(int,input().split())\na=[str(input()) for _ in range(n)]\nb=[str(input()) for _ in range(m)]\nfor i in range(n-m+1):\n for j in range(n-m+1):\n tmp=[]\n for k in range(m):\n tmp.append(a[j+k][i:i+m])\n if tmp==b:\n print("YES")\n exit()\nprint("NO")', 'n,m=map(int,input().split())\na=[str(input()) for _ in range(n)]\nb=[str(input()) for _ in range(m)]\nfor i in range(n-m+1):\n for j in range(n-m+1):\n tmp=[]\n for k in range(m):\n tmp.append(a[j+k][i:i+m])\n if tmp==b:\n print("Yes")\n exit()\nprint("No")'] | ['Wrong Answer', 'Accepted'] | ['s934411472', 's798719686'] | [3064.0, 3060.0] | [22.0, 24.0] | [303, 303] |
p03804 | u929569377 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['\n#include <string>\nusing namespace std;\n\nint main()\n{\n\tint N, M;\n\tcin >> N >> M;\n\t\n\tstring A[55];\n\tstring B[55];\n\t\n\tfor(int i = 0; i < N; i++){\n\t\tcin >> A[i];\n\t}\n\tfor(int j = 0; j < M; j++){\n\t\tcin >> B[j];\n\t}\n\t\n\tbool judge = false;\n\t\n\tfor(int i = 0; i < N - M + 1; i++){\n\t\tfor(int j = 0; j < N - M + 1; j++){\n\t\t\tfor(int k = 0; k < M; k++){\n\t\t\t\tif(B[k] != A[i + k].substr(j, M)){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif(k == M - 1){\n\t\t\t\t\tjudge = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tif(judge){\n\t\tcout << "Yes";\n\t}\n\telse {\n\t\tcout << "No";\n\t}\n}\n', "N, M = [int(x) for x in input().split()]\n\nA = []\nB = []\n\nfor _ in range(N):\n\tA.append(input())\n\nfor _ in range(M):\n\tB.append(input())\n\njudge = False\n\t\nfor i in range(N - M + 1):\n\tfor j in range(N - M + 1):\n\t\tfor k in range(M):\n\t\t\tif B[k] != A[i + k][j: j + M]:\n\t\t\t\tbreak\n\t\t\tif k == M - 1:\n\t\t\t\tjudge = True\n\nif judge:\n\tprint('Yes')\nelse:\n\tprint('No')"] | ['Runtime Error', 'Accepted'] | ['s871058625', 's154868926'] | [2940.0, 3064.0] | [17.0, 19.0] | [533, 349] |
p03804 | u940342887 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['print(A)\n\ndef is_match(a, b):\n return (a==b).all()\nflag = False\nfor i in range(N):\n for j in range(N):\n x_left = i\n x_right = i + M\n y_up = j\n y_under = j + M\n if x_right >= N or y_under >= N:\n continue\n if is_match(B, A[x_left:x_right, y_up:y_under]):\n flag = True\nif flag:\n print("Yes")\nelse:\n print("No")', 'N, M = map(int, input().split())\n\nA = []\nfor i in range(N):\n tmp = input()\n A.append([0 if s=="." else 1 for s in tmp])\nB = []\nfor i in range(M):\n tmp = input()\n B.append([0 if s=="." else 1 for s in tmp])\n \nA = np.array(A)\nB = np.array(B)\n\ndef is_match(a, b):\n return (a==b).all()\nflag = False\nfor i in range(N):\n for j in range(N):\n x_left = i\n x_right = i + M\n y_up = j\n y_under = j + M\n if x_right >= N or y_under >= N:\n continue\n if is_match(B, A[x_left:x_right, y_up:y_under]):\n flag = True\nif flag:\n print("Yes")\nelse:\n print("No")', 'import numpy as np\nN, M = map(int, input().split())\n\nA = []\nfor i in range(N):\n tmp = input()\n A.append([0 if s=="." else 1 for s in tmp])\nB = []\nfor i in range(M):\n tmp = input()\n B.append([0 if s=="." else 1 for s in tmp])\n \nA = np.array(A)\nB = np.array(B)\n\ndef is_match(a, b):\n return (a==b).all()\nflag = False\nfor i in range(N):\n for j in range(N):\n x_left = i\n x_right = i + M\n y_up = j\n y_under = j + M\n if x_right > N or y_under > N:\n continue\n if is_match(B, A[x_left:x_right, y_up:y_under]):\n flag = True\nif flag:\n print("Yes")\nelse:\n print("No")'] | ['Runtime Error', 'Runtime Error', 'Accepted'] | ['s064586091', 's341772206', 's354410271'] | [3064.0, 3064.0, 21656.0] | [17.0, 18.0, 298.0] | [412, 629, 646] |
p03804 | u945418216 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n,m = map(int, input().split())\naa = [input() for _ in range(n)]\nbb = [input() for _ in range(m)]\n\nans = 0\nfor a in aa:\n for b in bb:\n if a.count(b)>0:\n ans +=1\n break\n# print(ans)\nprint('Yes' if ans==len(bb) else 'No')", "n,m = map(int, input().split())\naa = [input() for _ in range(n)]\nbb = [input() for _ in range(m)]\n\nmatch = False\nfor y in range(n-m+1):\n for x in range(n-m+1):\n target = ([''.join(aa[i][x:x+m]) for i in range(y,y+m)])\n if match or target == bb:\n match = True\n\nprint('Yes' if match else 'No')\n"] | ['Wrong Answer', 'Accepted'] | ['s602958807', 's787132183'] | [3060.0, 3060.0] | [20.0, 33.0] | [251, 320] |
p03804 | u947193699 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['import numpy as np\nn,m =map(int,input().split())\n\n\nA = np.array([list(input()) for i in range(n)])\nB = np.array([list(input()) for i in range(m)])\nP = np.zeros(B.shape,str)\na = 0\nfor i in range(n-m+1):\n for j in range(n-m+1):\n P= A[i:i+m,j:j+m]\n # print(P)\n if np.all(B==P):\n print("Yes")\n a = 1\n break\n\nif a ==0:\n print("No")', 'import numpy as np\nn,m =map(int,input().split())\n\n\nA = np.array([list(input()) for i in range(n)])\nB = np.array([list(input()) for i in range(m)])\nP = np.zeros(B.shape,str)\na = 0\nfor i in range(n-m+1):\n for j in range(n-m+1):\n \n print(P)\n if np.all(B==P):\n print("Yes")\n a = 1\n break\n\nif a ==0:\n print("No")\n', 'import numpy as np\nn,m =map(int,input().split())\n\n\nA = np.array([list(input()) for i in range(n)])\nB = np.array([list(input()) for i in range(m)])\nP = np.zeros(B.shape,str)\na = 0\nfor i in range(n-m+1):\n for j in range(n-m+1):\n P= A[i:i+m,j:j+m]\n if np.all(B==P):\n a = 1\n break\n\nif a ==0:\n print("No")\nelse:\n print("Yes")'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s202842495', 's211198674', 's883019595'] | [22196.0, 13668.0, 12404.0] | [342.0, 865.0, 177.0] | [369, 370, 352] |
p03804 | u948524308 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['N,M = map(int,input().split())\n\nA = []\nB = []\n\nfor i in range(N):\n A.append(input())\nfor j in range(M):\n B.append(input())\n\n\nfor i in range(N - M + 1):\n for j in range(N - M + 1):\n l = 0\n for l in range(M):\n if A[i].find(B[l],j) != j:\n break \n if l == M-1:\n print("Yes")\n exit()\n\nprint("No")\n ', 'N,M=map(int,input().split())\nA=[]\nB=[]\nfor i in range(N):\n A.append(input())\nfor i in range(M):\n B.append(input())\n\nfor i in range(N-M+1):\n for j in range(N-M+1):\n f=True\n for k in range(M):\n if A[j+k][i:M+i]==B[k]:continue\n else:\n f=False\n break\n if f:\n print("Yes")\n exit()\nprint("No")\n'] | ['Wrong Answer', 'Accepted'] | ['s797421760', 's818364334'] | [3064.0, 9204.0] | [19.0, 26.0] | [396, 392] |
p03804 | u957957759 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n,m=map(int,input().split())\ns=[input() for i in range(n)]\nt=[input() for i in range(m)]\n\nz=0\nc=0\n\nfor i in range(n-m+1):\n for j in range(n-m+1): \n \n for x in range(m):\n for y in range(m):\n if s[i+x][j+y]==t[x][y]:\n z+=1\n if z==m**2:\n c+=1\n else:\n c=0\nif c>0:\n print('Yes')\nelse:\n print('No')", "n,m=map(int,input().split())\ns=[input() for i in range(n)]\nt=[input() for i in range(m)]\n\nz=0\nc=0\n\nfor i in range(n-m+1):\n for j in range(n-m+1): \n \n for x in range(m):\n for y in range(m):\n if s[i+x][j+y]==t[x][y]:\n z+=1\n if z==m**2:\n c+=1\n else:\n z=0\nif c>0:\n print('Yes')\nelse:\n print('No')"] | ['Wrong Answer', 'Accepted'] | ['s830865022', 's838808687'] | [3064.0, 3064.0] | [163.0, 161.0] | [396, 396] |
p03804 | u958506960 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n, m = map(int, input().split())\na = [input() for _ in range(n)]\nb = [input() for _ in range(m)]\ns = 0\ncnt = 0\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n for x in range(m):\n for y in range(m):\n if a[i+x][j+y] == b[x][y]:\n s += 1\n if s == m ** 2:\n cnt += 1\n else:\n s = 0\nif c > 0:\n print('Yes')\nelse:\n print('No')", "n, m = map(int, input().split())\na = [input() for _ in range(n)]\nb = [input() for _ in range(m)]\ns = 0\ncnt = 0\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n for x in range(m):\n for y in range(m):\n if a[i+x][j+y] == b[x][y]:\n s += 1\n if s == m ** 2:\n cnt += 1\n else:\n s = 0\nif cnt > 0:\n print('Yes')\nelse:\n print('No')", "n, m = map(int, input().split())\na = [input() for _ in range(n)]\nb = [input() for _ in range(m)]\ns = 0\ncnt = 0\n\nfor i in range(n-m+1):\n for j in range(n-m+1):\n for x in range(m):\n for y in range(m):\n if a[i+x][j+y] == b[x][y]:\n s += 1\n if s == m ** 2:\n cnt += 1\n else:\n s = 0\nif cnt > 0:\n print('Yes')\nelse:\n print('No')"] | ['Runtime Error', 'Wrong Answer', 'Accepted'] | ['s088108104', 's693888393', 's598168184'] | [3064.0, 3064.0, 3064.0] | [179.0, 172.0, 166.0] | [431, 433, 417] |
p03804 | u961674365 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m=map(int,input().split())\na=[input() for i in range(n)]\nb=[input() for i in range(m)]\n#print(a,b)\nans=0\ncnt=0\nfor i in range(n-m+1):\n for j in range(n-m+1):\n cnt=0\n for k in range(m):\n if b[k]!=a[i+k][j:j+m]:\n break\n cnt+=1\n \n if cnt==m:\n ans+=1\n if ans>0:\n break\n if ans>0:\n break\n \nprint("Yes" if ans>0 else "No",ans)\n\n\n\n\n\n\n', 'n,m=map(int,input().split())\na=[input() for i in range(n)]\nb=[input() for i in range(m)]\n#print(a,b)\nans=0\ncnt=0\nfor i in range(n-m+1):\n for j in range(n-m+1):\n cnt=0\n for k in range(m):\n if b[k]!=a[i+k][j:j+m]:\n break\n cnt+=1\n \n if cnt==m:\n ans+=1\n if ans>0:\n break\n if ans>0:\n break\n \nprint("Yes" if ans>0 else "No")\n\n\n\n\n\n\n'] | ['Wrong Answer', 'Accepted'] | ['s398003947', 's287782507'] | [3064.0, 3064.0] | [18.0, 19.0] | [425, 421] |
p03804 | u970809473 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n,m=map(int,input().split())\ns1=[input() for _ in range(n)]\ns2=[input() for _ in range(m)]\nans='No'\nfor i in range(n-m+1):\n for j in range(n-m+1):\n flg=0\n print(i,j)\n for k in range(m):\n if s1[j+k][i:i+m]==s2[k]:\n flg+=1\n if flg==m:\n ans='Yes'\nprint(ans)", "n,m=map(int,input().split())\ns1=[input() for _ in range(n)]\ns2=[input() for _ in range(m)]\nans='No'\nfor i in range(n-m+1):\n for j in range(n-m+1):\n flg=0\n for k in range(m):\n if s1[j+k][i:i+m]==s2[k]:\n flg+=1\n if flg==m:\n ans='Yes'\nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s305062663', 's543137255'] | [9348.0, 9188.0] | [28.0, 31.0] | [284, 269] |
p03804 | u977389981 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ["n, m = map(int, input().split())\nA = [list(input()) for i in range(n)]\nB = [list(input()) for i in range(m)]\n\nfor i in range(n - m + 1):\n flag = 0\n for j in range(m):\n if flag:\n break\n else:\n for k in range(m):\n if A[i + j][k] != B[j][k]:\n flag = 1\n break\n if A[j][i + k] != B[j][k]:\n flag = 1\n break\n\nprint('No' if flag else 'Yes')", "n, m = map(int, input().split())\nA = [input() for i in range(n)]\nB = [input() for i in range(m)]\n\nans = 'No'\nfor i in range(n - m + 1):\n for j in range(n - m + 1):\n C = []\n for k in range(m):\n C.append(A[i + k][j : j + m])\n if B == C:\n ans = 'Yes'\n \nprint(ans)"] | ['Wrong Answer', 'Accepted'] | ['s152523537', 's370579465'] | [3064.0, 3064.0] | [18.0, 23.0] | [480, 317] |
p03804 | u980783809 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n, m = map(int, input().split())\nnl=[]\nml=[]\nfor i in range(n):\n nl.append(input())\nfor i in range(m):\n ml.append(input())\n\ncnt=0\nYes=False\nfor i in nl:\n if(ml[0] in i):\n print(str(ml[0])+" in "+ str(i))\n idx = i.find(ml[0])\n cnt2=cnt+1\n for j in range(1,m):\n if cnt2>n-1:\n break\n elif(not ml[j]==nl[cnt2][idx:idx+m]):\n break\n elif(j==m-1):\n Yes = True\n break\n cnt2+=1\n if(Yes):\n break\n cnt+=1\nif Yes:\n print("Yes")\nelse:\n print("No")', ', m = map(int, input().split())\nnl=[]\nml=[]\nfor i in range(n):\n nl.append(input())\nfor i in range(m):\n ml.append(input())\n\ncnt=0\nYes=False\nfor i in nl:\n if(ml[0] in i):\n idx = i.find(ml[0])\n cnt2=cnt+1\n for j in range(1,m):\n if cnt2>n-1:\n ok = False\n break\n elif(not ml[j]==nl[cnt2][idx:idx+m]):\n ok=False\n break\n elif(j==m-1):\n Yes = True\n break\n cnt2+=1\n if(Yes):\n break\n cnt+=1\nif Yes:\n print("Yes")\nelse:\n print("No")', 'n, m = map(int, input().split())\nnl=[]\nml=[]\nfor i in range(n):\n nl.append(input())\nfor i in range(m):\n ml.append(input())\n\ncnt=0\nYes=False\nfor i in nl:\n if(ml[0] in i):\n idx = i.find(ml[0])\n cnt2=cnt+1\n if m==1:\n Yes = True\n break\n for j in range(1,m):\n if cnt2>n-1:\n break\n elif(not ml[j]==nl[cnt2][idx:idx+m]):\n break\n elif(j==m-1):\n Yes = True\n break\n cnt2+=1\n if(Yes):\n break\n cnt+=1\nif Yes:\n print("Yes")\nelse:\n print("No")'] | ['Wrong Answer', 'Runtime Error', 'Accepted'] | ['s287070020', 's716911083', 's275746305'] | [3064.0, 2940.0, 3064.0] | [17.0, 17.0, 18.0] | [594, 604, 611] |
p03804 | u989345508 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n,m=input().split()\nn,m=int(n),int(m)\na=[]\nfor i in range(n):\n a.append(input())\n\nb=[]\nfor i in range(m):\n b.append(input())\n\n\nfor i in range(n-m):\n for j in range(n-m):\n c=0\n for k in range(m):\n if b[k] == a[i+k][j:j+m]:\n c+=1\n else:\n break\n if c==m:\n break\n if c==m:\n break\n', 'n,m=map(int,input().split())\na=[list(input()) for i in range(n)]\nb=[list(input()) for i in range(m)]\ndef all_true(i,j):\n global a,b\n for k in range(i,i+m):\n for l in range(j,j+m):\n if a[k][l]!=b[k-i][l-j]:\n return False\n return True\nf=0\nfor i in range(n-m+1):\n for j in range(n-m+1):\n if all_true(i,j):\n f=1\n break\n if f==1:\n print("Yes")\n break\nelse:\n print("No")\n'] | ['Wrong Answer', 'Accepted'] | ['s314371480', 's852288478'] | [3064.0, 3064.0] | [18.0, 18.0] | [404, 459] |
p03804 | u991567869 | 2,000 | 262,144 | You are given an image A composed of N rows and N columns of pixels, and a template image B composed of M rows and M columns of pixels. A pixel is the smallest element of an image, and in this problem it is a square of size 1×1. Also, the given images are binary images, and the color of each pixel is either white or black. In the input, every pixel is represented by a character: `.` corresponds to a white pixel, and `#` corresponds to a black pixel. The image A is given as N strings A_1,...,A_N. The j-th character in the string A_i corresponds to the pixel at the i-th row and j-th column of the image A (1≦i,j≦N). Similarly, the template image B is given as M strings B_1,...,B_M. The j-th character in the string B_i corresponds to the pixel at the i-th row and j-th column of the template image B (1≦i,j≦M). Determine whether the template image B is contained in the image A when only parallel shifts can be applied to the images. | ['n, m = map(int, input().split())\n\na = [input() for _ in range(n)]\nb = [input() for _ in range(m)]\nans = "No"\n\nfor i in range(n - m + 1): \n for j in range(n - m + 1): \n for k in range(m): \n print(b[k], a[i + k][j:j + m])\n if b[k] != a[i + k][j:j + m]:\n break\n if k == m - 1 and b[k] == a[i + k][j:j + m]:\n ans = "Yes"\n\nprint(ans)', 'n, m = map(int, input().split())\n\na = [input() for _ in range(n)]\nb = [input() for _ in range(m)]\nans = "No"\n\nfor i in range(n - m + 1): \n for j in range(n - m + 1): \n for k in range(m): \n if b[k] != a[i + k][j:j + m]:\n break\n if k == m - 1 and b[k] == a[i + k][j:j + m]:\n ans = "Yes"\n\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s487163383', 's186932495'] | [3444.0, 3064.0] | [23.0, 18.0] | [453, 410] |
p03805 | u001024152 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['import sys\nsys.setrecursionlimit(100000)\nN,M = map(int, input().split())\npath = []\nfor _ in range(M):\n ai, bi = map(int, input().split())\n path.append((ai, bi))\n path.append((bi, ai))\n \nans = 0\ndef dfs(v, visited):\n # v: now here\n # visited: set\n global ans\n print(visited)\n if v in visited:\n return\n else:\n visited.add(v)\n \n if len(visited)==N:\n ans += 1\n \n for pi in path:\n a,b = pi[0], pi[1]\n if a==b==v:\n dfs(a, visited)\n else:\n if a==v: dfs(b, visited)\n if b==v: dfs(a, visited)\n\n\ndfs(1, set([]))\nloop = 0\nfor pi in path:\n a,b = pi[0], pi[1]\n if a==b:\n loop += 1\nprint(ans+loop)', 'import sys\nsys.setrecursionlimit(100000)\nN,M = map(int, input().split())\npath = []\nfor _ in range(M):\n ai, bi = map(int, input().split())\n path.append((ai, bi))\n path.append((bi, ai))\n \nans = 0\ndef dfs(v, visited):\n # v: now here\n # visited: set\n global ans\n# print(visited)\n if v in visited:\n return\n else:\n visited.add(v)\n \n if len(visited)==N:\n ans += 1\n \n for pi in path:\n a,b = pi[0], pi[1]\n if a==b==v:\n dfs(a, visited)\n else:\n if a==v: dfs(b, visited)\n if b==v: dfs(a, visited)\n\n\ndfs(1, set([]))\nloop = 0\nfor pi in path:\n a,b = pi[0], pi[1]\n if a==b:\n loop += 1\nprint(ans+loop)', 'def main():\n N, M = map(int, input().split())\n edges = [[] for _ in range(N)]\n for _ in range(M):\n a, b = map(lambda x: int(x)-1, input().split())\n edges[a].append(b)\n edges[b].append(a)\n\n visited = [False]*N\n visited[0] = True\n ans = 0\n\n def dfs(v: int):\n nonlocal visited\n nonlocal ans\n if all(visited):\n ans += 1\n return\n for n in edges[v]:\n if visited[n]:\n continue\n visited[n] = True\n dfs(n)\n visited[n] = False\n return\n\n dfs(0)\n print(ans)\n\n\nif __name__ == "__main__":\n main()\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s757776654', 's951515059', 's950752553'] | [3064.0, 3064.0, 3064.0] | [17.0, 17.0, 23.0] | [721, 723, 650] |
p03805 | u013408661 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['import sys\nn,m=map(int,input().split())\nnumber=[[int(i) for i in l.split()] for l in sys.stdin]\nvisit=[0]*(n+1)\nvisit[1]=1\nnode=[[] for i in range(n+1)]\nfor i in number:\n node[i[0]].append(i[1])\n node[i[1]].appedn(i[0])\nans=0\ndef dfs(x):\n global ans\n if visit.count(1)==n:\n ans+=1\n return 0\n for i in node[x]:\n if visit[i]==0:\n visit[i]=1\n dfs(i)\n visit[i]=0\n return 0\ndfs(1)\nprint(ans)', 'import sys\nn,m=map(int,input().split())\nnumber=[[int(i) for i in l.split()] for l in sys.stdin]\nans=0\nroot=[i for i in range(n)]\nrank=[0]*(n+1)\ndef find(x):\n if root[x]==x:\n return x\n root[x]=find(root[x])\n return root[x]\ndef check(x,y):\n return find(x)==find(y)\ndef union(x,y):\n x=find(x)\n y=find(y)\n if rank[x]>=rank[y]:\n root[y]=x\n else:\n root[x]=y\n if rank[x]==rank[y]:\n rank[x]+=1\ndef dfs(i,flag):\n if str(flag).count(1)!=n-1:\n if i==m:\n return 0\n dfs(i+1,flag|2**i)\n dfs(i+1|flag)\n root=[i for i in range(n)]\n rank=[0]*(n+1)\n for j in range(m):\n if flag&2**j>0:\n union(number[j][0],number[j][1])\n for j in range(1,n):\n if check(i,i+1)==False:\n return 0\n ans+=1\ndfs(0,0)\nprint(ans)', 'import sys\nn,m=map(int,input().split())\nnumber=[[int(i) for i in l.split()] for l in sys.stdin]\nvisit=[0]*(n+1)\nnode=[[] for i in range(n+1)]\nfor i in number:\n node[i[0]].append(i[1])\n node[i[1]].appedn(i[0])\nans=0\ndef dfs(x):\n global ans\n if visit.count(1)==n:\n ans+=1\n return 0\n for i in visit[x]:\n if visit[i]==0:\n visit[i]=1\n dfs(i)\n visit[i]=0\n return 0\ndfs(1)\nprint(ans)', 'import sys\nn,m=map(int,input().split())\nnumber=[[int(i) for i in l.split()] for l in sys.stdin]\nvisit=[0]*(n+1)\nnode=[[] for i in range(n+1)]\nfor i in number:\n node[i[0]].append(i[1])\n node[i[1]].appedn(i[0])\nans=0\ndef dfs(x):\n global ans\n if visit.count(1)==n:\n ans+=1\n return 0\n for i in node[x]:\n if visit[i]==0:\n visit[i]=1\n dfs(i)\n visit[i]=0\n return 0\ndfs(1)\nprint(ans)', 'import sys\nn,m=map(int,input().split())\nnumber=[[int(i) for i in l.split()] for l in sys.stdin]\nvisit=[0]*(n+1)\nvisit[1]=1\nnode=[[] for i in range(n+1)]\nfor i in number:\n node[i[0]].append(i[1])\n node[i[1]].append(i[0])\nans=0\ndef dfs(x):\n global ans\n if visit.count(1)==n:\n ans+=1\n return 0\n for i in node[x]:\n if visit[i]==0:\n visit[i]=1\n dfs(i)\n visit[i]=0\n return 0\ndfs(1)\nprint(ans)'] | ['Runtime Error', 'Runtime Error', 'Runtime Error', 'Runtime Error', 'Accepted'] | ['s136257552', 's199904692', 's593578534', 's693316443', 's376827668'] | [3064.0, 3064.0, 3064.0, 3064.0, 3064.0] | [17.0, 18.0, 17.0, 19.0, 26.0] | [416, 743, 406, 405, 416] |
p03805 | u013956357 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['[n,m] = [int(x) for x in input().split()]\ndata = [[int(x) for x in input().split()] for _ in range(m)]\n\ntotal = 0\nfor x in itertools.permutations(range(2,n+1)):\n \n route = [1,]+list(x)\n \n for x in range(len(route)-1):\n flg = False\n \n for y in data:\n if {route[x],route[x+1]} == set(y):\n flg = True\n break\n \n if flg == False:\n break\n \n else:\n total += 1\n \nprint(total)\n ', 'import itertools\n\n[n,m] = [int(x) for x in input().split()]\ndata = [[int(x) for x in input().split()] for _ in range(m)]\n\ntotal = 0\nfor x in itertools.permutations(range(2,n+1)):\n \n route = [1,]+list(x)\n \n for x in range(len(route)-1):\n flg = False\n \n for y in data:\n if {route[x],route[x+1]} == set(y):\n flg = True\n break\n \n if flg == False:\n break\n \n else:\n total += 1\n \nprint(total)\n '] | ['Runtime Error', 'Accepted'] | ['s825364282', 's646128267'] | [3064.0, 3064.0] | [17.0, 317.0] | [511, 529] |
p03805 | u017050982 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['def kaijyo(n):\n ans = 1\n for i in range(n):\n ans *= i + 1\n return ans\n\nN,M = map(int,input().rstrip().split(" "))\nhen = []\nans = 0\nfor i in range(M):\n a,b = map(int,input().rstrip().split(" "))\n hen.append([a,b])\nprint(hen)\nfor i in range(kaijyo(N-1)):\n lis = [i+2 for i in range(N-1)]\n lis2 = [1]\n k = i\n for i2 in range(N-1):\n lis2.append(lis[k % (N - 1 - i2)])\n k = k // (N - 1 - i2)\n for i3 in range(len(lis)):\n if lis[i3] == lis2[-1]:\n lis.pop(i3)\n break\n for i2 in range(N-1):\n if not ([lis2[i2],lis2[i2+1]] in hen or [lis2[i2+1],lis2[i2]] in hen):\n break\n if i2 == N - 2:\n ans += 1\nprint(ans)\n ', 'def kaijyo(n):\n ans = 1\n for i in range(n):\n ans *= i + 1\n return ans\n\nN,M = map(int,input().rstrip().split(" "))\nhen = []\nans = 0\nfor i in range(M):\n a,b = map(int,input().rstrip().split(" "))\n hen.append([a,b])\nfor i in range(kaijyo(N-1)):\n lis = [i+2 for i in range(N-1)]\n lis2 = [1]\n k = i\n for i2 in range(N-1):\n lis2.append(lis[k % (N - 1 - i2)])\n k = k // (N - 1 - i2)\n for i3 in range(len(lis)):\n if lis[i3] == lis2[-1]:\n lis.pop(i3)\n break\n for i2 in range(N-1):\n if not ([lis2[i2],lis2[i2+1]] in hen or [lis2[i2+1],lis2[i2]] in hen):\n break\n if i2 == N - 2:\n ans += 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s671430771', 's739306321'] | [9200.0, 9260.0] | [95.0, 91.0] | [739, 723] |
p03805 | u035210736 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['n, m = map(int, input().split())\na = [list(map(int, input().split())) for _ in range(m)]\n\nc = [i for i in range(2, n + 1)]\nb = []\nfor x in itertools.permutations(c):\n b.append([1] + list(x))\n \ncnt = 0\nfor x in b:\n exist = True\n for i in range(n-1):\n if not sorted(x[i:i+2]) in a:\n exist = False\n break\n if exist:\n cnt += 1\n\nprint(cnt)', 'from networkx import *\nn, m = map(int, input().split())\na = [list(map(int, input().split())) for i in range(m)]\ng = Graph(a)\nans = 0\nfor i in range(2, n + 1):\n for p in all_simple_paths(g, 1, i):\n if len(p) == n:\n ans += 1\nprint(ans)'] | ['Runtime Error', 'Accepted'] | ['s845322609', 's036208921'] | [9152.0, 53328.0] | [26.0, 363.0] | [355, 242] |
p03805 | u047178225 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['nmax = 8\ngraph = [[0]*nmax for i in range(nmax)]\nvisited = [0] * nmax\n\ndef dfs(v, N, visitied):\n all_visited = True\n for i in range(N):\n if visitied[i] == 0:\n all_visited = False\n if all_visited:\n return 1\n \n ret = 0\n for i in range(N):\n if graph[v][i] == 0:\n continue\n if visited[i] == 0:\n continue\n visited[i] = 1\n ret += dfs(i, N, visited)\n visited[i] = False\n return ret\n \n\nN, M = [int(i) for i input().split()]\nfor j in range(M):\n a, b = [int(j) for j in input().split()]\n graph[a-1][b-1] = graph[b-1][a-1] = 1\n\nvisited[0] = 1\nprint(dfs(0, N, visited))\n \n', 'nmax = 8\ngraph = [[0]*nmax for i in range(nmax)]\nvisited = [0] * nmax\n\n\ndef dfs(v, N, visited):\n all_visited = True\n for i in range(N):\n if visited[i] == 0:\n all_visited = False\n if all_visited:\n return 1\n \n ret = 0\n for i in range(N):\n if graph[v][i] == 0:\n continue\n if visited[i] == 1:\n continue\n visited[i] = 1\n ret += dfs(i, N, visited)\n visited[i] = 0\n return ret\n \n\nN, M = [int(i) for i in input().split()]\nfor j in range(M):\n a, b = [int(j) for j in input().split()]\n graph[a-1][b-1] = graph[b-1][a-1] = 1\n\n\nvisited[0] = 1\nprint(dfs(0, N, visited))'] | ['Runtime Error', 'Accepted'] | ['s987955988', 's437213396'] | [3060.0, 3064.0] | [17.0, 38.0] | [615, 668] |
p03805 | u051842502 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['N,M=map(int,input().split())\noriginal_paths={}\npaths={}\nfor n in range(1,N+1):\n original_paths[n]=[]\nfor m in range(1,M+1):\n s,e=map(int,input().split())\n original_paths[s].append(e)\n original_paths[e].append(s)\n \nvisited=[1]\ncurrent_point=1\nanswer=0\nimport copy\npaths=copy.deepcopy(original_paths)\n\nwhile len(paths[1])!=0:\n print(current_point,visited,paths)\n if len(paths[current_point])!=0:\n next_point=paths[current_point][0]\n \n if next_point in visited:\n\n if len(paths[current_point])!=1:\n paths[current_point].remove(next_point)\n\n else:\n if len(visited)==N:\n answer+=1\n prior_point=visited[-2]\n paths[current_point]=original_paths[current_point].copy()\n paths[prior_point].remove(current_point)\n visited.remove(current_point)\n current_point=prior_point\n\n else:\n visited.append(next_point)\n current_point=next_point\n\n else:\n prior_point=visited[-2]\n paths[current_point]=original_paths[current_point].copy()\n paths[prior_point].remove(current_point)\n visited.remove(current_point)\n current_point=prior_point\n \nprint(answer)\n', 'N,M=map(int,input().split())\noriginal_paths={}\npaths={}\nfor n in range(1,N+1):\n original_paths[n]=[]\n paths[n]=[]\nfor m in range(1,M+1):\n s,e=map(int,input().split())\n original_paths[s].append(e)\n original_paths[e].append(s)\n paths[s].append(e)\n paths[e].append(s)\n \nvisited=[1]\ncurrent_point=1\nanswer=0\n\nwhile len(paths[1])!=0:\n print(current_point,visited,paths)\n if len(paths[current_point])!=0:\n next_point=paths[current_point][0]\n \n if next_point in visited:\n\n if len(paths[current_point])!=1:\n paths[current_point].remove(next_point)\n\n else:\n if len(visited)==N:\n answer+=1\n prior_point=visited[-2]\n paths[current_point]=original_paths[current_point].copy()\n paths[prior_point].remove(current_point)\n visited.remove(current_point)\n current_point=prior_point\n\n else:\n visited.append(next_point)\n current_point=next_point\n\n else:\n prior_point=visited[-2]\n paths[current_point]=original_paths[current_point].copy()\n paths[prior_point].remove(current_point)\n visited.remove(current_point)\n current_point=prior_point\n \nprint(answer)\n', 'N,M=map(int,input().split())\noriginal_paths={}\npaths={}\nfor n in range(1,N+1):\n original_paths[n]=[]\n paths[n]=[]\nfor m in range(1,M+1):\n s,e=map(int,input().split())\n original_paths[s].append(e)\n original_paths[e].append(s)\n paths[s].append(e)\n paths[e].append(s)\n \nvisited=[1]\ncurrent_point=1\nanswer=0\n\nwhile len(paths[1])!=0:\n \n if len(paths[current_point])!=0:\n next_point=paths[current_point][0]\n \n if next_point in visited:\n\n if len(paths[current_point])!=1:\n paths[current_point].remove(next_point)\n\n else:\n if len(visited)==N:\n answer+=1\n prior_point=visited[-2]\n paths[current_point]=original_paths[current_point].copy()\n paths[prior_point].remove(current_point)\n visited.remove(current_point)\n current_point=prior_point\n\n else:\n visited.append(next_point)\n current_point=next_point\n\n else:\n prior_point=visited[-2]\n paths[current_point]=original_paths[current_point].copy()\n paths[prior_point].remove(current_point)\n visited.remove(current_point)\n current_point=prior_point\n \nprint(answer)\n'] | ['Wrong Answer', 'Wrong Answer', 'Accepted'] | ['s720225274', 's772925951', 's712939905'] | [19060.0, 18676.0, 3064.0] | [795.0, 815.0, 93.0] | [2099, 2105, 2071] |
p03805 | u057109575 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['N, M = map(int, input().split())\nedges = [list(map(int, input().split())) for _ in range(M)]\n\ngraph = [[None] * N for _ in range(N)]\nfor x, y in edges:\n graph[x - 1][y - 1] = True\n graph[y - 1][x - 1] = True\n \ndef dfs(v):\n global ans\n visited[v] = True\n \n if all(visited):\n ans += 1\n return\n \n for i in range(N):\n if not graph[v][i]:\n continue\n if visited[i]:\n continue\n \n visited[v] = True\n dfs(i)\n visited[v] = False\n\nans = 0\nvisited = [False] * N\ndfs(0)\nprint(ans)', 'N, M = map(int, input().split())\nedges = [list(map(int, input().split())) for _ in range(M)]\n\ngraph = [[0] * N for _ in range(N)]\nfor u, v in edges:\n graph[u - 1][v - 1] = 1\n graph[v - 1][u - 1] = 1\n\nvisited = [False] * N\nvisited[0] = True\n\ndef dfs(s): \n if all(visited):\n return 1\n\n cnt = 0\n for i in range(N):\n if visited[i] or graph[s][i] != 1:\n continue\n \n visited[i] = True\n cnt += dfs(i)\n visited[i] = False\n \n return cnt\n\nprint(dfs(0))'] | ['Wrong Answer', 'Accepted'] | ['s828608525', 's112983310'] | [3064.0, 3064.0] | [17.0, 27.0] | [576, 527] |
p03805 | u059210959 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['# encoding:utf-8\nimport copy\nimport random\nimport bisect \nimport fractions \nimport math\nimport sys\n\nmod = 10**9+7\nsys.setrecursionlimit(mod) \n\nN,M = map(int,input().split())\ntree = [[] for i in range(N)]\nfor i in range(M):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n tree[a] += [b]\n tree[b] += [a]\nposition = 0\n\n\ndef dfs(node,p,passed,ans):\n if len(passed) == N - 1:\n return ans + 1\n for new_node in tree[node]:\n if new_node == p:\n continue\n if not new_node in passed:\n passed += [node]\n return dfs(new_node,node,passed,ans)\n\n\nans = dfs(0,-1,[],0)\nprint(ans)\n', '# encoding:utf-8\nimport copy\nimport random\nimport bisect \nimport fractions \nimport math\nimport sys\n\nmod = 10**9+7\nsys.setrecursionlimit(mod) \n\nN,M = map(int,input().split())\ntree = [[] for i in range(N)]\nfor i in range(M):\n a,b = map(int,input().split())\n a -= 1\n b -= 1\n tree[a] += [b]\n tree[b] += [a]\n\n# print(tree)\ndef dfs(node,p,passed):\n # print(node,passed)\n if len(passed) == N:\n return 1\n cnt = 0\n for new_node in tree[node]:\n if new_node == p:\n continue\n if not new_node in passed:\n passed2 = copy.deepcopy(passed)\n passed2 += [new_node]\n cnt += dfs(new_node,node,passed2)\n return cnt\n\nans = dfs(0,-1,[0])\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s612309546', 's032035541'] | [5700.0, 5460.0] | [42.0, 139.0] | [773, 855] |
p03805 | u063052907 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['ans = 0\ndef dfs(v, visitedNode, graph):\n visitedNode[v] = 1 \n if all(visitedNode):\n global ans\n ans += 1\n return\n for node in graph[v]: \n if visitedNode[node]:\n \n continue\n else:\n \n dfs(node, visitedNode, graph)\n\n\nN, M = map(int, input().split())\nv = 0\nvisitedNode = [0] * N\n\n\n\ngraph = [[] for _ in range(N)]\nfor _ in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n graph[a].append(b)\n graph[b].append(a)\n\n\n\ndfs(v, visitedNode, graph)\nprint(ans)\n', 'ans = 0\ndef dfs(v, visitedNode, graph):\n visitedNode[v] = 1\n # print(visitedNode)\n if all(visitedNode):\n global ans\n ans += 1\n return\n for node in graph[v]:\n if visitedNode[node]:\n \n continue\n else:\n \n dfs(node, visitedNode[:], graph)\n\n\nN, M = map(int, input().split())\nv = 0\nvisitedNode = [0] * N\n\n\ngraph = [[] for _ in range(N)]\nfor _ in range(M):\n a, b = map(int, input().split())\n a -= 1\n b -= 1\n graph[a].append(b)\n graph[b].append(a)\n# print(graph)\n\n\ndfs(v, visitedNode, graph)\nprint(ans)\n'] | ['Wrong Answer', 'Accepted'] | ['s241436932', 's441327316'] | [3316.0, 3064.0] | [19.0, 25.0] | [825, 704] |
p03805 | u075595666 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['import itertools\n\nn,m = [int(i) for i in input().split()]\n\nchk = [[0]*8 for i in range(8)]\nfor i in range(m):\n a,b = [int(i) for i in input().split()]\n chk[a-1][b-1] = 1\n chk[b-1][a-1] = 1\n\nans = 0\n\nfor i in itertools.permutations(range(n),n):\n if i[0] == 1:\n for j in range(n):\n if j == n-1:\n ans += 1\n break\n if chk[i[j]][i[j+1]] == 0:\n break', 'import itertools\n\nn,m = [int(i) for i in input().split()]\n\nchk = [[0]*n for i in range(n)]\nfor i in range(m):\n a,b = [int(i) for i in input().split()]\n chk[a-1][b-1] = 1\n chk[b-1][a-1] = 1\n\nans = 0\n\nfor i in itertools.permutations(range(n),n):\n if i[0] == 0:\n for j in range(n):\n if j == n-1:\n ans += 1\n break\n if chk[i[j]][i[j+1]] != 1:\n break\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s696917164', 's450693857'] | [3064.0, 3064.0] | [34.0, 34.0] | [382, 393] |
p03805 | u077898957 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['import itertools\nN,M=map(int,input().split())\nedges={tuple(sorted(map(int,input().split()))) for i in range(M)}\nans=0\nfor i in itertools.permutations(range(2,N+1),N-1):\n l=[1]+list(i)\n ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1\nprint(0)', 'import itertools\nN,M=map(int,input().split())\nedges={tuple(sorted(map(int,input().split()))) for i in range(M)}\nans=0\nfor i in itertools.permutations(range(2,N+1),N-1):\n l=[1]+list(i)\n ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s366430305', 's656409151'] | [3060.0, 3064.0] | [44.0, 44.0] | [273, 275] |
p03805 | u085910248 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['n, m = map(int, input().split())\ncolor = [0] * n \npath = [[] for _ in range(m)]\n\nfor i in range(m):\n a, b = map(int, input().split())\n path[a-1].append(b)\n path[b-1].append(a)\n\nprint(path)\ndef rec(c, p, crnt, d):\n d += 1\n if c[crnt] == 1:\n if len(list(filter(lambda x: x == 1, c))) == m and d == m+1:\n return 1\n else:\n return 0\n elif c[crnt] > 1:\n return 0\n else:\n c[crnt] += 1\n sm = 0\n for i in p[crnt]:\n sm += rec(c, p, i-1, d)\n return sm\n\nprint(rec(color, path, 0, 0))\n', 'from itertools import permutations\nn, m = map(int, input().split())\nv = [set(map(int, input().split())) for _ in range(m)]\n\nans = 0\nx = [i for i in range(2, n+1)]\ncand = permutations(x)\nfor i in cand:\n crnt = 1\n for nxt in i:\n if set([crnt, nxt]) in v:\n crnt = nxt\n else:\n break\n else:\n ans += 1\nprint(ans)\n'] | ['Runtime Error', 'Accepted'] | ['s038320816', 's909355246'] | [3064.0, 3064.0] | [17.0, 46.0] | [575, 359] |
p03805 | u089032001 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['import itertools\n\nn, m = map(int, input().split())\npath = [set()] * n\nfor _ in range(m):\n a, b = map(int, input().split())\n path[a-1].add(b-1)\n path[b-1].add(a-1)\nexample = [i for i in range(n)]\n\nans = 0\nfor ex in itertools.permutations(example):\n for a, b in zip(ex, ex[1:]):\n if b not in path[a]:\n break\n else:\n ans += 1\nprint(ans)', 'import itertools\n\nn, m = map(int, input().split())\npath = [[False for _ in range(n)] for __ in range(n)]\nfor _ in range(m):\n a, b = map(int, input().split())\n path[a-1][b-1] = True\n path[b-1][a-1] = True\nexample = [i for i in range(1, n)]\n\nans = 0\nfor ex in itertools.permutations(example):\n e = [0] + list(ex)\n for a, b in zip(e, e[1:]):\n if path[a][b] is False:\n break\n else:\n # print(e)\n ans += 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s572137957', 's511656028'] | [3064.0, 3064.0] | [81.0, 27.0] | [349, 460] |
p03805 | u094999522 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['import itertools\n(n,_),*a= [[*map(int,i.split())] for i in open(0)]\np=itertools.permutations(range(1,n+1),n)\nc = 0\nfor i in p:\n for j in range(n-1):\n if sorted([i[j],i[j+1]]) not in a:\n break\n else:\n c+=1\nprint(c)', 'import itertools\n(n,_),*a= [[*map(int,i.split())] for i in open(0)]\np=[[1] + list(i) for i in itertools.permutations(range(2,n+1),n-1)]\nc = 0\nfor i in p:\n for j in range(n-1):\n if sorted([i[j],i[j+1]]) not in a:\n break\n else:\n c+=1\nprint(c)'] | ['Wrong Answer', 'Accepted'] | ['s180448815', 's352232323'] | [9068.0, 9504.0] | [229.0, 56.0] | [244, 271] |
p03805 | u096616343 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['import itertools\nN,M = map(int,input().split())\nr = []\nfor _ in range(M):\n add = list(map(int,input().split()))\n r.append(add)\n r.append(add[::-1])\nA = [i for i in range(2,N + 1)]\nA = list(itertools.permutations(A,N - 1))\nans = 0\nfor check in A:\n q = 0\n p = [1] + list(check)\n for c in range(N - 1):\n if p[c:c + 2] in r:\n q += 1\n if q == N - 1:\n ans += 1\n print(q)\nprint(ans)', 'import itertools\nN,M = map(int,input().split())\nr = []\nfor _ in range(M):\n add = list(map(int,input().split()))\n r.append(add)\n r.append(add[::-1])\nA = [i for i in range(2,N + 1)]\nA = list(itertools.permutations(A,N - 1))\nans = 0\nfor check in A:\n q = 0\n p = [1] + list(check)\n for c in range(N - 1):\n if p[c:c + 2] in r:\n q += 1\n if q == N - 1:\n ans += 1\nprint(ans)'] | ['Wrong Answer', 'Accepted'] | ['s238921217', 's893020814'] | [4340.0, 3572.0] | [69.0, 64.0] | [424, 411] |
p03805 | u098572984 | 2,000 | 262,144 | You are given an undirected unweighted graph with N vertices and M edges that contains neither self-loops nor double edges. Here, a _self-loop_ is an edge where a_i = b_i (1≤i≤M), and _double edges_ are two edges where (a_i,b_i)=(a_j,b_j) or (a_i,b_i)=(b_j,a_j) (1≤i<j≤M). How many different paths start from vertex 1 and visit all the vertices exactly once? Here, the endpoints of a path are considered visited. For example, let us assume that the following undirected graph shown in Figure 1 is given. Figure 1: an example of an undirected graph The following path shown in Figure 2 satisfies the condition. Figure 2: an example of a path that satisfies the condition However, the following path shown in Figure 3 does not satisfy the condition, because it does not visit all the vertices. Figure 3: an example of a path that does not satisfy the condition Neither the following path shown in Figure 4, because it does not start from vertex 1. Figure 4: another example of a path that does not satisfy the condition | ['_N,_M=input().split()\nN = int(_N)\nM = int(_M)\nl = []\nfor i in range(0,M):\n _p, _q = input().split\n l.append((int(_p),int(_q)))\n_A,_B=zip(l)\n\nA=_A+_B\nB=_B+_A\n\n\ndef gen_get_to(_fr):\n global A\n global B\n global nodes\n global step\n for itr in range(0,len(A)):\n if A[itr]==_fr:\n if not B[itr] in nodes[0:step]:\n yield B[itr]\n\ndef move(): #returns whether "move" succeeded or not\n global nodes\n global possible_memo\n global step\n global counter\n global N\n global end_flag\n try:\n _=next(possible_memo[step])\n nodes[step+1]=_\n step+=1\n #print("success move to {}".format(nodes[step]))\n #print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==N-1:\n counter+=1\n #print(\'REACHED GOAL!!!\')\n possible_memo[step]=gen_get_to(nodes[step])\n except StopIteration:\n step-=1\n #print("failed to move")\n if not step==-1:\n pass#print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==-1:\n #print("I fell from the first node")\n end_flag=True\n\nnodes=[0]*N\npossible_memo=[0]*N\ncounter=0\nstep=0\nnodes[step]=1\npossible_memo[step]=gen_get_to(nodes[0])\nend_flag=False\n\nwhile not end_flag:\n move()\n\n\nprint(counter)', 'N,M=input().split()\nl = []\nfor i in range(0,M):\n l.append(input())\n_A,_B=zip(l)\n\nA=_A+_B\nB=_B+_A\n\n\ndef gen_get_to(_fr):\n global A\n global B\n global nodes\n global step\n for itr in range(0,len(A)):\n if A[itr]==_fr:\n if not B[itr] in nodes[0:step]:\n yield B[itr]\n\ndef move(): #returns whether "move" succeeded or not\n global nodes\n global possible_memo\n global step\n global counter\n global N\n global end_flag\n try:\n _=next(possible_memo[step])\n nodes[step+1]=_\n step+=1\n #print("success move to {}".format(nodes[step]))\n #print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==N-1:\n counter+=1\n #print(\'REACHED GOAL!!!\')\n possible_memo[step]=gen_get_to(nodes[step])\n except StopIteration:\n step-=1\n #print("failed to move")\n if not step==-1:\n pass#print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==-1:\n #print("I fell from the first node")\n end_flag=True\n\nnodes=[0]*N\npossible_memo=[0]*N\ncounter=0\nstep=0\nnodes[step]=1\npossible_memo[step]=gen_get_to(nodes[0])\nend_flag=False\n\nwhile not end_flag:\n move()\n\n\nprint(counter)', 'N=7\nM=7\n_A=[1,2,3,4,4,5,6]\n_B=[3,7,4,5,6,6,7]\nA=_A+_B\nB=_B+_A\n\n\ndef gen_get_to(_fr):\n global A\n global B\n global nodes\n global step\n for itr in range(0,len(A)):\n if A[itr]==_fr:\n if not B[itr] in nodes[0:step]:\n yield B[itr]\n\ndef move(): #returns whether "move" succeeded or not\n global nodes\n global possible_memo\n global step\n global counter\n global N\n global end_flag\n try:\n _=next(possible_memo[step])\n nodes[step+1]=_\n step+=1\n #print("success move to {}".format(nodes[step]))\n #print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==N-1:\n counter+=1\n #print(\'REACHED GOAL!!!\')\n possible_memo[step]=gen_get_to(nodes[step])\n except StopIteration:\n step-=1\n #print("failed to move")\n if not step==-1:\n pass#print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==-1:\n #print("I fell from the first node")\n end_flag=True\n\nnodes=[0]*N\npossible_memo=[0]*N\ncounter=0\nstep=0\nnodes[step]=1\npossible_memo[step]=gen_get_to(nodes[0])\nend_flag=False\n\nwhile not end_flag:\n move()\n\n\nprint(counter)', '_N,_M=input().split()\nN = int(_N)\nM = int(_M)\nl = []\nfor i in range(0,M):\n _p, _q = input().split()\n l.append((int(_p),int(_q)))\n_A,_B=zip(l)\n\nA=_A+_B\nB=_B+_A\n\n\ndef gen_get_to(_fr):\n global A\n global B\n global nodes\n global step\n for itr in range(0,len(A)):\n if A[itr]==_fr:\n if not B[itr] in nodes[0:step]:\n yield B[itr]\n\ndef move(): #returns whether "move" succeeded or not\n global nodes\n global possible_memo\n global step\n global counter\n global N\n global end_flag\n try:\n _=next(possible_memo[step])\n nodes[step+1]=_\n step+=1\n #print("success move to {}".format(nodes[step]))\n #print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==N-1:\n counter+=1\n #print(\'REACHED GOAL!!!\')\n possible_memo[step]=gen_get_to(nodes[step])\n except StopIteration:\n step-=1\n #print("failed to move")\n if not step==-1:\n pass#print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==-1:\n #print("I fell from the first node")\n end_flag=True\n\nnodes=[0]*N\npossible_memo=[0]*N\ncounter=0\nstep=0\nnodes[step]=1\npossible_memo[step]=gen_get_to(nodes[0])\nend_flag=False\n\nwhile not end_flag:\n move()\n\n\nprint(counter)', '_N,_M=input().split()\nN = int(_N)\nM = int(_M)\nl = []\nfor i in range(0,M):\n _p, _q = input().split()\n l.append((int(_p),int(_q)))\n_A,_B=zip(*l)\n\nA=_A+_B\nB=_B+_A\n\n\ndef gen_get_to(_fr):\n global A\n global B\n global nodes\n global step\n for itr in range(0,len(A)):\n if A[itr]==_fr:\n if not B[itr] in nodes[0:step]:\n yield B[itr]\n\ndef move(): #returns whether "move" succeeded or not\n global nodes\n global possible_memo\n global step\n global counter\n global N\n global end_flag\n try:\n _=next(possible_memo[step])\n nodes[step+1]=_\n step+=1\n #print("success move to {}".format(nodes[step]))\n #print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==N-1:\n counter+=1\n #print(\'REACHED GOAL!!!\')\n possible_memo[step]=gen_get_to(nodes[step])\n except StopIteration:\n step-=1\n #print("failed to move")\n if not step==-1:\n pass#print("map: {}".format(nodes[0:step+1]))\n #print("I am at {}th node".format(step+1))\n if step==-1:\n #print("I fell from the first node")\n end_flag=True\n\nnodes=[0]*N\npossible_memo=[0]*N\ncounter=0\nstep=0\nnodes[step]=1\npossible_memo[step]=gen_get_to(nodes[0])\nend_flag=False\n\nwhile not end_flag:\n move()\n\n\nprint(counter)'] | ['Runtime Error', 'Runtime Error', 'Wrong Answer', 'Runtime Error', 'Accepted'] | ['s071346904', 's242354167', 's916056972', 's974104621', 's687333354'] | [3444.0, 3064.0, 3064.0, 3444.0, 3444.0] | [21.0, 17.0, 18.0, 20.0, 103.0] | [1393, 1330, 1292, 1395, 1396] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.