2023 CCPC Henan Provincial Collegiate Programming Contest

Posted sakuya726

tags:

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

因为是我和队友VP的这场比赛,最后记录的也是比赛时候的提交代码,因此会出现多种不同的码风也是正常现象。

A.小水獭游河南

#include<bits/stdc++.h>
using namespace std;
#define rg register
#define maxn 150500
#define mod 998244353
#define pi 3.141592653
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 t; 
string s;
int num[1500];
int tag1,tag2=-1;//大小写的分割点 
inline bool check(string a)//判断回文 

    int len=a.length();
    int l=0,r=len-1;
    while(l<=r)
    
        if(a[l]!=a[r]) return false; 
        l++;
        r--;            
    
    return true;

inline void pre_work()

    memset(num,0,sizeof(num));
    tag1=s.length();
    tag2=-1;
    for(rg int i=0;i<s.length();++i)
    
        num[s[i]]++;
        if(num[s[i]]>=2||s[i]<\'a\'||s[i]>\'z\') 
        
            tag1=i;
            break;
        
    
    memset(num,0,sizeof(num));
    for(rg int i=s.length()-1;i>=0;--i)
    
        num[s[i]]++;
        if(num[s[i]]>=2||s[i]<\'a\'||s[i]>\'z\') 
        
            tag2=i;
            break;
        
    

int main()

    t=read();
    while(t--)
    
        cin>>s;
        pre_work();
        for(rg int i=0;i<s.length()-1;++i)
        
            //[0,i]--[i+1,len-1]
            if(i<tag1&&check(s.substr(i+1,s.length()-(i+1)))==1) 
            
                cout<<"HE"<<endl;
                goto ed;
            
            else if((i+1)>tag2&&check(s.substr(0,i+1))==1)
            
                cout<<"HE"<<endl;
                goto ed;
            
            else if(i>=tag1&&i+1<=tag2) break;
        
        cout<<"NaN"<<endl;
        ed:;
    

B.Art for Rest

#include<bits/stdc++.h>
using namespace std;
#define rg register
#define maxn 1000500
#define mod 998244353
#define pi 3.141592653
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,m,a[maxn];
int f[maxn][22];
int g[maxn][22];
long long lg[maxn];
inline void ST_prework()

    for(rg int j=1;(1<<j)<=n;++j)
    
        for(rg int i=1;i<=n-(1<<j)+1;++i)
        
            f[i][j]=max(f[i][j-1],f[i+(1<<(j-1))][j-1]);
            g[i][j]=min(g[i][j-1],g[i+(1<<(j-1))][j-1]);
        
    

inline long long query1(int l,int r)

    long long k=lg[r-l+1]/(lg[2]);
    return max(f[l][k],f[r-(1<<k)+1][k]);
 
inline long long query2(int l,int r)

    long long k=lg[r-l+1]/(lg[2]);
    return min(g[l][k],g[r-(1<<k)+1][k]);
 
bool xd[maxn];
int ans;
int main()

    n=read();
    lg[1]=0;
    lg[2]=1;
    for(rg int i=3;i<=n+1;++i) lg[i]=lg[i/2]+1;
    for(rg int i=1;i<=n;++i)
    
        a[i]=read();
        f[i][0]=a[i];
        g[i][0]=a[i];
    
    ST_prework();
    for(rg int k=1;k<=n;++k)
    
        if(xd[k]==1) 
        
            ans++;
            continue;
        
        else
        
            bool flag=1;
            int l=min(n,k+1),r=min(n,2*k);
            int maxx=query1(1,k);
            int m=ceil(double(1.0*n)/double(1.0*k))-1;
            while(m--)
            
                if(query2(l,r)<maxx) 
                
                    flag=0;
                    break;
                
                else maxx=query1(l,r);
                l=min(n,l+k);
                r=min(n,r+k);
            
            if(flag==1)
            
                ++ans;                
                for(rg int j=k;j<=n;j+=k) xd[j]=1;
            
        
    
    cout<<ans;

E.矩阵游戏

#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;

const int N = 500 + 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 g[N][N];

void solve()

    scanf("%d %d %d", &n, &m, &k);
    vector<vector<vector<int>>> f(2, vector<vector<int>>(m + 1, vector<int>(k + 1)));
    for (int i = 1; i <= n; i++)
    
        scanf("%s", g[i] + 1);
    
    for (int i = 1; i <= n; i++)
    
        for (int j = 1; j <= m; j++)
        
            for (int z = 0; z <= k; z++)
            
                if (g[i][j] == \'0\')
                
                    f[i & 1][j][z] = max(f[(i - 1) & 1][j][z], f[i & 1][j - 1][z]);
                
                else if (g[i][j] == \'1\')
                
                    f[i & 1][j][z] = max(f[(i - 1) & 1][j][z], f[i & 1][j - 1][z]) + 1;
                
                else
                
                    if (z >= 1)
                    
                        f[i & 1][j][z] = max(f[(i - 1) & 1][j][z - 1], f[i & 1][j - 1][z - 1]) + 1;
                    
                    else
                    
                        f[i & 1][j][z] = max(f[(i - 1) & 1][j][z], f[i & 1][j - 1][z]);
                    
                
            
      
        
   
    
    printf("%d\\n", f[n & 1][m][k]);


signed main()

    int t = 1;

    scanf("%lld", &t);

    while (t--)
    

        solve();
    
    return 0;

F.Art for Last

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

//#define int long long  

typedef long long LL;
const int N=5e5+10;
int a[N],b[N],q[N];
int n,k;



signed main()

    cin>>n>>k;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    sort(a+1,a+n+1);
    
    LL res=1e18;
    
    int tt=-1,hh=0;
    for(int i=2;i<=n;i++)
    
        b[i]=abs(a[i]-a[i-1]);
        if(k>2)
        
            while(hh<=tt&&i+1-k>q[hh])  hh++;//判断q[hh]有没有滑出窗口
            while(hh<=tt&&b[q[tt]]>=b[i]) tt--;//保证窗口内的数从小到大排序
            q[++tt]=i;
            if(i>=k) res=min(res,(LL)b[q[hh]]*abs(a[i]-a[i-k+1])); 
        else res=min(res,(LL)b[i]*b[i]);
    
    
    cout<<res;

H.Travel Begins

#include<bits/stdc++.h>
using namespace std;
#define rg register
#define maxn 250500
#define mod 998244353
#define pi 3.141592653
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 t;
int n,k;
int minn,maxx;
int main()

    t=read();
    while(t--)
    
        n=read();
        k=read();
        minn=maxx=0;
        int tot1=k-1;
        if(tot1%2==0)
        
            int res=n-tot1/2;
            cout<<max(0,res)<<" ";
        
        else
        
            int res=n-(tot1-1)/2;
            cout<<max(0,res)<<" ";
        
    //    cout<<k-1<<" "<<(((k-1)%2==0)?(n-(k-1)/2):(n-(k-2)/2))<<endl;
        cout<<min(2*n,(k-1)+(((k-1)%2==0)?(n-(k-1)/2):(n-(k-2)/2)))<<endl;
    

K.排列与质数

#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;

const int N = 1e5 + 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];
int cnt = 0;
bool st[N];
bool isp[N];

void init()

    for (int i = 2; i <= 1e5; i++)
    
        if (!st[i])
        
            st[i] = true;
            primes[cnt++] = i;
            isp[i] = true;
        
        for (int j = 0; primes[j] <= 1e5 / i; j++)
        
            st[primes[j] * i] = true;
            if (i % primes[j] == 0)
            
                break;
            
        
    


int find(int n)


    int res = 2 * (n - 2);
    // cout << res << endl;
    for (int i = 0; i < cnt; i++)
    
        int j = primes[i];
        cout << j << endl;
        if (res + j > n)
        
            return 0;
        
        if (isp[res] && isp[res + j])
        
            return j;
        
    
    return 0;


void solve()


    scanf("%d", &n);
    vector<int> a(n + 10);
    a[1] = 1;
    if (n <= 4)
    
        printf("-1\\n");
        return;
    
    if (n == 5)
    
        printf("4 1 3 5 2\\n");
    
    else if (n == 6)
    
        printf("4 6 1 3 5 2\\n");
    
    else if (n == 7)
    
        printf("4 6 1 3 5 2 7\\n");
    
    else if (n == 8)
    
        printf("4 6 8 1 3 5 2 7\\n");
    
    else if (n == 9)
    
        printf("4 6 8 1 3 5 2 7 9\\n");
    
    else if (n == 10)
    
        printf("8 6 9 4 1 3 5 2 7 10\\n");
    
    else if (n == 11)
    
        printf("8 6 4 1 3 10 5 2 7 9 11\\n");
    
    else if (n == 12)
    
        printf("8 11 6 4 1 3 5 2 7 9 12 10\\n");
    
    else
    
        if (n & 1)
        
            a[4] = 2;
            a[3] = 5;
            a[5] = 7;
            int t = n - 6;
            int idx = 0;
            int cur = 0;
            for (int i = 2; i <= (n + 3) / 2 + 1; i++)
            
                if (a[i - 2] == t)
                
                    a[i] = t + 2;
                    continue;
                
                if (!a[i])
                
                    a[i] = a[i - 1] + 2;
                
                if (a[i] == t)
                
                    i++;
                    a[i] = n - 1;
                
                // cout << i << \' \' << a[i] << endl;
            
            cur = n - 1;
            for (int i = (n + 3) / 2 + 2; i <= n && cur > 0; i++, cur -= 2)
            
                a[i] = cur - 2;
            
            // for (int i = 1; i <= n; i++)
            // 
            //     cout << i << \' \' << a[i] << endl;
            // 
        
        else
        
            a[4] = 2;
            a[3] = 5;
            a[5] = 7;
            int t = n - 6;
            int cur = 4;
            for (int i = n; i >= n / 2 + 1; i--, cur += 2)
            
                if (a[i + 2] == t)
                
                    a[i] = t + 2;
                    continue;
                
                if (!a[i])
                
                    a[i] = cur;
                
                if (a[i] == t)
                
                    i--;
                    a[i] = n - 1;
                
                // cout << i << \' \' << a[i] << endl;
            
            for (int i = 2; i <= n / 2; i++)
            
                if (!a[i])
                
                    a[i] = a[i - 1] + 2;
                
                // cout << i << \' \' << a[i] << endl;
            
        
        for (int i = 1; i <= n; i++)
        
            printf("%d", a[i]);
            if (i != n)
            
                printf(" ");
            
            else
            
                puts("");
            
        
    


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 
 *   ┃        ┣┓
 *    ┃        ┏┛
 *     ┗┓┓┏━┳┓┏┛ + + + +
 *    ┃┫┫ ┃┫┫
 *    ┗┻┛ ┗┻┛+ + + +
 */

 

echarts_部分图表配置_地图的配置

 

 1 function echarts_map (thisId,data){
 2     $.get(\'map/json/henan.json\', function (chinaJson) {
 3         echarts.registerMap(\'henan\', chinaJson);
 4         var chart = echarts.init(document.getElementById(thisId));
 5         chart.setOption({
 6 
 7             visualMap: {
 8                 show:false,//不显示也有颜色区分的效果
 9                 min: 0,
10                 max: 50000,
11                 left: \'left\',
12                 top: \'bottom\',
13                 text: [\'高\',\'低\'], // 文本,默认为数值文本
14                 calculable: false,//是否显示可拖动的句柄
15                 inRange: {
16                     color: [\'rgba(15,220,150,.5)\',\'#00415a\',]
17                 }
18             },
19             tooltip: {
20                 trigger: \'item\',
21                 showDelay: 0,
22                 backgroundColor: \'#c6e8e9\',//浮框背景色
23                 transitionDuration: 0.2,
24                 formatter: function (params) {//设置提示框内的文字
25                     var p = \'<h3 style="color:#29667b;text-align:center;font-size:14px;font-weight:bold;line-height:20px;">[\'+params.name+\']</h3>\'+
26                         \'<p style="color:#26677b;font-size:12px;">今日累计用户数:\'+params.data.uv+\'</p>\'+
27                         \'<p style="color:#26677b;font-size:12px;">当前活跃用户数:\'+params.data.iuv+\'</p>\'
28                     return p;
29                 }
30             },           
31             series: [{
32                 type: \'map\',
33                 map: \'henan\',
34                 roam: false,//标识是否可以缩放和拖动
35                 aspectScale:1.1,//设置地图的长宽比 数值越大 高度越小 数值越小 宽度越小
36                 zoom:1.25,//定义当前视角的缩放比
37                 label: {
38                     normal: {
39                         show: false,//标示是否显示提示文字
40                     },
41                     emphasis: {
42                         show: false
43                     }
44                 },
45                 itemStyle:{
46                     normal:{
47                         areaColor:\'rgba(15,220,150,.5)\'
48                     }
49                 },
50                 data:data
51             }]
52         });
53         chart.on(\'mouseover\', function (e) {
54             e.event.target.style.fill = \'#00415a\';
55         });
56     });
57 };

 

以上是关于2023 CCPC Henan Provincial Collegiate Programming Contest的主要内容,如果未能解决你的问题,请参考以下文章

列表练习

A . Xu Xiake in Henan Province (签到) ( 2018-2019 ACM-ICPC, Asia Jiaozuo Regional Contest )

对象检测界面

03-字典的增删改查

echarts_部分图表配置_地图的配置

2020CCPC威海