Codeforces Round #288 (Div. 2)

A. Pasha and Pixels

Brute force.

There are multiple ways to form a 2*2 square at one single step.

Alt text

So at every step, we have to check the neighbours of pixel that is colored black.

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

#define …
more ...

Sequence Median

Description

Given a sequence of integer numbers, try to find the median of the sequence.

Extending

  • Make sure your code can get the right answer in any conditions
  • Make sure your code work effectively on some special kinds of sequence. For example, ordered sequence or a nearly ordered one, a …
more ...

类型-长度-值(TLV)协议

在数据通信协议中,可选的信息或字段通常使用type-length-value(a.k.a TLV)元素来进行编码。

  • Type - 类型

用来标示字段类型的值,通常是一个二进制值或简单的字母

  • Length - 长度

字段长度,单位通常为Byte

  • Value - 值

一个变长的比特数组用来存储这个字段的值

优势

  • TLV序列方便遍历查找
  • 新的字段可以无痛的加入现有的协议中。解析的时候,对于未知的字段,可以轻松的跳过。这点与XML类似
  • TLV元素的顺序可以是随意的
  • TLV元素通常使用二进制存储,可以使解析速度加快并且使数据更小
  • TLV可以与XML数据相互转换,易于人类阅读

例子

在这里,我们以protobuf的可选和变长字段为例。

field_number ++ wire_type

每一个protobuf的字段在传输时,都会加上field_numberwire_type这两个值,这两个值组成这个字段的key。

key = (field_number << 3) | wire_type

field_number标明了字段的编号,方便协议向前向后的兼容。而 …

more ...

Reasons They Recruit

From Ace of Programming Interview, Cpt1 - Hiring Programmers: The Inside Story

Establish a Rapport

For an interviewee, one the the most efficient way to build a rapport is to try to see things in from the interviewer's perspective.

  • understand the motivation of the interviewer
  • establishing a common ground
  • adapting your …
more ...


The Checklist of Steve Yegge

Hey man, I don't know that stuff

Stevey's talking aboooooout

If my boss thinks it's important

I'm gonna get fiiiiiiiiiired

Oooh yeah baaaby baaaay-beeeeee....

非技术部分

热身

好好读一本讲数据结构和算法的书

熟悉一些“术语”,可以强化分辨问题的能力。

Yegge推荐了 Steven S. Skiena 的《算法设计手册》,而我推荐的是 Udi Manber 的《算法引论》

每一本书都有它的长处短处。找一本评价不错的书,认真读完,肯定会有收获。

找个朋友来面试你,尝试白板编程

在白纸/白板上编程的体验和在计算机上大有不同。没有条件的情况下 …

more ...