Last Day

老师们都被常州的老师传染了,竟然出了二分题。

第一题  淘淘摘苹果

淘淘四不四有猫病啊,摘个苹果还辣么麻烦。

这道题主要让我崩溃的地方是我布吉岛怎么把同样高度的树进行标记,让它不要在同一次中出现同样高度的树,其他的都还好了。

 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<span class="hljs-built_in">cin</span>&gt;&gt;n&gt;&gt;m;
<span class="hljs-keyword">for</span>(i=<span class="hljs-number">1</span>;i&lt;=n;++i){
    <span class="hljs-built_in">cin</span>&gt;&gt;a[i];
    t[a[i]]++;
    <span class="hljs-keyword">if</span>(a[i]&gt;k) k=a[i];
}
<span class="hljs-keyword">for</span>(i=<span class="hljs-number">1</span>;i&lt;=m;++i)
    <span class="hljs-built_in">cin</span>&gt;&gt;b[i];
<span class="hljs-keyword">for</span>(i=<span class="hljs-number">1</span>;i&lt;=m;++i){
    p=<span class="hljs-number">0</span>;
    <span class="hljs-keyword">for</span>(j=<span class="hljs-number">0</span>;j&lt;=k;++j){
        <span class="hljs-keyword">if</span>(p==b[i]) <span class="hljs-keyword">break</span>;
        <span class="hljs-keyword">if</span>(t[j]&gt;<span class="hljs-number">0</span>){
            t[j]--;
            <span class="hljs-built_in">cout</span>&lt;&lt;j&lt;&lt;<span class="hljs-string">" "</span>;
            p++;
        }
    }
    <span class="hljs-built_in">cout</span>&lt;&lt;endl;
}

第二题  替身使者

这道题目应该用二分,具体代码如下:


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<span class="hljs-built_in">cin</span>&gt;&gt;n&gt;&gt;k;
    <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">1</span>;i&lt;=n;i++)
      <span class="hljs-built_in">cin</span>&gt;&gt;a[i];
    sort(a+<span class="hljs-number">1</span>,a+n+<span class="hljs-number">1</span>);
    <span class="hljs-keyword">while</span>(l&lt;=r)
    {
        m=(l+r)/<span class="hljs-number">2</span>;
        t=<span class="hljs-number">1</span>;
        last=a[<span class="hljs-number">1</span>];
        <span class="hljs-keyword">for</span>(<span class="hljs-keyword">int</span> i=<span class="hljs-number">2</span>;i&lt;=n;i++)
          <span class="hljs-keyword">if</span>(a[i]-last&gt;=m){
            last=a[i];
            t++;
        }
        <span class="hljs-keyword">if</span>(t&gt;=k) l=m+<span class="hljs-number">1</span>;
        <span class="hljs-keyword">else</span> r=m-<span class="hljs-number">1</span>;
    }
    <span class="hljs-built_in">cout</span>&lt;&lt;l-<span class="hljs-number">1</span>&lt;&lt;endl;

这题就是这样了。

第三题 电流

由于默认起点是在房间1,所以用单源算法SPFA。(不会的先学,谢谢)。
从一个点出发修改能到达的点的值,如果更新成功就入队(已在队列的不重复入队)。这些点拥有了一个较之前更优的值,那么可能可以用来更新这个点出发所能到达的点的最优值。
直到所有的点都被修改完为止。

这道题具体代码还未想出。

第四题 行军

这道题目完全看不懂。

题解太扎心了吧,什么叫水到不能再水了???????明明就完全不会啊!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

发表评论

电子邮件地址不会被公开。 必填项已用*标注