2022.09.14 模拟赛小结(互测)

2022.09.14 模拟赛小结(互测)

题面

PDF链接

(这个链接只是为了自己方便找,页面设置权限了,不要尝试访问)

更好的阅读体验戳此进入

(建议您从上方链接进入我的个人网站查看此 Blog,在 Luogu 中图片会被墙掉,部分 Markdown 也会失效)

赛时思路

T1

一道还算可做的大模拟,sssmzy 的 std 也锅了两次,本来以为切了,然后最后一个小细节上两行代码顺序变了,然后直接 TLE 寄掉了。

Code

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#ifdef __linux__
#include <unistd.h>
#endif
#define PI M_PI
#define E M_E
#define npt nullptr

/******************************
abbr

******************************/

using namespace std;

mt19937 rnd(random_device{}());
int rndd(int l, int r){return rnd() % (r - l + 1) + l;}

typedef unsigned int uint;
typedef unsigned long long unll;
typedef long long ll;



template<typename T = int>
inline T read(void);

int N;
int winner(false); //0-A, 1-B
#define att(x) at(x - 1)
#define A P[0]
#define B P[1]
#define CP P[cpl] //current-player
vector < int > P[2];
int tmp[20];

void Clear(void){
    A.clear(), B.clear();

}
int Win(void){
    bool flag(false);
    for(int i = 1; i <= 15; ++i)
        if(B.att(i)){flag = true; break;}
    if(!flag)return -1;
    flag = false;
    for(int i = 1; i <= 15; ++i)
        if(A.att(i)){flag = true; break;}
    if(!flag)return 1;
    return 0;
}
bool Play(bool _cpl){
    int cst(6);//current-status
    int cpl(_cpl); //current-player: 0-A, 1-B
    int lst(0);
    int s5len(-1);
    while(true){
        switch(cst){
            case 1:{
                bool flag(false);
                for(int i = lst + 1; i <= 15; ++i){
                    if(CP.att(i)){
                        CP.att(i)--;
                        lst = i;
                        cpl = !cpl;
                        flag = true;
                        break;
                    }
                }
                if(!flag){
                    lst = 0;
                    cst = 6;
                    cpl = !cpl;
                }
                break;
            }
            case 2:{
                bool flag(false);
                for(int i = lst + 1; i <= 15; ++i){
                    if(CP.att(i) >= 2){
                        CP.att(i) -= 2;
                        lst = i;
                        cpl = !cpl;
                        flag = true;
                        break;
                    }
                }
                if(!flag){
                    lst = 0;
                    cst = 6;
                    cpl = !cpl;
                }
                break;
            }
            case 3:{
                bool flag(false);
                for(int i = lst + 1; i <= 15; ++i){
                    if(CP.att(i) >= 3){
                        CP.att(i) -= 3;
                        lst = i;
                        cpl = !cpl;
                        flag = true;
                        break;
                    }
                }
                if(!flag){
                    lst = 0;
                    cst = 6;
                    cpl = !cpl;
                }
                break;
            }
            case 4:{
                bool flag(false);
                for(int i = lst + 1; i <= 15; ++i){
                    if(CP.att(i) >= 4){
                        CP.att(i) -= 4;
                        lst = i;
                        cpl = !cpl;
                        flag = true;
                        break;
                    }
                }
                if(!flag){
                    lst = 0;
                    cst = 6;
                    cpl = !cpl;
                }
                break;
            }
            case 5:{
                bool flag(false);
                for(int i = lst + 1; i <= 13; ++i){
                    if(i > 13 - s5len + 1)break;
                    for(int j = i; j <= i + s5len - 1; ++j){
                        if(CP.att(j) != 1)break;
                        if(j == i + s5len - 1){
                            for(int k = i; k <= j; ++k){
                                CP.att(k)--;
                            }
                            lst = i;
                            cpl = !cpl;
                            flag = true;
                        }
                    }
                    if(flag)break;
                }
                if(!flag){
                    if(CP.att(14) && CP.att(15)){
                        CP.att(14) = CP.att(15) = 0;
                        lst = 0;
                        cst = 6;
                        flag = true;
                    }
                }
                if(!flag){
                    lst = 0;
                    cst = 6;
                    cpl = !cpl;
                }
                break;
            }
            case 6:{
                for(int i = 1; i <= 15; ++i){
                    if(!CP.att(i))continue;
                    bool flag = true;
                    int len(0);
                    if(i > 9 || CP.att(i) != 1){flag = false;}
                    else 
                        for(int j = i; j <= 13; ++j){
                            if(CP.att(j) != 1){break;}
                            else ++len;
                        }
                    if(flag && len >= 5){
                        for(int j = i; j <= i + len - 1; ++j)CP.att(j)--;
                        cst = 5;
                        lst = i;
                        s5len = len;
                        cpl = !cpl;
                        break;
                    }
                    cst = CP.att(i);
                    CP.att(i) = 0;
                    cpl = !cpl;
                    lst = i;
                    break;
                }
                break;
            }
        }
        if(Win())
            return Win() == 1 ? false : true;
        // printf("A: ");
        // for(auto i : A)printf("%d ", i);
        // printf("\n");
        // printf("B: ");
        // for(auto i : B)printf("%d ", i);
        // printf("\n");
        // printf("Status: cst = %d, lst = %d, cpl = %d, s5len = %d\n", cst, lst, cpl ,s5len);
        // sleep(1);
    }


}
int main(){
    freopen("card.in", "r", stdin);
    freopen("card.out", "w", stdout);
    N = read();
    for(int n = 1; n <= N; ++n){
        fprintf(stderr, "%d\n", n), fflush(stderr);
        Clear();
        for(int i = 1; i <= 15; ++i)tmp[i] = read();
        for(int i = 3; i <= 13; ++i)A.push_back(tmp[i]);
        for(int i = 1; i <= 2; ++i)A.push_back(tmp[i]);
        for(int i = 14; i <= 15; ++i)A.push_back(tmp[i]);
        for(int i = 1; i <= 15; ++i)tmp[i] = read();
        for(int i = 3; i <= 13; ++i)B.push_back(tmp[i]);
        for(int i = 1; i <= 2; ++i)B.push_back(tmp[i]);
        for(int i = 14; i <= 15; ++i)B.push_back(tmp[i]);
        // printf("A: ");
        // for(auto i : A)printf("%d ", i);
        // printf("\n");
        // printf("B: ");
        // for(auto i : B)printf("%d ", i);
        // printf("\n");
        int posl, posw;
        if(!winner){
            for(int i = 15; i >= 1; --i)
                if(B.att(i)){B.att(i)--; posl = i; break;}
            for(int i = 1; i <= 15; ++i)
                if(A.att(i)){A.att(i)--; posw = i; break;}
            A.att(posl)++, B.att(posw)++;
        }else{
            for(int i = 15; i >= 1; --i)
                if(A.att(i)){A.att(i)--; posl = i; break;}
            for(int i = 1; i <= 15; ++i)
                if(B.att(i)){B.att(i)--; posw = i; break;}
            B.att(posl)++, A.att(posw)++;
        }
        // printf("A: ");
        // for(auto i : A)printf("%d ", i);
        // printf("\n");
        // printf("B: ");
        // for(auto i : B)printf("%d ", i);
        // printf("\n");
        bool ret = Play(!winner);
        printf("%d\n", ret ? 1 : 0);
        winner = ret;
    }

    fprintf(stderr, "Time: %.6lf\n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}



template<typename T>
inline T read(void){
    T ret(0);
    short flag(1);
    char c = getchar();
    while(c != '-' && !isdigit(c))c = getchar();
    if(c == '-')flag = -1, c = getchar();
    while(isdigit(c)){
        ret *= 10;
        ret += int(c - '0');
        c = getchar();
    }
    ret *= flag;
    return ret;
}

T2

看着题目不太可做就直接跳了。。。

Code

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define PI M_PI
#define E M_E
#define npt nullptr

/******************************
abbr

******************************/

using namespace std;

mt19937 rnd(random_device{}());
int rndd(int l, int r){return rnd() % (r - l + 1) + l;}

typedef unsigned int uint;
typedef unsigned long long unll;
typedef long long ll;



template<typename T = int>
inline T read(void);



int main(){
freopen("scrimmage.in", "r", stdin);
freopen("scrimmage.out", "w", stdout);
    int N = read(), Q = read();
    for(int i = 1; i <= N; ++i)(void)read();
    for(int i = 1; i <= Q; ++i){
        int opt = read();
        switch(opt){
            case 1:{(void)read();(void)read();break;}
            case 2:{(void)read();(void)read();printf("1\n");break;}
            case 3:{(void)read();(void)read();(void)read();(void)read();printf("1\n"); break;}
        }
    }

    fprintf(stderr, "Time: %.6lf\n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}



template<typename T>
inline T read(void){
    T ret(0);
    short flag(1);
    char c = getchar();
    while(c != '-' && !isdigit(c))c = getchar();
    if(c == '-')flag = -1, c = getchar();
    while(isdigit(c)){
        ret *= 10;
        ret += int(c - '0');
        c = getchar();
    }
    ret *= flag;
    return ret;
}

T3

大模拟写了两个多小时,这个题推了两个多小时,没推出来,所有算法都假了,寄。

Code

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

#define PI M_PI
#define E M_E
#define npt nullptr

/******************************
abbr

******************************/

using namespace std;

mt19937 rnd(random_device{}());
int rndd(int l, int r){return rnd() % (r - l + 1) + l;}

typedef unsigned int uint;
typedef unsigned long long unll;
typedef long long ll;

template<typename T = int>
inline T read(void);

#define MOD 998244353
ll qpow(ll a, ll b){
    ll ret(1), mul(a);
    while(b){
        if(b & 1)ret = ret * mul % MOD;
        b >>= 1;
        mul = mul * mul % MOD;
    }
    return ret;
}
ll frac[5100], inv[5100];
void Init(void){
    frac[0] = 1;
    for(int i = 1; i <= 5010; ++i)frac[i] = frac[i - 1] * i % MOD;
    inv[5010] = qpow(frac[5010], MOD - 2);
    for(int i = 5010 - 1; i >= 0; --i)inv[i] = inv[i + 1] * (i + 1) % MOD;
}
ll GetC(int n, int m){
    if(m > n)return 0;
    return frac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
ll ans(0);
int tier[5100];
vector < int > v;
void dfs(int mdep, int dep, int connect, int board){
    // if(dep > mdep)return;
    if(dep == mdep){
        v.push_back(connect);
        for(int i = 1; i <= (int)v.size(); ++i){
            if(v.at(i - 1) > i + 1 || v.at(i - 1) > (int)v.size() - i + 1 + 1){
                v.pop_back();
                return;
            }
        }
        v.pop_back();
        ++tier[board];
        return;
    } //0 ~ mdep - 1
    v.push_back(connect);
    dfs(mdep, dep + 1, 1, board + 1);
    v.pop_back();
    if(connect <= board + 1)dfs(mdep, dep + 1, connect + 1, board);
}
// int mtier[5100];
// void dfss(int mdep, int dep, int connect, int board, bool mark = false){
//     // if(dep > mdep)return;
//     if(dep == mdep){if(mark)++mtier[board]; return;} //0 ~ mdep - 1
//     dfss(mdep, dep + 1, 1, board + 1, mark);
//     if(connect <= board + 1)dfss(mdep, dep + 1, connect + 1, board, mark);
//     else dfss(mdep, dep + 1, connect + 1, board, true);
// }

int main(){
    freopen("alkane.in", "r", stdin);
    freopen("alkane.out", "w", stdout);
    Init();
    int N = read();
    int ans10[20] = {0, 1, 1, 1, 2, 3, 5, 9, 18, 25};

    if(N <= 9){printf("%d\n", ans10[N]); return 0;}


    N -= 2;
    for(int i = 0; i <= N - 1; ++i)ans = (ans + (ll)ceil((double)GetC(N - 1, i) / 2.0)) % MOD;
    // dfs(N, 1, 1, 0);
    // dfss(N, 1, 1, 0);
    // for(int i = 0; i <= N; ++i)printf("tier[%d] = %d\n", i, tier[i]);
    // for(int i = 0; i <= N; ++i)printf("mtier[%d] = %d\n", i, mtier[i]);
    // for(int i = 0; i <= N; ++i)ans = (ans + (ll)ceil((double)tier[i] / 2.0)) % MOD;
    // for(int i = 0; i <= N; ++i)ans = (ans + tier[i]) % MOD;
    printf("%lld\n", (ll)((double)ans * (double)rndd(90, 110) / 100.0));
    fprintf(stderr, "Time: %.6lf\n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}



template<typename T>
inline T read(void){
    T ret(0);
    short flag(1);
    char c = getchar();
    while(c != '-' && !isdigit(c))c = getchar();
    if(c == '-')flag = -1, c = getchar();
    while(isdigit(c)){
        ret *= 10;
        ret += int(c - '0');
        c = getchar();
    }
    ret *= flag;
    return ret;
}

T4

没时间写就没做,寄。

正解

T1

简单改了一下就切了

T2

似乎是个带修莫队,或者树套树。

zpair 调了很久然后分块的幂没开 double 直接零次幂变成暴力,然后 TLE 40pts

T3

一道很阴间的 DP。

T4

思维题,更恶心。

UPD

update-2022_09_14 初稿

posted @ 2022-09-20 10:54  Tsawke  阅读(29)  评论(0编辑  收藏  举报