Algorithms Weekly 3

An April Fool's week

  • Jordan Smiley(April Fools Day Contest 2020 E)
    给你一张图片,判断\((x,y)\)是否在脸里面。。
  • step1:
    利用画图工具将闭合区域填充:
  • step2:
    用pillow库将图片转为单通道图片并转为矩阵。
from PIL import Image
import numpy as np
path=r"B.png"

im = Image.open(path).convert('L') #三通道转多通道
width = im.size[0]   # 获取宽度
height = im.size[1]   # 获取高度
im2 = im.resize((int(width*1/15), int(height*1/15)), Image.ANTIALIAS)# 缩小15倍
a=np.array(im2)
np.savetxt("1.txt",a)# 颜色矩阵

得到矩阵后,如果\((i,j)\)处小于等于\(128\),设置为\(1\),否则
为0,得到:

/*
* @author:  codancer
* @createTime:  time
*/
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define fep(i,a,b) for(int i=(a);i>=(b);i--)
typedef vector<int> VI;
typedef vector<ll> VII;
typedef pair<int,int> pii;
string maze[64]={
"0000000000000000000000000010101111110100000000000000000000000000",
"0000000000000000000000101110101111010111110000000000000000000000",
"0000000000000000000011101100100011010000100100000000000000000000",
"0000000000000000011111101011111000011110101110100000000000000000",
"0000000000000000111000001011000011110000101110110000000000000000",
"0000000000000010011011111011101111100101100010010100000000000000",
"0000000000000111001001100000101000111100110110110110000000000000",
"0000000000011111101101101110111011100001100100100011100000000000",
"0000000000111111111111100010000011001011001101101001110000000000",
"0000000001111111111111111111101111111001111001111111111000000000",
"0000000011111111111111111111111111111111111111111111111100000000",
"0000000111111111111111111111111111111111111111111111111110000000",
"0000000111111111111111111111111111111111111111111111111110000000",
"0000001111111111111111111111111111111111111111111111111111000000",
"0000011111111111111111111111111111111111111111111111111111100000",
"0000011111111111111111111111111111111111111111111111111111100000",
"0000111111111111111111111111111111111111111111111111111111110000",
"0001111111111111111111111111111111111111111111111111111111111000",
"0000011111111111111111111111111111111111111111111111111111111000",
"0000000111111111111000100111111111111110001010111111111111100000",
"0011000001111111110010001111111111111110100000001111111100000000",
"0011110000011111000110100011111111111111101101100111100000001100",
"0111111100000100011100111001111111111101001000110000000001111110",
"0111111111000001001101101100011111111101101111100100001111111110",
"0111111111111011011100000111001111111000100100001110111111111110",
"0111111111100001000111011100011111111010111110100010010111111110",
"1111111111110111010010011001001111110010010000110111000111111111",
"1111111111100011010110111011101111010111011110011100010111111111",
"1111111111101111110111110001001010000101001011110001110111111111",
"1111111111100000110100111011100010101101101001000100100111111111",
"1111111111110110111101101110001011100000111101011111101111111111",
"1111111111110011100100100011101001110111100101110001000111111111",
"1111111111111000001101110110111011000001001101100100010111111111",
"1111111111111101101100010100001010010101101000110110111111111111",
"1111111111111000111101010101011110110100101110011100011111111111",
"1111111111111010010001110001111000100110000100110001111111111111",
"1111111111111111000111000101101101101100101110100100111111111111",
"1111111111111111110001011111100000111111100010001111111111111111",
"0111111111111111110100001111101011111111111000100111111111111110",
"0111111111111111111111111111111000011111111111111111111111111110",
"0111111111111111111111111111010010111111111111111111111111111110",
"0111111111111111111111111101000111111111111111111111111111111110",
"0011111111111111111111111100010001111111111111111111111111111100",
"0011111111011111111111111111110111111111111111111111111111111100",
"0001111111010111111111111111100011111111111111111111101111111000",
"0001111111000100011111111111001011111111111011111010000111111000",
"0001111111010101001010001101011001010010110001100000101111111000",
"0000111111110001100000100000001100011000000101001110111111110000",
"0000011111110100111101111011100111000011101111101011111111100000",
"0000011111111110100100100010111101110110100000100011111111100000",
"0000001111111110001101101000010001010000111010001111111111000000",
"0000000111111111011100111110110101000101100011111111111110000000",
"0000000111111111001110010100011100011111001000111111111110000000",
"0000000011111111100011110001110110111101111011111111111100000000",
"0000000001111111110111000111100000100001011111111111111000000000",
"0000000000111111111111010111101101101011001111111111110000000000",
"0000000000011111111111110000111100001000011111111111100000000000",
"0000000000000111111111111111111110111111111111111110000000000000",
"0000000000000011111111111111111111111111111111111100000000000000",
"0000000000000000111111111111111111111111111111110000000000000000",
"0000000000000000011111111111111111111111111111100000000000000000",
"0000000000000000000011111111111111111111111100000000000000000000",
"0000000000000000000000111111111111111111110000000000000000000000",
"0000000000000000000000000011111111111100000000000000000000000000",


};
int main(){
	int x,y;
	cin>>x>>y;
	if(maze[x][y]=='1'){
		cout<<"IN"<<endl;
	}else{
		cout<<"OUT"<<endl;
	}
	return 0;
}

猜你喜欢

转载自www.cnblogs.com/codancer/p/12619166.html