当前位置:   article > 正文

Codeforces-April Fools Day Contest 2020-E-图片坐标_april fools day contest 2021 a

april fools day contest 2021 a

这是我做的图片(Codeforces@LetMeFly)
这是我做的图片(Codeforces@LetMeFly)

做了一张有坐标的图片,可能会帮助你解答E题
Having a picture with coordinates may help you solve E problem

E. Jordan Smiley
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output

Input
The input contains two integers row, col (0≤row,col≤63), separated by a single space.

Output
Output “IN” or “OUT”.

这是题目的图片
(这是题目的图片)
Examples
input
0 0
output
OUT
input
27 0
output
IN
input
0 27
output
OUT
input
27 27
output
IN

其实就是判断一个点的坐标在不在封闭图形内。
这是外国一大神的图片Codeforces@brezhart
外国大神的评论以及代码是:(Codeforces@brezhart)
First: fill area in photoshop

Second: Do 2d dimension arr. Check pixel at (i15)+5 (g15)+5. If it’s white, put 0 in arr else put 1; Save that arr in file for use it in final solution. I picked Node.JS for this step.

var fs = require("fs");
var Canvas = require("canvas");

let fileLink = "smile.png";
var canvas = new Canvas.Canvas(960, 960, "png");
var ctx = canvas.getContext("2d");

const Image = Canvas.Image;
var image = new Image(963,964);
dataArr = [];
image.onload = function () {
    ctx.drawImage(image,-2,-2,963,964);
    for (let i = 0; i < 64; i++){
        let newStr = [];
        for (let g = 0; g < 64; g++){
            var p = ctx.getImageData((g*15)+4, (i*15)+4, 1, 1).data;
            if (p[2] < 240){
                newStr.push(0)
            } else {
                newStr.push(1)
            }
        }
        dataArr.push(newStr)
    }
    fs.writeFileSync("DATAOUT.txt",JSON.stringify(dataArr))
};
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26

image.src = fileLink;
Final solution: just get row and col and check arr[row][col] if it’s 0 print “OUT” else print “IN”

这需要时间啊 …………

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/74357
推荐阅读
相关标签
  

闽ICP备14008679号