ICPC Southeastern Europe Contest 2019

Posted 2aptx4869

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ICPC Southeastern Europe Contest 2019相关的知识,希望对你有一定的参考价值。

B(DP)

最重要的是状态转移对同一阶段的影响,

就像01背包优化为什么要倒叙,但这道题不光要倒叙,还要把这阶段的转移先存起来,最后统一保存

就避免了转移同一阶段相互影响

至于排序,当然希望升级多余的经验越多越好。

#include <bits/stdc++.h>
#define RE register
#define P pair<int, int>
#define PP pair<P, P>
#define ll long long
using namespace std;

int n, x, y;
ll f[501][501], ff[501][501];
PP a[501];

bool cmp(PP a, PP b)
{
    return a.first.first < b.first.first;
}

int main()
{
    scanf("%d%d%d", &n, &x, &y);
    memset(f, 0x3f3f3f3f, sizeof f);
    memset(ff, 0x3f3f3f3f, sizeof ff);
    ll flag = f[0][0];
    f[0][0] = 0;
    for (RE int i = 1; i <= n; ++i)
        scanf("%d%d%d%d", &a[i].first.first, &a[i].first.second, &a[i].second.first, &a[i].second.second);
    sort(a + 1, a + 1 + n, cmp);
    for (int i = 1; i <= n; ++i)
    {
        for (int c = 0; c <= x; ++c)
            for (int d = 0; d <= y; ++d)
                ff[c][d] = f[c][d];
        for (int c = x; c >= 0; --c)
            for (int d = y; d >= 0; --d)
            {
                if (f[c][d] == flag) continue;
                if (c != x)
                {
                    int nc = c + a[i].first.first;
                    int nd = d;
                    if (nc > x) nd += nc - x, nc = x;
                    nd = min(nd, y);
                    ff[nc][nd] = min(ff[nc][nd], f[c][d] + a[i].first.second);
                }
                int nd = min(d + a[i].second.first, y);
                ff[c][nd] = min(ff[c][nd], f[c][d] + a[i].second.second);
            }
        for (int c = 0; c <= x; ++c)
            for (int d = 0; d <= y; ++d)
                f[c][d] = ff[c][d];
    }
    if (f[x][y] == flag) f[x][y] = -1;
    printf("%lld", f[x][y]);
    return 0;
}

D(造就完了)

#include <bits/stdc++.h>
using namespace std;

char s[1000005];
int a[26], len = 1, n;
vector<int> ve;

int main()
{
    scanf("%s", s + 1);
    for (int &i = len; s[i]; ++i) ++a[s[i] - a];
    --len;  len >>= 1;
    for (int i = 0; i < 26; ++i)
        if (a[i] >= len) ve.emplace_back(i), ++n;
        else if (a[i]) ++n;
    if (ve.size() > 1 || (ve.size() == 1 && n < 3)) 
    {
        puts("NO");
        return 0;
    }
    puts("YES"); 
    if (!ve.empty())
    {
        a[ve[0]] -= len;
        for (int i = 1; i <= len; ++i) printf("%c", ve[0] + a);
        for (int i = 0; i < 26; ++i)
            if (a[i] && i != ve[0]) 
            {
                --a[i]; printf("%c", a +i);
                break;
            }
        while (a[ve[0]]--) printf("%c", ve[0] + a);
    }
    for (int i = 0; i < 26; ++i)
        while (a[i] > 0) printf("%c", i + a), --a[i];    
    return 0;
}

F(树删边,nim)

#include <bits/stdc++.h>
using namespace std;

const int N=1e5 + 5;

vector<int> vec[N];
int n;

int dfs(int u, int fa) 
{
    int re = 0;
    for (int i = 0; i < vec[u].size(); ++i) 
        if (vec[u][i] != fa) 
            re ^= 1 + dfs(vec[u][i], u);
    return re;
}

int main() 
{
        scanf("%d", &n);
        for (int i = 1, a, b; i < n; ++i)
        {
            scanf("%d%d", &a, &b);
            vec[a].push_back(b);
            vec[b].push_back(a);
        }
    printf(dfs(1,0)?"Alice":"Bob");
    return 0;
}    

 

以上是关于ICPC Southeastern Europe Contest 2019的主要内容,如果未能解决你的问题,请参考以下文章

2021 ICPC Southeastern Europe Regional Contest C. Werewolves

2021 ICPC Southeastern Europe Regional Contest C. Werewolves

Level Up - ICPC Southeastern Europe Contest 2019(简单DP)

2020-2021 ICPC Southeastern European B. Reverse Game(思维,博弈)

2016-2017 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2016)

2020-2021 ICPC Southeastern European M. Mistake(模拟,拓扑排序)