Leetcode 990: 等式的满足性

题目来源:https://leetcode.com/problems/satisfiability-of-equality-equations/

题目描述:

给一字符串数组,每个元素是一个等式,表示两个变量之间的关系。每个等式长度为4,形如 “a==b” 或者 “a!=b”,a 和 b 两个小写字母表示变量名,a和b可能相同。

如果能给这些变量分配数字,并满足这些等式,返回 true。

解题过程:

开始想着,遇见新变量且没有约束就赋新值,有约束就按照约束来,如果现有的约束冲突了,就返回false。

比如,a==b,b!=c, c==a。第一步,a自由赋值,b=a;第二步,c自由赋值,不等于b即可;第三步,a、c都已经初始化了,且不想等,故返回false。

但是,a==b,c==d,b==c。第一步,a、b自由赋值,且相等;第二步,c、d自由赋新值,且相等;第三步,b、c均初始化,而且不想等,返回false。但实际上,应该返回true。

后来想了想,这个不就是一个并查集吗?把所有相等的变量放到一个集合。然后判断不想等的是不是在一个集合中,如果是,返回false。

简而言之,数组中每一个节点都记录了父节点的下标,如果指向了自己,则自己是父节点。

阅读更多

怪屋女孩:灵魂博物馆

刚刚读完了 Library of Souls - The Third Novel of Miss Peregrine’s Peculiar Children

我读这本书其实是为了学英语,但作为一本冒险小说,设定还是很有新意的,尤其是那些照片,还有男主的女朋友!

不过,这种故事是典型的英雄之旅(Hero’s journey)的模版。读到最后,回忆主角经历的种种,恍若隔世,还是蛮温馨的。


接下来是我的笔记,见笑了。

She wished me luck and kissed me on the lips. Then I looked at Sharon, who tilted his head at me as if to say, I hope you’re not expecting a kiss from me, too, and I just laughed and walked toward the fighters.

这个梗在漫威电影里面也有用到

Just because I’m a capitalist doesn’t mean I’m a black-hearted bastard.

我是一个资本家,但这并不意味着我是一个黑心的混蛋

“Gold coins!” said Emma, fairly spitting with disgust. “What about the well-being of your fellow peculiars? What about loyalty?”
Sharon chuckled. “If I cared about things like that, I’d have been dead long ago.”

Sharon说的很有道理,居然无法反驳

He was a hoarder, like his brother, of strange and ghastly things—only where Bentham was organized to a tee, Caul badly needed a maid.

badly needed,哈哈

“In the tales that are told about us after our victory, I should like to be known as Addison the Intrepid.”
“And so you shall,” said Emma.
“Make that Extremely Intrepid,” Addison said. “And handsome.”
“Done,” I said.

这两个应该算是英式幽默吧,Addison Intrepid and Handsome!

阅读更多

Billionaire

The topic is billionaire, namely, If you had a billion dollars, what would you do.

How about browsers billionaires firstly? No, it isn’t interesting.

What can we do with those non-existent one billion dollars?

Hey, I am a man, the cosmetics, the luxuries, will not be on the top of the list.

The simplest thing is buying an island, for fun? I can’t find the reason.

Seriously, The spacecraft can be the first. There are space stations built by NASA(acronymized by National Aeronautics and Space Administration) and CNSA(acronymized by China National Space Administration). But I prefer crewed spacecraft because I could be a crew.

The second can be supporting research institute. How about research on immortality? It sounds like perpetual motion, does it? Namely, it’s medical research, that we can prolong the lifespan until eternity. When a  scientist states that something is impossible, he is very probably wrong. And the cosmology research is what I want to sponsor if the money is enough. Earth is the cradle of humanity, but one cannot live in a cradle forever.

But, one billion dollars isn’t enough, neither for research or spacecraft. The budget is certainly limited, right?

Here is some billionaire we mentioned:

  • Rockefeller, an American oil industry business magnate, had 400 billion dollars. But Rockefeller has died, so let’s move on.
  • Zuckerberg, Facebook co-founder, also a philanthropist, has 56 billion dollars.
  • Larry Ellison, Oracle co-founder, has 59 billion dollars.
  • Larry Page, Google co-founder, has 53 billion dollars.
  • Bill Gates, Microsoft co-founder, has 95 billion dollars.
  • Jeff Bezos, Amazon co-founder, has 137 billion dollars.
阅读更多

The woman on the bus was molested

On 25th, Sep, domestic violence happened at a bus at Beiliu City, Guangxi Provence.

According to the video, a woman moved to bus’s roar exit gate, trying to get off at the next station. The man pulled the woman off the rear of the bus while the woman tried holding on the handles. The man threw the girl to the last row of seat and sat beside her. The woman was screaming throughout the video.

At first, the video is thought to have happened at Zhongshan City, Guangdong Provence. After investing, police at Zhongshang declared that it didn’t happen in Zhongshan.

Later, a reporter contacted the police in Beiliu City, Guangxi Provence, which confirmed the violence happen at Beiliu City, Guangxi Provence.

Sadly, the police’s response in the video shows the lack of legal knowledge:

“The man and the woman are factual marriage, which means they haven’t registered, hadn’t a marriage certificate. They have one child. The woman is too young to register for marriage. And the police has told the man not to use violence.”

According to Chinese laws, the statement from police doesn’t make sense.Factual marriage was deprecated since 1994, and it should be considered illegal cohabitation. The police should know it well. By all means, neither the marriage or the child doesn’t make the domestic violence legal. So, Why didn’t the police protect the woman?

We should notice that no one stood up to protect the woman at the bus. But the most important things is the police just tried to muddle through, not protect the woman.

阅读更多

How to enable AV1 support?

AV1 is a product of the Alliance for Open Media (AOM). AOM was founded in September 2015 by Google, Mozilla, Cisco, Microsoft, Netflix, Amazon, and Intel to create the next generation video codec for the Internet. Recently, Youtube is working on AV1 support. we can set AV1 as preference encodes at Youtube!

How to try it?

You can open the url, https://www.youtube.com/testtube. If your browser support AV1, it show like that:   You can set your AV1 preference. If your browser doesn’t support AV1, the pages looks like this: But, you can try to enable AV1 support: For Firefox, open about:config?filter=media.av1.enabled, search media.av1.enabled, set it to true: Now, try it again. For Chrome-like, open chrome://flags/#enable-av1-decoder, set Enable AV1 video decoding. to Enabled. And try again.

Now, test it at Youtube

Open Youtube AV1 Beta Launch Playlist, play it. Right click video, open Stats for Nerds. And if Codecsis something like av01.***. You are in!

阅读更多

A freshman was expelled, because of killing a stray cat

In 10th, Sep, a stray cat was killed, by bows and arrows. A member from the animal protection society of HBUE(Hubei University of Economics) said that the cat was found in the trash, then sent to the hospital for surgery. Unfortunately, the cat was dead. He said, “When he is killing the cat, His friend is recording video” In 18th, Sep, HBUE announces that the cat-killer is a freshman from further education college, enrolled in 2018. And, the killing didn’t happen on campus. The police were investing. In 20th, Sep, the college announces that the freshman was expelled. That’s what happened.

Is there any law he violated?

Strictly, It’s Cruelty to animals(according to P.L. 89-544, which is American law). But in China, there isn’t a specific law to protect pets. Sadly, the freshman’s behave isn’t illegal.

So, how about regulations?

According to the college’s announcement,

Announcement from HBUE, source: https://weibo.com/2174871542/GAfikEJlx

the college just announces the punishment but doesn’t give the specific regulations. It’s really unprofessional. It seems like we punish him, just because he violated the regulation which doesn’t exist. When some bad thing happened, we should think about it. Why there isn’t a low for an animal’s welfare? We shouldn’t be happy just for punishment without clear regulation. At the same time,

Today he kills the cat. Tomorrow, He will kill people.

is widely spread in Weibo bizarrely. They asks for punishment with one voice, but not for a fair law.

Let’s narrow it to laws and regulations:

阅读更多

The story about Chang(伥)

First and fomoest, Chang(伥) is a kind of Chinese ghost. Some ancient Chinese books describe Chang.

Guangyiji

In Tang dynasty, Dai Fu, written a book Guangyiji, to record mysterious, supernatural things. At chapter Xuanzhouer, he writen,

At the end of TIANBAO(C.E. 742-756) in Tang dynasty. There is a child living near to the mountain, at Xuanzhou. Every night, he always seeing a ghost leading a tiger to cheat himself. This happened more than ten times. The child told parents, “I will die because the ghost was leading a tiger. People are saying,’If someone is eaten by a tiger, then he will become Chang’. I will become Chang, if I died. If that happened, I will lead tiger to village. You can set a trap in the road it must take, and you can catch a tiger”. Several days after, the child died by the tiger. long time after, his father have a dream that the child said, “I have been Chang already. I will lead tiger to village. You can set a trap in the west of the village.” The father set the trap. when the trap was set, a tiger was caught.

Beimengsuoyan

In book Beimengsuoyan, which was written by Sunguangxian in Ming dynasty, recorded:

One died by tiger, or drown in water, will become Chang. They must seek someone to replace themselves.

This is a definition of Chang. But later, Chang’s meaning narrowed to a ghost was died by tiger.

Zhengzitong, Tingyujitan

The book named Zhengzitong, Tingyujitan, which was written in later years of Ming dynasty, give more detail about Chang:

阅读更多

"For Freedom!" and following performance was canceled

Here are the original report of Süddeutsche Zeitung:

He has the impression, wrote one on the Internet after the performance of Henrik Ibsen’s “People’s Enemy” by the Schaubühne Berlin in Beijing, as if “the chickens wanted to tell the ducks something”. It can happen that chickens and ducks talk to each other. For example Norwegians with Germans, Germans with Chinese and the creatures of existing capitalism with those of newly inventing socialism. That a text from the 19th century is addressed to an audience from the 21st, and the audience then turns to the actors. And that it becomes turbulent. It may be that those in charge at Beijing end of last week were fully confident in the old Chinese wisdom that chickens and ducks do not understand each other anyway. But it can also be that the poultry suddenly discovers that it speaks a common language. And that this discovery makes those responsible so upset that they first want to pull the plug. The Schaubühne is not a freshman in China. The ensemble has performed here more than 40 times over the past four years. The website of the National Theater in Beijing praises her as a “dream team” of the German theater world, which now enjoys a “legendary” reputation in China. The “People’s Enemy” staging of the Schaubühnen director Thomas Ostermeier states that it is of “dazzling brilliance”. But whether one of the Beijing censors watched the play before the premiere last Thursday? Rather not. A classic, they will have thought, 130 years old, what should go wrong? Otherwise it would hardly have come to the excitement after the performance, to a crisis meeting until dawn, to the demands on the German ensemble, they should immediately remove the offensive place from the play, for the immediate stop of ticket sales. The brief News of the Beijing News said: “The play ‘People’s Enemy’ is being ‘adapted’ and the sales channels will be closed.”

Shortly before the end of the play the bath doctor Dr. Ing. Stockmann a speech to the citizens of his community. He wants to warn them about poisoned water and the corruption of the dignitaries of their place. Ostermeier used excerpts from the anti-capitalist pamphlet “The Coming Uprising”, which caused a sensation in France after the 2009 financial crisis. Above all, he lets the scene flow into a dialogue with the audience. Tobias Veit, director of the Schaubühne, says the ensemble did not know what to expect in Beijing. “And then we were flattened,” he says. For 15 minutes, the audience called up the reasons for their sympathy with the main character to the stage. “Because we are for the freedom of speech”. “Because China’s media does not speak the truth.” “Because our government acts just as irresponsibly here.” One could read the scene for a short time in the social media, something in the Wechat account of the viewer “Jingerna erjingxiaoshi”: “I was sweating inside,” he writes. “I thought: pronouncing such things in the National Theater - are not they afraid of a ban?” For a short time, the ban actually stood in the room: the functionaries of the theater made it clear to Veit that further performances take place only if the actors renounce the dialogue with the audience. This could raise “misunderstandings”. The ensemble then advised, says Veit - and decided against a rejection: “We would have left scorched earth, and the scandal would have had a forum in Germany alone,” says the director. The actors decided to shorten the dialogue, but to mark the censored passage as such: “The audience should know that something has happened here, that something is missing”.

The spectators sympathize with the upright, who puts on the power

It has celebrated the “enemy of the people” as a criticism of capitalism and democracy. And now Ibsen’s play in China is perceived as a mirror of the circumstances. Amazing? Not really. Fraud, hypocrisy, cover-ups by the authorities and the media, a swamp of corruption, a “bottomless poisoned society”, the lone fighter for the truth, who is declared a “madman” are all too familiar to humans. Friday evening. It’s the first performance after the near miss. Stockmann gives his speech. Then the question of the publisher Aslaksen: Who agrees with the speaker, the radical, the madman? Almost everyone in the hall in Beijing raise their hands. To assume that they do not care about the speech just given. They sympathize with the upright, who has taken on the power. Some yell. Demand: Do you even understand what he said? An older viewer can no longer hold to himself: “For the rights of the individual!” calls he. “For the freedom!” Occasional “Bravo!” Calls sound. The actors are standing on the stage, silently. “Dear spectators,” says the physician Stockmann (Christoph Gawenda), finally, “at this point a dialogue should actually have taken place with you. - he tears open the publisher (David Ruland) - “the Mr. publisher has no voice”. “Incredible,” says one of the viewers in the foyer of the National Theater, “100 years old - and I recognize the China of today”. His companion pulls out her cell phone. “Oh,” she says. “I better not put that on Wechat. Too tricky.”

Currently, the planned performance in Nanjing City, Jiangsu province, was canceled by “stage technical reason”:
the planned performance in Nanjing City, Jiangsu province, was canceled

阅读更多

Food poisoning in guilin academic conference

23rd to 25th of August 2018, CAD&CG, GDC held in Guilin, Guangxi Provence, China. After the 25th launch, many attendees started headaches, fever, diarrhea, abdominal pain, nausea, and vomiting. In 27th, attendees received an emergency notification, said that authority confirms it’s a Salmonella poisoning. Here is the official report:

A food poisoning occurred at about 7 o ‘clock on August 26, 2018, at the Dihe international hotel in Guilin. As of 18:00 on August 27, a total of 159 people were admitted to the hospital for examination and 92 were hospitalized, with no critical or fatal cases. At present, 20 people remain in the hospital for observation.

official report

Here is a Unofficial information: 600 people attend this conference, include 70 years old professors, some young professors. It also said more than 300 suffer from the toxic symptom. Some old professors started to get poisoning symptoms in return trip and don’t receive promote medical treatment. Even worst, some young teacher received critical condition notice. Some professors have written testament. A female professor, without knowing to be pregnant, was informed that the baby maybe infanted by Salmonella, that means there is a risk of fetal malformation. The doctor suggests abortion. Here is the screenshot of chatting.

The doctor suggests abortion

What’s the hotel’s current situation?

Officially, the hotel was shut down pending further investigation. But, according to some Weibo, the hotel is still opening.

But above is not the worst.

Some people commit on relative Weibo, forum thread:

阅读更多

Shadowsocks + simple-obfs + IPv6 [CentOS 7]

Sometimes, the network traffic need to be encrypted and obfuscated. shadowsocks + simple-obfs is a simple solution. shadowsocks is a socks5 proxy, with traffic encryption. all traffic through shadosocks will be encrypted. simple-obfs is used for obfuscate traffic. The upstream traffic encapsulation in HTTP or tls stream. The outer traffic will look like an HTTP session.

Server-side config

Install shadowsocks, simple-obfs

Enable copr and install:

curl https://copr.fedorainfracloud.org/coprs/antonchen/proxy/repo/epel-7/antonchen-proxy-epel-7.repo -o /etc/yum.repos.d/antonchen-proxy-epel-7.repo
dnf install shadowsocks-libev simple-obfs

Config shadowsocks:

# cat /etc/shadowsocks-libev/config.json
{
“server”: [“[::1]“, “127.0.0.1”],
“server_port”: 8888,
“password”: “Password”,
“timeout”: 600,
“method”: “salsa20”,
“fast_open”: true,
“workers”: 2,
“plugin”: “obfs-server”,
“plugin_opts”: “obfs=http;fast-open=true”
}

server with value ["[::1]", "127.0.0.1"] means listen 127.0.0.1 and ::1(localhost in IPv6), not listen all interface. fast_open means use TCP Fast Open, but with plugin, so actually 8888 is listened by obfs_-server, so we add fast-open=true to plugin_opts._ ipv6_first means while proxying DNS request, use IPv6 firstly. When you access google.com via proxy, you will use IPv6. Start it, make it autostart:

systemctl start shadowsocks-libev
systemctl enable shadowsocks-libev

Then,

阅读更多