0w1

Entries from 2016-10-18 to 1 day

CFR 732 D. Exams ( Binary Search + Greedy )

Problem - D - Codeforces 二分搜答案,對於所有考試,一定考最後一個日期,這時候就變區間置點問題,所有考試對應一個區間,且在該區間必須放置 k 個點。 注意考試時不能讀書。 bool cmp( pii a, pii b ){ if( a.first != b.first ) return a.first > b.fir…

ABC 045 D - すぬけ君の塗り絵 ( Ad hoc )

D: すぬけ君の塗り絵 / Snuke's Coloring - AtCoder Beginner Contest 045 | AtCoder 考慮每個點在分別在九宮格的每個可能位置上的那九宮格數量。對於每個那樣的點那樣的位置,增加對應的塗色數計數。由於包含 x 個點的九宮格會被算 x 次,最後要做一次除法…

台北市104 學年度資訊學科能力競賽 心得

事隔一年,看題目覺得都好水。。。當初是有多傻才沒辦法拿個能看得分數。

台北市104 學年度資訊學科能力競賽 pE. Saving Ryan( DP )

dp[ i ][ j ][ t ] : 到達 ( i, j ) 時,有無使用過炸彈( t ),此時最小的總值 因為可以上下左右彎來彎去,所以用 dijkstra 更新。 tuple 真好用。 #include <bits/stdc++.h> using namespace std; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< vv</bits/stdc++.h>…

台北市104 學年度資訊學科能力競賽 pD. Guess ( DP )

dp[ i ][ j ] : 考慮完 B 字串的第 i 個字元,其尾端有 j 個字元是 A 字串的前綴,且B不含A,此時修改次數的最小值。 修改最後一個字元之後,尋找其最長的後綴使 A 的前綴與之相同。這部分用預處理。 #include <bits/stdc++.h> using namespace std; typedef vector< int > </bits/stdc++.h>…

台北市104 學年度資訊學科能力競賽 pC. Underdog ( 田忌賽馬 )

暴力判斷就可以了。 顯然把最強的K + 1個依序跟對手最弱的K + 1個比,一定最優。 #include <bits/stdc++.h> using namespace std; typedef vector< int > vi; typedef vector< vi > vvi; typedef pair< int, int > pii; typedef vector< pii > vp; int K, N; vi S; // team </bits/stdc++.h>…

台北市104 學年度資訊學科能力競賽 pB. Party ( LCS )

把其中一個字串的0和1對調就是標準的 LCS。 #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef pair< int, int > pii; template< class T1, class T2 > bool upmin( T1 &x, T2 v ){ if( x</bits/stdc++.h>…

台北市104 學年度資訊學科能力競賽 pA. Prime ( 神秘暴搜 )

時間複雜度很神秘混沌的題目。竟然這樣暴搜就可以過了。如果有人可以提出證明它是好/壞的,請務必告訴我。 用質數篩法把質數表先建出來後,對每次的詢問進行遞迴求解,無需剪枝。 注意不能減去比當前的數字大的質數,你會花很久時間才發現你是怎麼逾時的。 #…