2023 Xian Jiaotong University Programming Contest

这篇具有很好参考价值的文章主要介绍了2023 Xian Jiaotong University Programming Contest。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

A.大水题

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define fi first
#define se second
#define lc u << 1
#define rc u << 1 | 1
// #define int long long

// #define double long long
// #define int __int128_t
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e7 + 10;

// const int R = 999997;
const int Base = N / 2;
const int M = 1e6 + 10;

// const int P = 1 << 10;
const int INF = 2147483647;

typedef unsigned long long ULL;

const double eps = 1e-4;
const double PI = acos(-1);
const int mod = 1e9 + 7;
int n, k;
int d;
int m;
int Q;
int target;
// int p = INF;
// __int128_t a = 1;

// rope<int> r;
tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> treap;
int primes[N];
bool st[N];
int phi[N];
int cnt;
int T = 0;
LL s[N];

void init(int n)
{
    for (int i = 2; i <= n; i++)
    {
        if (!st[i])
        {
            st[i] = true;
            phi[i] = i - 1;
            primes[cnt++] = i;
        }
        for (int j = 0; primes[j] <= n / i; j++)
        {
            st[i * primes[j]] = true;
            if (i % primes[j])
            {
                phi[i * primes[j]] = phi[i] * phi[primes[j]];
            }
            else
            {
                phi[i * primes[j]] = phi[i] * primes[j];
                break;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        s[i] = s[i - 1] + phi[i];
    }
}

void solve()
{
    scanf("%d",&n);
    if(n <= 6)
    {
        printf("water\n");
    }
    else
    {
        printf("dry\n");
    }
}

signed main()
{
    int t = 1;
    // str = "codeforces";
    // init();
    // cout << cnt << endl;
    // init();
    // scanf("%d", &t);
    // getchar();
    // int a = 1;
    // for (int i = 1; i <= 26; i++)
    // {
    //     a = (a << 1) + 1;
    // }
    // cout << a << endl;
    // float t = 134217727;
    // int cnt = 200;
    // printf("%.16lf", t);
    // while (cnt--)
    // {
    //     t = t * 2 + a;
    //     printf("%.16f\n", t);
    // }
    // getchar();
    // cout << (int)(log(4) / log(2)) << endl;
    while (t--)
    {
        //     cout << t << endl;
        //     // cout << (2563 % 11) << endl;
        //     // cout << t << endl;
        solve();
        //     // cout << (((float)1) << 63) << endl;
        //     // cout << '\0' << endl;
        //     // cout << f(4);
        //     // cout<<(25 >> 5)
        //     // cout << gcd(31415, 14142);//
        //     // cout << (28284 / 11) << endl;
    }
    return 0;
}

/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *                               神兽保佑            永无BUG
 */

/**
 *  ┏┓   ┏┓+ +
 * ┏┛┻━━━┛┻┓ + +
 * ┃       ┃
 * ┃   ━   ┃ ++ + + +
 *  ████━████+
 *  ◥██◤ ◥██◤ +
 * ┃   ┻   ┃
 * ┃       ┃ + +
 * ┗━┓   ┏━┛
 *   ┃   ┃ + + + +Code is far away from  
 *   ┃   ┃ + bug with the animal protecting
 *   ┃    ┗━━━┓ 神兽保佑,代码无bug 
 *   ┃        ┣┓
 *    ┃        ┏┛
 *     ┗┓┓┏━┳┓┏┛ + + + +
 *    ┃┫┫ ┃┫┫
 *    ┗┻┛ ┗┻┛+ + + +
 */
View Code

B.原粥率

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define fi first
#define se second
#define lc u << 1
#define rc u << 1 | 1
// #define int long long

// #define double long long
// #define int __int128_t
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e7 + 10;

// const int R = 999997;
const int Base = N / 2;
const int M = 1e6 + 10;

// const int P = 1 << 10;
const int INF = 2147483647;

typedef unsigned long long ULL;

const double eps = 1e-4;
const double PI = acos(-1);
const int mod = 1e9 + 7;
int n, k;
int d;
int m;
int Q;
int target;
// int p = INF;
// __int128_t a = 1;

// rope<int> r;
tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> treap;
int primes[N];
bool st[N];
int phi[N];
int cnt;
int T = 0;
LL s[N];

void init(int n)
{
    for (int i = 2; i <= n; i++)
    {
        if (!st[i])
        {
            st[i] = true;
            phi[i] = i - 1;
            primes[cnt++] = i;
        }
        for (int j = 0; primes[j] <= n / i; j++)
        {
            st[i * primes[j]] = true;
            if (i % primes[j])
            {
                phi[i * primes[j]] = phi[i] * phi[primes[j]];
            }
            else
            {
                phi[i * primes[j]] = phi[i] * primes[j];
                break;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        s[i] = s[i - 1] + phi[i];
    }
}

void solve()
{
    double a, b;
    scanf("%lf %lf", &a, &b);
    printf("%.9lf\n", a / b);
}

signed main()
{
    int t = 1;
    // str = "codeforces";
    // init();
    // cout << cnt << endl;
    // init();
    // scanf("%d", &t);
    // getchar();
    // int a = 1;
    // for (int i = 1; i <= 26; i++)
    // {
    //     a = (a << 1) + 1;
    // }
    // cout << a << endl;
    // float t = 134217727;
    // int cnt = 200;
    // printf("%.16lf", t);
    // while (cnt--)
    // {
    //     t = t * 2 + a;
    //     printf("%.16f\n", t);
    // }
    // getchar();
    // cout << (int)(log(4) / log(2)) << endl;
    while (t--)
    {
        //     cout << t << endl;
        //     // cout << (2563 % 11) << endl;
        //     // cout << t << endl;
        solve();
        //     // cout << (((float)1) << 63) << endl;
        //     // cout << '\0' << endl;
        //     // cout << f(4);
        //     // cout<<(25 >> 5)
        //     // cout << gcd(31415, 14142);//
        //     // cout << (28284 / 11) << endl;
    }
    return 0;
}

/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *                               神兽保佑            永无BUG
 */

/**
 *  ┏┓   ┏┓+ +
 * ┏┛┻━━━┛┻┓ + +
 * ┃       ┃
 * ┃   ━   ┃ ++ + + +
 *  ████━████+
 *  ◥██◤ ◥██◤ +
 * ┃   ┻   ┃
 * ┃       ┃ + +
 * ┗━┓   ┏━┛
 *   ┃   ┃ + + + +Code is far away from  
 *   ┃   ┃ + bug with the animal protecting
 *   ┃    ┗━━━┓ 神兽保佑,代码无bug 
 *   ┃        ┣┓
 *    ┃        ┏┛
 *     ┗┓┓┏━┳┓┏┛ + + + +
 *    ┃┫┫ ┃┫┫
 *    ┗┻┛ ┗┻┛+ + + +
 */
View Code

C.话剧

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include<bits/stdc++.h>
using namespace std;

double x,y,z;

signed main()
{
    cin>>x>>y>>z;
    printf("%.6lf",z/(x*y));
}
View Code

D.点集扩张

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include<bits/stdc++.h>
using namespace std;

const int N=110,M=410;
bool st[M][M];
int n,x,y;

signed main()
{
    cin>>n;
    
    int x1=-0x3f3f3f3f,x2=0x3f3f3f3f,y1=-0x3f3f3f3f,y2=0x3f3f3f3f;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        st[x+N][y+N]=true;
        x1=max(x1,x),x2=min(x2,x),y1=max(y1,y),y2=min(y2,y);
    }
    
    if(x2<=0&&x1>=0&&y2<=0&&0<=y1)
    {
        bool flag=true;
        for(int i=x2+N;i<=x1+N;i++)
            for(int j=y2+N;j<=y1+N;j++)
                if(!st[i][j]) flag=false;
        
        if(flag) cout<<x1-x2+y1-y2;
        else cout<<-1; 
    }else cout<<-1;
}
View Code

E.全错

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include<bits/stdc++.h>
using namespace std;

#define x first
#define y second

typedef pair<double,int> PDI;
const double esp=1e-6;
const int N=210;
bool dist[N][N];
int t,n;
string s;
double b;

int cmp(double a,double b)
{
    if(fabs(a-b)<esp) return 0;
    else if(a<b) return -1;
    return 1;
}

double init()
{
    double a;
    if(s[0]=='+') sscanf(s.c_str(),"+%lf",&a);
    else if(s[0]=='-') sscanf(s.c_str(),"-%lf",&a),a=-a;
    else sscanf(s.c_str(),"%lf",&a);
    
    return a;
}

signed main()
{
    cin>>t;
    while(t--)
    {
        cin>>n>>s;
        b=init();
        
        memset(dist,false,sizeof dist);
        
        PDI p[n];
        for(int i=1;i<=n;i++)
        {
            int idx=0;
            for(int j=1;j<=n;j++)
            {
                cin>>s;
                if(i==j) continue;
                double a=init();
                p[idx++]={a,j};
            }
            sort(p,p+idx,greater<PDI>());
            if(cmp(p[0].x,b)>=0) dist[i][p[0].y]=true;
        }
        if(n==1)
        {
            cout<<"kono jinsei, imi ga nai!"<<endl;
            continue;
        }
        for(int k=1;k<=n;k++)
            for(int i=1;i<=n;i++)
                for(int j=1;j<=n;j++)
                {
                    dist[i][j]=dist[i][j];
                    if(dist[i][k]&&dist[k][j]) dist[i][j]=true;     
                }
        bool flag=true;
        for(int i=1;i<=n;i++)
            if(!dist[i][i]) flag=false;
        
        if(flag) cout<<"wish you the best in your search"<<endl;
        else cout<<"hbxql"<<endl;        
    }
}
View Code

F.渡渡鸟游乐场

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define fi first
#define se second
#define lc u << 1
#define rc u << 1 | 1
// #define int long long

// #define double long long
// #define int __int128_t
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e7 + 10;

// const int R = 999997;
const int Base = N / 2;
const int M = 1e6 + 10;

// const int P = 1 << 10;
const int INF = 2147483647;

typedef unsigned long long ULL;

const double eps = 1e-4;
const double PI = acos(-1);
const int mod = 1e9 + 7;
int n, k;
int d;
int m;
int Q;
int target;
// int p = INF;
// __int128_t a = 1;

// rope<int> r;
tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> treap;
char s[1010];

void solve()
{
    scanf("%d", &n);
    m = 3 * n - 3;
    vector<vector<bool>> v(n + 1, vector<bool>(4));
    for (int i = 1; i <= m; i++)
    {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        v[a][b] = true;
        bool f = false;
        if (b == 2)
        {
            if (v[a][1] || v[a][3])
            {
                if (i & 1)
                {
                    printf("Nocriz");
                    break;
                }
                else
                {
                    printf("Sheauhaw");
                    break;
                }
            }
        }
        else
        {
            if (v[a][2])
            {
                if (i & 1)
                {
                    printf("Nocriz");
                    break;
                }
                else
                {
                    printf("Sheauhaw");
                    break;
                }
            }
        }
    }
}

signed main()
{
    int t = 1;
    // str = "codeforces";
    // init();
    // cout << cnt << endl;
    // init();
    // scanf("%d", &t);
    // getchar();
    // int a = 1;
    // for (int i = 1; i <= 26; i++)
    // {
    //     a = (a << 1) + 1;
    // }
    // cout << a << endl;
    // float t = 134217727;
    // int cnt = 200;
    // printf("%.16lf", t);
    // while (cnt--)
    // {
    //     t = t * 2 + a;
    //     printf("%.16f\n", t);
    // }
    // getchar();
    // cout << (int)(log(4) / log(2)) << endl;
    while (t--)
    {
        //     cout << t << endl;
        //     // cout << (2563 % 11) << endl;
        //     // cout << t << endl;
        solve();
        //     // cout << (((float)1) << 63) << endl;
        //     // cout << '\0' << endl;
        //     // cout << f(4);
        //     // cout<<(25 >> 5)
        //     // cout << gcd(31415, 14142);//
        //     // cout << (28284 / 11) << endl;
    }
    return 0;
}

/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *                               神兽保佑            永无BUG
 */

/**
 *  ┏┓   ┏┓+ +
 * ┏┛┻━━━┛┻┓ + +
 * ┃       ┃
 * ┃   ━   ┃ ++ + + +
 *  ████━████+
 *  ◥██◤ ◥██◤ +
 * ┃   ┻   ┃
 * ┃       ┃ + +
 * ┗━┓   ┏━┛
 *   ┃   ┃ + + + +Code is far away from  
 *   ┃   ┃ + bug with the animal protecting
 *   ┃    ┗━━━┓ 神兽保佑,代码无bug 
 *   ┃        ┣┓
 *    ┃        ┏┛
 *     ┗┓┓┏━┳┓┏┛ + + + +
 *    ┃┫┫ ┃┫┫
 *    ┗┻┛ ┗┻┛+ + + +
 */
View Code

G.和而不同

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define maxn 201005
#define mod 998244353
#define pi 3.141592653
#define P 131
#define inf 1e9
#define int long long
inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=(x<<3)+(x<<1)+c-48;
        c=getchar();
    }
    return x*f;
}    
int dis[1200][1200],n;
map<int,int>vis;
signed main()
{
    n=read();
    int temp=1;
    for(rg int i=1;i<n;++i)
    {
        int now=i;
        int nxt=i+1;
        for(rg int j=now;j>=1;--j)
        {
            while(vis[temp+dis[j][now]]==1) 
            {
                ++temp; 
                j=now+1;
            }
        }
        dis[now][nxt]=dis[nxt][now]=temp;
        vis[temp]=1;
        for(rg int j=now;j>=1;--j)
        {
            dis[j][nxt]=dis[nxt][j]=dis[j][now]+dis[now][nxt];
            vis[dis[j][nxt]]=1;
        }
    }
    cout<<n-1<<endl;
    for(rg int i=1;i<n;++i)
    {
        cout<<i<<" "<<i+1<<" "<<dis[i][i+1]<<endl;
    }
}
View Code

H.字符游戏

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define fi first
#define se second
#define lc u << 1
#define rc u << 1 | 1
// #define int long long

// #define double long long
// #define int __int128_t
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e7 + 10;

// const int R = 999997;
const int Base = N / 2;
const int M = 1e6 + 10;

// const int P = 1 << 10;
const int INF = 2147483647;

typedef unsigned long long ULL;

const double eps = 1e-4;
const double PI = acos(-1);
const int mod = 1e9 + 7;
int n, k;
int d;
int m;
int Q;
int target;
// int p = INF;
// __int128_t a = 1;

// rope<int> r;
tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> treap;
char s[1010];

void solve()
{
    scanf("%d", &n);
    vector<vector<int>> cnt(n + 1, vector<int>(27));
    for (int i = 1; i <= n; i++)
    {
        scanf("%s", s + 1);
        int len = strlen(s + 1);
        for (int j = 1; j <= len; j++)
        {
            cnt[i][s[j] - 'a']++;
        }
    }
    int ans = -1;
    for (int i = 0; i < 26; i++)
    {
        bool flag = true;
        unordered_map<int, bool> mp;
        for (int j = 1; j <= n; j++)
        {
            if (!mp.count(cnt[j][i]))
            {
                mp[cnt[j][i]] = true;
            }
            else
            {
                flag = false;
                break;
            }
        }
        if (flag)
        {
            ans = i;
            break;
        }
    }
    // cout << ans << endl;
    if (ans == -1)
    {
        puts("NO");
    }
    else
    {
        puts("YES");
        string str = "";
        for (int i = 0; i < 26; i++)
        {
            if (i != ans)
            {
                str += i + 'a';
            }
        }
        str += ans + 'a';
        cout << str << endl;
    }
}

signed main()
{
    int t = 1;
    // str = "codeforces";
    // init();
    // cout << cnt << endl;
    // init();
    // scanf("%d", &t);
    // getchar();
    // int a = 1;
    // for (int i = 1; i <= 26; i++)
    // {
    //     a = (a << 1) + 1;
    // }
    // cout << a << endl;
    // float t = 134217727;
    // int cnt = 200;
    // printf("%.16lf", t);
    // while (cnt--)
    // {
    //     t = t * 2 + a;
    //     printf("%.16f\n", t);
    // }
    // getchar();
    // cout << (int)(log(4) / log(2)) << endl;
    while (t--)
    {
        //     cout << t << endl;
        //     // cout << (2563 % 11) << endl;
        //     // cout << t << endl;
        solve();
        //     // cout << (((float)1) << 63) << endl;
        //     // cout << '\0' << endl;
        //     // cout << f(4);
        //     // cout<<(25 >> 5)
        //     // cout << gcd(31415, 14142);//
        //     // cout << (28284 / 11) << endl;
    }
    return 0;
}

/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *                               神兽保佑            永无BUG
 */

/**
 *  ┏┓   ┏┓+ +
 * ┏┛┻━━━┛┻┓ + +
 * ┃       ┃
 * ┃   ━   ┃ ++ + + +
 *  ████━████+
 *  ◥██◤ ◥██◤ +
 * ┃   ┻   ┃
 * ┃       ┃ + +
 * ┗━┓   ┏━┛
 *   ┃   ┃ + + + +Code is far away from  
 *   ┃   ┃ + bug with the animal protecting
 *   ┃    ┗━━━┓ 神兽保佑,代码无bug 
 *   ┃        ┣┓
 *    ┃        ┏┛
 *     ┗┓┓┏━┳┓┏┛ + + + +
 *    ┃┫┫ ┃┫┫
 *    ┗┻┛ ┗┻┛+ + + +
 */
View Code

M.斑马子树

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define maxn 201005
#define mod 998244353
#define pi 3.141592653
#define P 131
#define inf 1e9
inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=(x<<3)+(x<<1)+c-48;
        c=getchar();
    }
    return x*f;
}    
int n;
struct node
{
    int v,nxt;
}s[maxn];
int head[maxn],tot;
inline void add(int x,int y)
{
    s[++tot].v=y;
    s[tot].nxt=head[x];
    head[x]=tot;
} 
int ce[maxn],t[maxn],ans[maxn];
inline pair<int,int> dfs(int now)
{
    int l=t[now],r=t[now];
    for(rg int i=head[now];i;i=s[i].nxt)
    {
        auto nxt=dfs(s[i].v);
        l=min(l,nxt.first);
        r=max(r,nxt.second);
    }
    ans[l]++;
    ans[r]--;
    return make_pair(l,r);
}
int S[maxn];
int main()
{
    n=read();
    for(rg int i=1;i<n;++i) add(read(),i+1);
    for(rg int i=1;i<=n;++i) 
    {
        ce[i]=read();
        t[ce[i]]=i;
    }
    dfs(1);
    for(rg int i=1;i<=n;++i)
    {
        S[i]=S[i-1]+ans[i];
        printf("%d ",S[i]);
    }
}
View Code

N.栈列

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#define fi first
#define se second
#define lc u << 1
#define rc u << 1 | 1
// #define int long long

// #define double long long
// #define int __int128_t
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e7 + 10;

// const int R = 999997;
const int Base = N / 2;
const int M = 1e6 + 10;

// const int P = 1 << 10;
const int INF = 2147483647;

typedef unsigned long long ULL;

const double eps = 1e-4;
const double PI = acos(-1);
const int mod = 1e9 + 7;
int n, k;
int d;
int m;
int Q;
int target;
// int p = INF;
// __int128_t a = 1;

// rope<int> r;
tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> treap;
char s[1010];

void solve()
{
    scanf("%d %d", &n, &m);
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    vector<int> v(n + 1);
    int mc = 0;
    int pos = 0;
    unordered_map<int, int> cnt;
    int num = 1;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &v[i]);
        if (i > 1 && v[i] <= v[i - 1])
        {
            num++;
            pos = v[i];
        }
        cnt[v[i]]++;
        if (cnt[v[i]] > mc)
        {
            mc = cnt[v[i]];
            pos = v[i];
        }
        else if (cnt[v[i]] == mc && v[i] > pos)
        {
            pos = v[i];
        }
        else if (v[i] > pos)
        {
            pos = v[i];
        }
    }
    // cout << pos << endl;
    // cout << pos << endl;
    LL res = (LL)m * num - (m - pos - 1);
    // cout << res << endl;
    LL ans = (LL)a * res;
    // cout << ans << endl;
    ans += (LL)b * (res - n);
    for (int i = 2; i <= n; i++)
    {
        if (v[i] == 0)
        {
            if (v[i - 1] != m - 1)
            {
                ans += c;
                break;
            }
        }
        else
        {
            if (v[i - 1] != v[i] - 1)
            {
                ans += c;
                break;
            }
        }
    }

    printf("%lld\n", ans);
}

signed main()
{
    int t = 1;
    // str = "codeforces";
    // init();
    // cout << cnt << endl;
    // init();
    // scanf("%d", &t);
    // getchar();
    // int a = 1;
    // for (int i = 1; i <= 26; i++)
    // {
    //     a = (a << 1) + 1;
    // }
    // cout << a << endl;
    // float t = 134217727;
    // int cnt = 200;
    // printf("%.16lf", t);
    // while (cnt--)
    // {
    //     t = t * 2 + a;
    //     printf("%.16f\n", t);
    // }
    // getchar();
    // cout << (int)(log(4) / log(2)) << endl;
    while (t--)
    {
        //     cout << t << endl;
        //     // cout << (2563 % 11) << endl;
        //     // cout << t << endl;
        solve();
        //     // cout << (((float)1) << 63) << endl;
        //     // cout << '\0' << endl;
        //     // cout << f(4);
        //     // cout<<(25 >> 5)
        //     // cout << gcd(31415, 14142);//
        //     // cout << (28284 / 11) << endl;
    }
    return 0;
}

/*
 *                                                     __----~~~~~~~~~~~------___
 *                                    .  .   ~~//====......          __--~ ~~
 *                    -.            \_|//     |||\\  ~~~~~~::::... /~
 *                 ___-==_       _-~o~  \/    |||  \\            _/~~-
 *         __---~~~.==~||\=_    -_--~/_-~|-   |\\   \\        _/~
 *     _-~~     .=~    |  \\-_    '-~7  /-   /  ||    \      /
 *   .~       .~       |   \\ -_    /  /-   /   ||      \   /
 *  /  ____  /         |     \\ ~-_/  /|- _/   .||       \ /
 *  |~~    ~~|--~~~~--_ \     ~==-/   | \~--===~~        .\
 *           '         ~-|      /|    |-~\~~       __--~~
 *                       |-~~-_/ |    |   ~\_   _-~            /\
 *                            /  \     \__   \/~                \__
 *                        _--~ _/ | .-~~____--~-/                  ~~==.
 *                       ((->/~   '.|||' -_|    ~~-/ ,              . _||
 *                                  -_     ~\      ~~---l__i__i__i--~~_/
 *                                  _-~-__   ~)  \--______________--~~
 *                                //.-~~~-~_--~- |-------~~~~~~~~
 *                                       //.-~~~--\
 *                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *                               神兽保佑            永无BUG
 */

/**
 *  ┏┓   ┏┓+ +
 * ┏┛┻━━━┛┻┓ + +
 * ┃       ┃
 * ┃   ━   ┃ ++ + + +
 *  ████━████+
 *  ◥██◤ ◥██◤ +
 * ┃   ┻   ┃
 * ┃       ┃ + +
 * ┗━┓   ┏━┛
 *   ┃   ┃ + + + +Code is far away from  
 *   ┃   ┃ + bug with the animal protecting
 *   ┃    ┗━━━┓ 神兽保佑,代码无bug 
 *   ┃        ┣┓
 *    ┃        ┏┛
 *     ┗┓┓┏━┳┓┏┛ + + + +
 *    ┃┫┫ ┃┫┫
 *    ┗┻┛ ┗┻┛+ + + +
 */
View Code

O.打则

2023 Xian Jiaotong University Programming Contest2023 Xian Jiaotong University Programming Contest
#include<bits/stdc++.h>
using namespace std;
#define rg register
#define maxn 4200000
#define inf 1e15
#define mod 19961
#define int long long
inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-') f=-1;
        c=getchar();
    }
    while(c<='9'&&c>='0')
    {
        x=(x<<1)+(x<<3)+c-48;
        c=getchar(); 
    }
    return x*f;
}
int n,m,k,s;
bool vis[maxn];
int ans=1;
signed main()
{
    n=read();
    m=read();
    for(rg int i=1;i<=m;++i)
    {
        k=read();
        for(rg int j=1;j<=k;++j) s=read();
    }
    for(rg int i=1;i<=n;++i) ans=1*ans*i%mod;
    cout<<ans;
}
View Code

 文章来源地址https://www.toymoban.com/news/detail-455036.html

到了这里,关于2023 Xian Jiaotong University Programming Contest的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • KYOCERA Programming Contest 2022(AtCoder Beginner Contest 271)

    KYOCERA Programming Contest 2022(AtCoder Beginner Contest 271) 思路:进制转换 没啥巧解,就十进制转十六进制 思路: 直接取出对应位置的值即可 思路:二分 二分答案然后看 mid 是不是满足能构成 1到 mid里面的所有数,能就继续二分,输出答案即可 思路:动态规划 类似于背包,然后就

    2024年02月09日
    浏览(31)
  • The 14th Jilin Provincial Collegiate Programming Contest(暑期训练)

    Attachments - The 14th Jilin Provincial Collegiate Programming Contest - Codeforces 目录  Problem A. Chord  Problem B. Problem Select Problem C. String Game Problem E. Shorten the Array Problem F. Queue Problem G. Matrix  Problem J. Situation  Problem L. Swimmer      题意:         输入三个音阶,判断在钢琴上俩俩之间差是否满

    2024年02月12日
    浏览(27)
  • A Qualifiers Ranking Rules---The 2023 ICPC Asia Regionals Online Contest (1)

    The following is the current ranking rules for the ICPC Asia EC Online Qualifiers, and there will be two online contests. In each contest, only the rank of the top-ranked team from each university will be taken as the score of that university; In each contest, participating universities will be ranked according to their scores; The two rankings of universiti

    2024年02月08日
    浏览(48)
  • University Program VWF仿真步骤__全加器

    本教程将以全加器为例,选择DE2-115开发板的Cyclone IV EP4CE115F29C7 FPGA,使用Quartus Lite v18.1,循序渐进的介绍如何创建Quartus工程,并使用Quartus Prime软件的University Program VWF工具创建波形文件,对全加器的功能进行仿真。 使用University Program VWF工具进行仿真,其实也是调用ModelSim软件

    2024年02月22日
    浏览(37)
  • MongoDB University课程M310 MongoDB Security 学习笔记

    此课程需要两台虚机。因此需要提前安装Vagrant和VirtualBox,这些我已经有了。因此只需要下载课程提供的Vagrant文件m310-vagrant-env.zip就可以了。 解压文件,进入目录,运行以下命令即可: 注意需要先安装plugin,再运行 vagrant up ,如果顺序颠倒,会报以下错误 或以下错误: 如果

    2024年02月16日
    浏览(26)
  • 动态规划Dynamic Programming

     上篇文章我们简单入门了动态规划(一般都是简单的上楼梯,分析数据等问题)点我跳转,今天给大家带来的是路径问题,相对于上一篇在一维中摸爬滚打,这次就要上升到二维解决问题,但都用的是动态规划思想嘛,所以大差不差,且听我慢慢道来。 还是用一样的方法,

    2024年03月27日
    浏览(41)
  • Dynaminc Programming相关

    目录 3.1 最长回文子串(中等):标志位 3.2 最大子数组和(中等):动态规划 3.3 爬楼梯(简单):动态规划 3.4 买卖股票的最佳时机(简单):动态规划 3.5 买卖股票的最佳时机Ⅱ(中等):动态规划 3.6 生成括号(中等):递归 3.7 打家劫舍(中等):动态规划 3.8 跳跃游戏

    2024年02月12日
    浏览(18)
  • 【C# Programming】异常处理、泛型

            C# 允许代码引发从System.Exception 派生。 例如:         两个类似的异常是ArgumentNullException 和 NullReferenceException. 一般在解引用null值时,底层触发NullReferenceException。         参数异常类型(ArgumentException、ArgumentNullException和ArgumentOutRangeException) 一个重要特征是

    2024年02月07日
    浏览(31)
  • 声明式编程Declarative Programming

    接下来要介绍第五种编程范式 -- 声明式编程。分别从它的优缺点、案例分析和适用的编程语言这三个方面来介绍这个歌编程范式。 声明式编程是一种编程范式,其核心思想是通过描述问题的性质和约束,而不是通过描述解决问题的步骤来进行编程。这与命令式编程范式形成

    2024年02月05日
    浏览(31)
  • 动态规划(Dynamic Programming)详解

    引言: 动态规划(Dynamic Programming,简称DP)是计算机科学与数学领域中的一个经典算法设计策略,用于解决具有重叠子问题和最优子结构特性的复杂问题。它通过将问题分解为更小的子问题来避免重复计算,从而提高效率。本文旨在详细介绍动态规划的基本概念、原理、实现

    2024年04月13日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包