【赛后总结+部分题解】2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛

赛后总结:

  T:今天状态一般,甚至有点疲惫。然后12点比赛开始,和队友开始看题,从最后往前面看,发现数学题公式看不懂。然后发现队友已经双开做1001和1006了,我看着1007有人A,开始做1007。看了一会发现这是一个简单签到题,构造一下就完事了。然后一遍A,结束。在他们看1008的时候,我回去看1002和1003,1002的题意没看清楚,队友说的也有点模糊,然后不知道怎么下手。开始看1003,因为A的人真的好多呜呜呜。从AC自动机一直re转为后缀自动机,然后不会。结束了。今天对队伍的贡献太少了,复杂度也没算好,一直在re。做题策略还是有点问题,不该纠结自己不会的领域。然后也有很多不会的知识需要去弥补。

部分题解:

1001 ^&^

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<cmath>
#include<string>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
using namespace std;
#define mm(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const long long mod = 1e9 + 7;
const int maxn = 1e6 + 10;

int main()
{
    ll a, b, c, k, cnt;
    int t;
    cin >> t;
    k = 1;
    while (t--)
    {
        c = 0, k = 1, cnt = 0;
        scanf("%lld%lld", &a, &b);
        int flag = 1;
        while (a || b)
        {
            if (a & 1 && b & 1)
            {
                c += k;
            }
            else if ((a & 1) + (b & 1) == 1 && flag)
            {
                flag = 0, cnt = k;
            }
            a >>= 1, b >>= 1;
            k <<= 1;
        }
        if (!c) c = cnt == 0 ? 1 : cnt;
        printf("%lld\n", c);
    }
}

1006 Shuffle Card

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<queue>
#include<set>
#include<string>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
#include<fstream>
#include<iomanip>
using namespace std;
#define mm(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1e5+10;
const int inf = 0x3f3f3f3f;
const int mod = 998244353;
const double PI = acos(-1.0);
int a[maxn];
int b[maxn];
map<int,int> ma;
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++)
        scanf("%d",a+i);
    for(int i=0;i<m;i++)
        scanf("%d",b+i);
    for(int i=m-1;i>=0;i--){
        if(ma[b[i]])
            b[i]=0;
        else
            ma[b[i]]=1;
    }
    int sum=0;
    for(int i=m-1;i>=0;i--){
        if(b[i]!=0){
            printf("%d ",b[i]);
            sum++;
        }
        if(sum==n)
            break;
    }
    if(sum!=n){
        for(int i=0;i<n;i++){
            if(!ma[a[i]]){
                printf("%d ",a[i]);
                sum++;
            }
            if(sum==n)
                break;
        }
    }
    return 0;
}

1007 Windows of CCPC

#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma GCC optimize(2)
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<cmath>
#include<string>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
using namespace std;
#define mm(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const long long mod = 1e9+7;
const int maxn = 2e5;
char mp[2000][2000];
int num[20];
void init()
{
    num[0]=1;
    for(int i=1;i<=10;i++)
    {
        num[i]=num[i-1]*2;
    }
    mp[1][1]=‘C‘;
    mp[1][2]=‘C‘;
    mp[2][1]=‘P‘;
    mp[2][2]=‘C‘;
    for(int i=2;i<=10;i++)
    {
        for(int j=1;j<=num[i];j++)
        {
            for(int k=1;k<=num[i];k++)
            {
                if(j<=num[i-1]&&k<=num[i-1])
                    continue;

                if(k>num[i-1]&&j<=num[i-1])
                {
                    mp[j][k]=mp[j][k-num[i-1]];
                }
                else if(j>num[i-1]&&k>num[i-1])
                {
                    mp[j][k]=mp[j-num[i-1]][k-num[i-1]];
                }
                else if(j>num[i-1]&&k<=num[i-1])
                {
                    if(mp[j-num[i-1]][k]==‘C‘)
                        mp[j][k]=‘P‘;
                    else mp[j][k]=‘C‘;
                }
            }
        }
    }
}

int main()
{
    init();
    int T;
    scanf("%d",&T);
    while(T--)
    {
        int k;
        scanf("%d",&k);
        for(int i=1;i<=num[k];i++)
        {
            for(int j=1;j<=num[k];j++)
            {
                printf("%c",mp[i][j]);
            }
            printf("\n");
        }
    }
//

    return 0;
}

1008Fishing Master

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<cmath>
#include<string>
#include<map>
#include<vector>
#include<ctime>
#include<stack>
using namespace std;
#define mm(a,b) memset(a,b,sizeof(a))
typedef long long ll;
const long long mod = 1e9 + 7;
const int maxn = 1e6 + 10;
int t, n, vis[maxn];
ll a[maxn], k;
struct node{
    int id;
    ll yu;
}extra[maxn];
bool cmp(node a,node b) {
    return a.yu>b.yu;
}
int main()
{
    ll ans = 0, cnt, sum;
    cin >> t;
    while (t--)
    {
        queue<ll>q;
        ans = 0;
        cnt = 1;
        sum = 0;
        scanf("%d%lld", &n, &k);
        ans+=k;
        for (int i = 0; i < n; ++i)
        {
            scanf("%lld", &a[i]);
            cnt+=a[i]/k;
            extra[i].id=i;
            extra[i].yu=a[i]%k;
            ans+=a[i];
        }
        if(cnt<n){
            sort(extra,extra+n,cmp);
            for(ll i=0;i<=n-cnt-1;i++){
                    ans+=k-extra[i].yu;
            }
        }
        printf("%lld\n",ans);
    }
}

原文地址:https://www.cnblogs.com/Tangent-1231/p/11401965.html

时间: 2024-11-09 10:06:26

【赛后总结+部分题解】2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛的相关文章

2019中国大学生程序设计竞赛(CCPC) - 网络选拔赛

目录 1001 ^&^ 1002 array 1003 K-th occurrence 1004 path 1005 huntian oy 1006 Shuffle Card 1007 Windows Of CCPC 1008 Fishing Master 1009 Kaguya 1010 Touma Kazusa's function 1011 sakura 原文地址:https://www.cnblogs.com/Inko/p/11402622.html

2016中国大学生程序设计竞赛(ccpc 长春) Fraction【模拟】

Problem Description Mr. Frog recently studied how to add two fractions up, and he came up with an evil idea to trouble you by asking you to calculate the result of the formula below: As a talent, can you figure out the answer correctly? Input The fir

2016年中国大学生程序设计竞赛(合肥)-重现赛1008 HDU 5968

异或密码 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 19    Accepted Submission(s): 9 Problem Description 晨晨在纸上写了一个长度为N的非负整数序列{ai }.对于这个序列的一个连续子序列{al,al+1,…,ar }晨晨可以求出其中所有数异或的结果 alxoral+1xor...xo

2016年中国大学生程序设计竞赛(合肥)-重现赛1001 HDU 5961

传递 Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 42    Accepted Submission(s): 16 Problem Description 我们称一个有向图G是传递的,当且仅当对任意三个不同的顶点a,,若G中有 一条边从a到b且有一条边从b到c ,则G中同样有一条边从a到c.我们称图G是一个竞赛图,当且仅当它是一个有

2016年中国大学生程序设计竞赛(合肥)-重现赛1009 HDU 5969

最大的位或 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 18    Accepted Submission(s): 17 Problem Description B君和G君聊天的时候想到了如下的问题.给定自然数l和r ,选取2个整数x,y满足l <= x <= y <= r ,使得x|y最大.其中|表示按位或,即C. C++.

HDU 5833 Zhu and 772002(高斯消元)——2016中国大学生程序设计竞赛 - 网络选拔赛

传送门 Zhu and 772002 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 48    Accepted Submission(s): 16 Problem Description Zhu and 772002 are both good at math. One day, Zhu wants to test the abili

2017中国大学生程序设计竞赛 - 网络选拔赛 HDU 6154 CaoHaha&#39;s staff(几何找规律)

Problem Description "You shall not pass!"After shouted out that,the Force Staff appered in CaoHaha's hand.As we all know,the Force Staff is a staff with infinity power.If you can use it skillful,it may help you to do whatever you want.But now,hi

2016中国大学生程序设计竞赛 - 网络选拔赛 C. Magic boy Bi Luo with his excited tree

Magic boy Bi Luo with his excited tree Problem Description Bi Luo is a magic boy, he also has a migic tree, the tree has N nodes , in each node , there is a treasure, it's value is V[i], and for each edge, there is a cost C[i], which means every time

HDU6447 YJJ&#39;s Salesman 2018中国大学生程序设计竞赛 - 网络选拔赛1010 离散化+线段树+DP

YJJ's Salesman Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 253    Accepted Submission(s): 62 Problem Description YJJ is a salesman who has traveled through western country. YJJ is always on