第一次做交互真有趣……:挺好的细节思维题 This is an interactive problem. In good old times dwarves tried to develop extrasensory abilities: Exactly n dwarves entered completely dark cave. Each dwarf received a hat — white or black. While in cave, none of the dwarves was…
不难发现,每次询问结果一定是 (i,n)(i,n)(i,n), 而 iii 出现的次数恰好是 iii 到 i′i'i′ 的距离(i′i'i′ 是第一个不与 iii 相等的数).我们可以将这颗树构造成一条链,然后就 AC 了. Code: #include<cstdio> #include<cstdlib> #include<algorithm> using namespace std; const int maxn = 1000 + 5; int idx1[maxn],…