1001. Grid Illumination

There is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off.

You are given a 2D array of lamp positions lamps, where lamps[i] = [rowi, coli] indicates that the lamp at grid[rowi][coli] is turned on. Even if the same lamp is listed more than once, it is turned on.

When a lamp is turned on, it illuminates its cell and all other cells in the same row, column, or diagonal.

You are also given another 2D array queries, where queries[j] = [rowj, colj]. For the jth query, determine whether grid[rowj][colj] is illuminated or not. After answering the jth query, turn off the lamp at grid[rowj][colj] and its 8 adjacent lamps if they exist. A lamp is adjacent if its cell shares either a side or corner with grid[rowj][colj].

Return an array of integers ans, where ans[j] should be 1 if the cell in the jth query was illuminated, or 0 if the lamp was not.

解题要点:
1. 每个点(lamp)对应四条线,判断query的点是否在这些线上。
2. 容易想到通过hashmap保存这些点,映射四条线。但是判断query的时候,时间复杂度为n2。
3. 所以通过hashmap保存四条线,进行计数统计。query在计数大于0的线上,值为1
4. 八个相邻lamp内,用-1到+2的双重循环构造坐标。如果有坐标在lamp集合内,移除坐标,线的计数减一。

1219. Path with Maximum Gold

In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.

Return the maximum amount of gold you can collect under the conditions:

Every time you are located in a cell you will collect all the gold in that cell.
From your position, you can walk one step to the left, right, up, or down.
You can't visit the same cell more than once.
Never visit a cell with 0 gold.
You can start and stop collecting gold from any position in the grid that has some gold.

解题要点:
1. 回溯。枚举每个点作为起点,进行递归和回溯。
2. 规定了「每个单元格只能被开采一次」,因此当我们到达位置(x,y) 时,我们可以将 grid[x][y] 暂时置为 00;在进行回溯之前,再将 grid[x][y] 的值恢复
3. 全局变量保存黄金数量。

今日#英语# #阅读# 分享——Millennium-old tomb restored in China's Shanxi中国山西修复的千年古墓
Source: XinhuaEditor: huaxia2021-12-27 21:02:30

TAIYUAN, Dec. 27 (Xinhua) -- An ancient tomb with rare murals dating back to the Tang Dynasty (618-907) has been restored in north China's Shanxi Province, according to the Taiyuan Northern Qi Dynasty Mural Museum.

The tomb was discovered in an elementary school in Taiyuan, capital of Shanxi, in 2019 and later moved to the museum for protection and restoration.

According to the epitaph, the tomb owner Guo Xing was a mid-ranking military officer in the Tang Dynasty. The roof, walls, coffin bed, corridors and the doors of the tomb were all decorated with exquisite murals.

Defects in the murals such as fissures, hollows and blemishes have been fixed, and the tomb will open to the public in the future, said the museum.

Interestingly, various figures in the mural paintings appear to be making "V" signs with their middle and index fingers.

The exquisite murals of the tomb reveal the noble status of the tomb owner and attest to its historical, artistic and scientific value, said Feng Gang, a researcher at the Taiyuan Institute of Cultural Relics Protection. Enditem

p1:Undated file photo provided by Taiyuan Institute of Cultural Relics Protection shows a part of restored murals of an ancient tomb dating back to the Tang Dynasty (618-907) in Taiyuan, north China's Shanxi Province. The tomb was discovered in an elementary school in Taiyuan, capital of Shanxi, in 2019 and later moved to the museum for protection and restoration.

Defects in the murals such as fissures, hollows and blemishes have been fixed, and the tomb will open to the public in the future, said the Taiyuan Northern Qi Dynasty Mural Museum.

Interestingly, various figures in the mural paintings appear to be making "V" signs with their middle and index fingers. (Taiyuan Institute of Cultural Relics Protection/Handout via Xinhua)

p2:Undated file photo provided by Taiyuan Institute of Cultural Relics Protection shows a part of restored murals of an ancient tomb dating back to the Tang Dynasty (618-907) in Taiyuan, north China's Shanxi Province. The tomb was discovered in an elementary school in Taiyuan, capital of Shanxi, in 2019 and later moved to the museum for protection and restoration.Defects in the murals such as fissures, hollows and blemishes have been fixed, and the tomb will open to the public in the future, said the Taiyuan Northern Qi Dynasty Mural Museum.Interestingly, various figures in the mural paintings appear to be making "V" signs with their middle and index fingers. (Taiyuan Institute of Cultural Relics Protection/Handout via Xinhua)
p3:Undated file photo provided by Taiyuan Institute of Cultural Relics Protection shows a part of restored murals of an ancient tomb dating back to the Tang Dynasty (618-907) in Taiyuan, north China's Shanxi Province. The tomb was discovered in an elementary school in Taiyuan, capital of Shanxi, in 2019 and later moved to the museum for protection and restoration.Defects in the murals such as fissures, hollows and blemishes have been fixed, and the tomb will open to the public in the future, said the Taiyuan Northern Qi Dynasty Mural Museum.Interestingly, various figures in the mural paintings appear to be making "V" signs with their middle and index fingers. (Taiyuan Institute of Cultural Relics Protection/Handout via Xinhua)

原文链接:https://t.cn/A6JvuP3n
来源:新华社


发布     👍 0 举报 写留言 🖊   
✋热门推荐
  • ねりきりとは白餡に餅や芋を混ぜて作った和菓子で茶道 で使われる「主菓子」の一種です。ねりきりとは白餡に餅や芋を混ぜて作った和菓子で茶道 で使われる「主菓子」の一
  • [哇]好太太智能晒衣架入手原因:智能化可以操控晒衣高度,对于懒人不想用晒衣杆晒衣服的我,真的很心水这一点[哇][哇]使用感受:省了阳台装灯的钱,装一个晾衣架它不
  • 不全力以赴支持西西 ​,怎么有底气看新歌首秀的[丰收了][丰收了][丰收了]和@张艺兴 一起“带领华语音乐走向世界”[拳头]我相信 莲粉 永远热血[给力][给力
  • 不过我们在具体搭配的时候,最好是选择带有“收腰设计”的衬衣裙或是风衣,将身材的曲线感展现出来,看起来会更有女人味一些。第二:风衣与裙子的搭配细节细节1:高腰线的
  • 在你面前,她会主动靠近你,敢跟你有肢体上的接触,这就是对你动情的表现。可以说,“三狮”在欧国联的表现“欺骗”了很多球迷,而且在出战伊朗队之前,英格兰队也没有安排
  • 【部门动态|白云区税务局:以数治税 惠民实事越办越好】“‘六税两费’累计减免的近2万元费用对我们小微企业而言,已是雪中送炭,白云区税务局第一时间将好政策送上门,
  • 蓝色衬布:固有色:纯一点的蓝+少量肉色,笔触方向垂直布褶的走向;环境色:周围物体上的颜色调入布的固有色时调生一些;灰色:降低纯度,蓝布亮部的加肉色,中间加紫灰,
  • ”“我的离开并不意味着我们之间关系和友谊的结束,所以问题中心也确实是围绕着我和凯文(加内特)之间,因为我很清楚凯文对这里的人们有多么重要,一旦凯文接受了我,这里
  • 静下来,想想自己能做什么,需要什么,好好的认识自己,接纳自己,动起来,踢开消极,去积累,去实干,咸鱼也能翻身,远远好于一味地空想。不想想自己,抱怨所谓的工作分配
  • #大乘离文字普光明藏经# 大乘离文字普光明藏经是一部求取财富的佛教经典,值得每日修行持诵与传播的殊胜佛经。 开经偈 无上甚深唯妙法,百千万劫难遭遇, 我今
  • 有个病人来了,穿了一身盔甲,手肘以上通通被盔甲盖住了,你下背后也不 行,这个病人是肝硬化、肝病,那肝募期门也没有,肝俞也扎不到,就只能在手脚上下针, 这就是我们
  • 楼外很想了解 BlackPinkROSE Lisa,有喜欢粉墨的宝子可以疯狂安利我[哈哈][哈哈]楼外热巴美女我很爱!#BLACKPINK出道6周年#BL
  • 当然,投诉和起诉的主要目的之一就是要确定对方的货源,如果店家能够提供有效的进货凭证或授权书而导致品牌方投诉失败,那么他们就可以由此追踪溯源,找到对方的出货商,进
  • 1 . 一别两宽,互不相欠,从此陌路,永不相见 2 . 你还是你,我还是我,只是再无我们了 3.因为蕞初红了脸,蕞后红了眼。 4 . 不出现,不打扰,是我最后爱
  • 在进北电之后,有同班同学告诉施子怡,称那一届机构里的艺考女生,基本都被杜英哲骚扰过,几个胆小懦弱的在他的威逼利诱下和他发生了关系。在进北电之后,有同班同学告诉施
  • 那就楚苏一直一起唱歌吧二是姚老板快乐再出发,出新专吧,来讲讲后来这些年的姚老板的那些事,想听以及,现在我要鼓起勇气去考古生哥的演员综艺了,看看他是如何隐身没被拉
  • ”诗人一唱三叹中,浸染着人事胜衰的感慨;在栉风沐雨时,也体味着艳丽与沧桑的不停转换。深夜上头EMO意难平短句☽. “你好”开始 “你好好的”结束☽. 爱常有 相
  • 原来,早上9点多,集市正是热闹的时候,往来的行人中有一女子在摊位边反复溜达,李大姐热情的打招呼,但此女子却不买任何东西。这时前来购物的人多了起来,就在李大姐忙活
  • 3、三湘印象(房地产+旅游文演+Web3.0)周五反包失败,而且医药退潮的时候拉板也没有资金主封,说明房地产方向的预期缺少支撑,下周预计也是冲高回落icon为主
  • 前段时间对半错,严重怀疑我是不是低能儿[傻眼]自从不打王者了以后连triple 都不认识了[二哈]晚上从琴房回来路上拍的,有一个灯灯不亮了[月亮]永远有勇气结束