主頁 >  其他 > 2023 Xian Jiaotong University Programming Contest

2023 Xian Jiaotong University Programming Contest

2023-05-23 09:08:26 其他

A.大水題

#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.原粥率

#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.話劇

#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.點集擴張

#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.全錯

#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.渡渡鳥游樂場

#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.和而不同

#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.字符游戲

#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.斑馬子樹

#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.堆疊列

#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.打則

#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.uj5u.com/qita/553107.html

標籤:其他

上一篇:AIGC持續火爆大模型爭相推出,龐大市場造就算力供應模式演變

下一篇:返回列表

標籤雲
其他(159493) Python(38162) JavaScript(25441) Java(18096) C(15230) 區塊鏈(8267) C#(7972) AI(7469) 爪哇(7425) MySQL(7204) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5871) 数组(5741) R(5409) Linux(5340) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4574) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2433) ASP.NET(2403) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) .NET技术(1975) 功能(1967) Web開發(1951) HtmlCss(1940) C++(1919) python-3.x(1918) 弹簧靴(1913) xml(1889) PostgreSQL(1878) .NETCore(1861) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • 網閘典型架構簡述

    網閘架構一般分為兩種:三主機的三系統架構網閘和雙主機的2+1架構網閘。 三主機架構分別為內端機、外端機和仲裁機。三機無論從軟體和硬體上均各自獨立。首先從硬體上來看,三機都用各自獨立的主板、記憶體及存盤設備。從軟體上來看,三機有各自獨立的作業系統。這樣能達到完全的三機獨立。對于“2+1”系統,“2”分為 ......

    uj5u.com 2020-09-10 02:00:44 more
  • 如何從xshell上傳檔案到centos linux虛擬機里

    如何從xshell上傳檔案到centos linux虛擬機里及:虛擬機CentOs下執行 yum -y install lrzsz命令,出現錯誤:鏡像無法找到軟體包 前言 一、安裝lrzsz步驟 二、上傳檔案 三、遇到的問題及解決方案 總結 前言 提示:其實很簡單,往虛擬機上安裝一個上傳檔案的工具 ......

    uj5u.com 2020-09-10 02:00:47 more
  • 一、SQLMAP入門

    一、SQLMAP入門 1、判斷是否存在注入 sqlmap.py -u 網址/id=1 id=1不可缺少。當注入點后面的引數大于兩個時。需要加雙引號, sqlmap.py -u "網址/id=1&uid=1" 2、判斷文本中的請求是否存在注入 從文本中加載http請求,SQLMAP可以從一個文本檔案中 ......

    uj5u.com 2020-09-10 02:00:50 more
  • Metasploit 簡單使用教程

    metasploit 簡單使用教程 浩先生, 2020-08-28 16:18:25 分類專欄: kail 網路安全 linux 文章標簽: linux資訊安全 編輯 著作權 metasploit 使用教程 前言 一、Metasploit是什么? 二、準備作業 三、具體步驟 前言 Msfconsole ......

    uj5u.com 2020-09-10 02:00:53 more
  • 游戲逆向之驅動層與用戶層通訊

    驅動層代碼: #pragma once #include <ntifs.h> #define add_code CTL_CODE(FILE_DEVICE_UNKNOWN,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS) /* 更多游戲逆向視頻www.yxfzedu.com ......

    uj5u.com 2020-09-10 02:00:56 more
  • 北斗電力時鐘(北斗授時服務器)讓網路資料更精準

    北斗電力時鐘(北斗授時服務器)讓網路資料更精準 北斗電力時鐘(北斗授時服務器)讓網路資料更精準 京準電子科技官微——ahjzsz 近幾年,資訊技術的得了快速發展,互聯網在逐漸普及,其在人們生活和生產中都得到了廣泛應用,并且取得了不錯的應用效果。計算機網路資訊在電力系統中的應用,一方面使電力系統的運行 ......

    uj5u.com 2020-09-10 02:01:03 more
  • 【CTF】CTFHub 技能樹 彩蛋 writeup

    ?碎碎念 CTFHub:https://www.ctfhub.com/ 筆者入門CTF時時剛開始刷的是bugku的舊平臺,后來才有了CTFHub。 感覺不論是網頁UI設計,還是題目質量,賽事跟蹤,工具軟體都做得很不錯。 而且因為獨到的金幣制度的確讓人有一種想去刷題賺金幣的感覺。 個人還是非常喜歡這個 ......

    uj5u.com 2020-09-10 02:04:05 more
  • 02windows基礎操作

    我學到了一下幾點 Windows系統目錄結構與滲透的作用 常見Windows的服務詳解 Windows埠詳解 常用的Windows注冊表詳解 hacker DOS命令詳解(net user / type /md /rd/ dir /cd /net use copy、批處理 等) 利用dos命令制作 ......

    uj5u.com 2020-09-10 02:04:18 more
  • 03.Linux基礎操作

    我學到了以下幾點 01Linux系統介紹02系統安裝,密碼啊破解03Linux常用命令04LAMP 01LINUX windows: win03 8 12 16 19 配置不繁瑣 Linux:redhat,centos(紅帽社區版),Ubuntu server,suse unix:金融機構,證券,銀 ......

    uj5u.com 2020-09-10 02:04:30 more
  • 05HTML

    01HTML介紹 02頭部標簽講解03基礎標簽講解04表單標簽講解 HTML前段語言 js1.了解代碼2.根據代碼 懂得挖掘漏洞 (POST注入/XSS漏洞上傳)3.黑帽seo 白帽seo 客戶網站被黑帽植入劫持代碼如何處理4.熟悉html表單 <html><head><title>TDK標題,描述 ......

    uj5u.com 2020-09-10 02:04:36 more
最新发布
  • 2023 Xian Jiaotong University Programming Contest

    A.大水題 #include <bits/stdc++.h> #include <ext/rope> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_cxx; using name ......

    uj5u.com 2023-05-23 09:08:26 more
  • AIGC持續火爆大模型爭相推出,龐大市場造就算力供應模式演變

    本圖由AI生成 黃仁勛說的AI發展迎來iPhone時刻,對NVIDIA有什么影響? 文/王吉偉 近期的AIGC領域仍舊火爆例外。 但火的不只是AIGC應用,還有巨頭之間的AI競賽,以及接連不斷上新的AI大模型(LLM,Large Language Model)。 面對ChatGPT帶來的技術沖擊,為 ......

    uj5u.com 2023-05-23 09:08:18 more
  • 細談使用CodeQL進行反序列化鏈的挖掘程序

    學習了一下CodeQL的各種使用方式,決定使用CodeQL細談一下CC鏈挖掘,通過一步一步的朝著我們既定的目標進行靠近,最終成功的找到了一條雞肋的二次反序列化的入口 ......

    uj5u.com 2023-05-23 09:07:49 more
  • 數字名片工具 BBlog:使用一個鏈接,快速創建和分享你的資訊主頁和數

    數字名片 BBlog:使用一個鏈接,快速創建和分享你的資訊主頁和數字花園 隨著移動互聯網技術的快速發展,數字名片產品已成為現代社交和網路營銷的重要工具。數字名片可以幫助個人和企業在各種場合中展示和分享聯系資訊,同時還具有便捷、環保、易于管理等諸多優點。 在本文中,我們將介紹一款高效、易用、功能豐富的 ......

    uj5u.com 2023-05-23 09:06:54 more
  • 3D模型渲染引擎6大特點解讀:助力AR/VR呈現驚嘆的視覺效果!

    HOOPS Visualize不僅僅是一個圖形引擎,它還是一個以工程為中心的場景圖形技術構建工程應用程式的框架。圍繞這個圖形核心的是一個可定制和可擴展的類層,它封裝了工程應用程式中的許多高級功能,并提供與物體建模器等其他組件的集成。 ......

    uj5u.com 2023-05-23 09:06:35 more
  • 理論+實操,帶你了解多沙箱容器運行時Kuasar

    摘要:華為云DTSE技術布道師張天陽結合沙箱容器發展歷程,介紹華為云多沙箱容器運行時 Kuasar 專案優勢,開啟多沙箱容器運行時上手實踐體驗。 本文分享自華為云社區《理論+實操,帶你了解多沙箱容器運行時Kuasar》,作者:華為云社區精選。 本期《多沙箱容器運行時Kuasar開發上手實踐》主題直播 ......

    uj5u.com 2023-05-23 09:06:18 more
  • 面了一個4年經驗的測驗工程師,自動化都不會也要15k,我也是醉了&#18

    看到了很多份簡歷,好幾個都是幾個月測驗經驗的來面試,最離譜的是令我印象最深刻的,一個4年經驗的,問薪資一張口就是要15k,這份自信也讓我對他極其感興趣,以為是來了個大佬,沒想到我一問不提測驗工具,僅僅基礎的技術很多也知之不詳,多數人數年的作業經驗僅僅是功能測驗堆起來的,毫無深度,對于APP自動化等等... ......

    uj5u.com 2023-05-23 09:05:58 more
  • Pytest - pytest 命令(3) - 常用命令的使用

    ## pytest 常用命令 ### 測驗資訊輸出 ```python # 設定pytest的執行引數 "-q":安靜模式, 不輸出環境資訊 pytest.main(["-q"]) # 設定pytest的執行引數 "-s":顯示程式中的print/logging輸出 pytest.main(["-s ......

    uj5u.com 2023-05-23 09:04:56 more
  • 機器學習資料順序隨機打亂:Python實作

    本文介紹基于**Python**語言,實作機器學習、深度學習等模型訓練時,**資料集打亂**的具體操作。 # 1 為什么要打亂資料集 在機器學習中,如果不進行資料集的打亂,則可能導致模型在訓練程序中出現具有“**偏見**”的情況,降低其泛化能力,從而降低訓練精度。例如,如果我們做深度學習的分類,其中 ......

    uj5u.com 2023-05-23 09:04:52 more
  • 摳圖黨福音:教你一鍵分割影像

    摘要:輸入一個影像,通過Segment Anything模型即可獲得影像所有目標的分割點位置,再通過位置將影像進行分割保存。 本文分享自華為云社區《一鍵分割影像》,作者:雨落無痕 。 Segment Anything Segment Anything Model(SAM)通過點或框等輸入提示生成高質 ......

    uj5u.com 2023-05-23 09:04:40 more