>  기사  >  웹 프론트엔드  >  Codeforces Round #267 (Div. 2) 水了一发 真.记录_html/css_WEB-ITnose

Codeforces Round #267 (Div. 2) 水了一发 真.记录_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 11:57:38932검색

闲着没事就水了一发DIV2,本来想新注册一个小小号来着。结果验证码一直显示不出来。于是就用小号做。

结果rank44,但是没有rating.


以下均不解释题意了。


A:O(n)脑残模拟。

Code:

#include <cstdio>int main() {    int n, a, b;    scanf("%d", &n);    int res = 0;    while(n--) {        scanf("%d%d", &a, &b);        if (a + 2   <br> B:注意到两个数相异或后得出的结果的二进制表达中1的位数就是不同的个数。反正怎么做都行,O(nlogn)水。  <p></p>  <p>Code:</p>  <p></p>  <pre name="code" class="sycode">#include <cstdio>#include <cstring>#include <cctype>#include <iostream>#include <algorithm>using namespace std;#define M 1010int a[M];int count(int x) {    int res = 0;    for(; x; x -= x & -x)        ++res;    return res;}int main() {    int n, m, k;    scanf("%d%d%d", &n, &m, &k);    register int i, j;    int S = (1   <br> C:显然是dp,设f[i][j]表示第i段的结尾为j时的最优值,显然f[i][j]=max{f[i-1][k]+sum[j]-sum[j-m]}(0  <p>不过这样是O(k*n^2),可能超时。</p>  <p>我们发现每一阶段的转移能用到的最优状态都是上一阶段的前缀最优值,于是dp时直接记录下来用来下面的转移,这样就不用枚举了,变为O(k*n)水过。</p>  <p>貌似卡内存,用了滚动数组。</p>  <p></p>  <pre name="code" class="sycode">#include <cstdio>#include <cstring>#include <cctype>#include <iostream>#include <algorithm>using namespace std;#define N 5010long long a[N];long long dp[2][N], sav[2][N];int main() {    int n, m, num;    scanf("%d%d%d", &n, &m, &num);    register int i, j, k;    for(i = 1; i   <br> D:各种坑爹。我们事实上想要找出一个单词能够通过一系列变换得到的最小答案是多少,不过可能存在环形转移,不能直接做。  <p></p>  <p>于是求出SCC后缩点,每个节点的初始答案等于节点所有内部节点的最优值。然后在DAG上dp即可。</p>  <p>反正就是很恶心。</p>  <p>注意答案可能爆int.</p>  <p></p>  <pre name="code" class="sycode">#include <cstdio>#include <cstring>#include <cctype>#include <iostream>#include <string>#include <algorithm>#include <map>using namespace std;#define N 100010#define E 100010int sav[N];    map<string int> M;inline void low(string &s) {    int len = s.length();    for(int i = 0; i = 'A' && s[i] > s;        low(s);        if (!M[s]) {            M[s] = ++id;            S[id].get(s);        }        sav[i] = M[s];    }        int m;    scanf("%d", &m);    int x, y;    for(i = 1; i > a >> b;        low(a), low(b);        if (!M[a]) {            M[a] = ++id;            S[id].get(a);        }        x = M[a];        if (!M[b]) {            M[b] = ++id;            S[id].get(b);        }        y = M[b];        if (x != y)            addedge(x, y);    }        for(i = 1; i   <p></p>  <p><br> </p> E:待填坑。  <br>  <br> </string></map></algorithm></string></iostream></cctype></cstring></cstdio>
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.