2019 CCPC网络选拔赛题

简介: 2019 CCPC网络选拔赛题

1006题目:Shuffle Card

A deck of card consists of n cards. Each card is different, numbered from 1 to n. At first, the cards were ordered from 1 to n. We complete the shuffle process in the following way, In each operation, we will draw a card and put it in the position of the first card, and repeat this operation for m times.

Please output the order of cards after m operations.

Input

The first line of input contains two positive integers n and m.(1<=n,m<=105)

The second line of the input file has n Numbers, a sequence of 1 through n.

Next there are m rows, each of which has a positive integer si, representing the card number extracted by the i-th operation.

Output

Please output the order of cards after m operations. (There should be one space after each number.)Sample Input

5 3
1 2 3 4 5
3
4
3

Sample Output

3 4 1 2 5

解题思路:

这个题正常去写的话会时间超限,就是每一次输入m中的数,前面的数就要整体后移,这样就会时间超限,所以这个题就是把n、m的数分别存入a[]、b[]两个数组中,然后再定义一个book[]数组,每一次输出之后就把数标记一下。

注意:这个题没有换行,不是多实例,而且每个数字后面都有一个空格

程序代码:

#include<stdio.h>
#include<string.h>
int a[100010],b[100100],book[200000];
int main()
{
  int i,j,n,m,k;
  memset(book,0,sizeof(book));//数组初始话为0
  scanf("%d%d",&n,&m);
  for(i=1;i<=n;i++)
    scanf("%d",&a[i]);//把n个数存入数组中
  for(i=m;i>=1;i--)
    scanf("%d",&b[i]);//把m个数存入数组中
  for(i=1;i<=m;i++)
  {
    if(book[b[i]]==0)//把b[]数组中的数输出并标记
    {
      printf("%d ",b[i]);
      book[b[i]]=1;
    }
  }
  for(i=1;i<=n;i++)
  {
    if(book[a[i]]==0)
    {
      printf("%d ",a[i]);//把a[]数组中的数输出并标记
      book[a[i]]=1;
    }
  }
  return 0;
}

1007题目:Windows Of CCPC

Problem Description

In recent years, CCPC has developed rapidly and gained a large number of competitors .One contestant designed a design called CCPC Windows .The 1-st order CCPC window is shown in the figure:

And the 2-nd order CCPC window is shown in the figure:

We can easily find that the window of CCPC of order k is generated by taking the window of CCPC of order k−1 as C of order k, and the result of inverting C/P in the window of CCPC of order k−1 as P of order k.

And now I have an order k ,please output k-order CCPC Windows , The CCPC window of order k is a 2k∗2k matrix.

Input

The input file contains T test samples.(1<=T<=10)

The first line of input file is an integer T.

Then the T lines contains a positive integers k , (1≤k≤10)

Output

For each test case,you should output the answer .

Sample Input

3
1
2
3


Sample Output

CC
PC
CCCC
PCPC
PPCC
CPPC
CCCCCCCC
PCPCPCPC
PPCCPPCC
CPPCCPPC
PPPPCCCC
CPCPPCPC
CCPPPPCC
PCCPCPPC

解题思路:

这个题有点找规律的迹象,就是先把前两排输入,然后从第三排开始,看第二排是P还是C,如果是C,就记录为CCPC,如果是P,就记录PPCP。

程序代码:

#include<stdio.h>
#include<string.h>
#include<math.h>
char e[2000][2000];
int main()
{
  int i,j,k,n,m,t;
  int T;
  scanf("%d",&T);
  while(T--)
  {
    scanf("%d",&n);
    m=pow(2,n);
    for(i=1;i<=m;i++)
      e[1][i]='C';
    for(i=1;i<=m;i++)
    {
      if(i%2==0)
        e[2][i]='C';
      else
        e[2][i]='P';
    }
    t=2;
    for(i=3;i<=m;i=i+2)
    {
      k=1;
      for(j=1;j<=m;j=j+2)
      {
        if(e[t][k]=='C')
        {
          e[i][j]='C';
          e[i][j+1]='C';
          e[i+1][j]='P';
          e[i+1][j+1]='C';
          k++;
        }
        else
        {
          e[i][j]='P';
          e[i][j+1]='P';
          e[i+1][j]='C';
          e[i+1][j+1]='P';
          k++;
        }
      }
      t++;
    }
    for(i=1;i<=m;i++)
    {
      for(j=1;j<=m;j++)
        printf("%c",e[i][j]);
      printf("\n");
    } 
  }
  return 0;
}
相关文章
|
2天前
|
监控 网络协议 算法
2026年起SSL证书有效期逐年缩短:企业如何避免“续期风暴”!
SSL证书有效期将从2026年起分三阶段逐步缩短至47天,人工续期难以为继。阿里云“WoSign SSL证书+自动化服务”,支持域名监控、自动托管、云产品/服务器一键部署及智能提醒,助力企业高效应对高频续期挑战。
8072 2
|
11天前
|
域名解析 人工智能 Linux
|
21天前
|
Linux Go 开发工具
手机上跑 DeepSeek 智能体:开源安卓客户端 DSH Go 安装与使用指南
DSH Go 是一款开源安卓客户端,将 DeepSeek Harness 智能体引擎装进手机:免 Root、免 Termux,一键安装即用;支持本机运行(内置 Ubuntu+Node.js)或远程接管电脑会话;具备插话打断、过程折叠、屏幕操控、端到端加密分享等特色功能,真正实现智能体“口袋化”。
18756 64
|
19天前
|
人工智能
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
进不去 Antigravity 或 Gemini,提示所在地区不可用?三步查清 Google 账号关联地区、官方更正表单理由选法与改区注意事项。
10140 13
Google 提示「所在地区不可用」?进不去 Antigravity 或 Gemini,先查账号这个设置
|
5天前
|
人工智能 安全 网络安全
|
10天前
|
Linux API iOS开发
【DSH】DeepSeek Harness新手保姆教程(下载+安装+配置+使用,2026最新实测)
DeepSeek Harness(dsh)是 DeepSeek AI 开源的智能体框架,秉持“一切皆插件”理念,支持读文件、改代码、执行命令、处理表格等自动化任务;免费开源,兼容 Win/macOS,需配 API 密钥使用。(239字)
1524 5
|
9天前
|
云安全 数据采集 人工智能
|
16天前
|
人工智能 开发工具 开发者
2026最新codex下载安装保姆级使用教程(下载+安装+登录+使用,含所有历史版本)
Codex 是 OpenAI 推出的开源 AI 编程智能体,跑在本地终端和桌面客户端里,能读懂整个代码仓库,一句自然语言就能让它改代码、执行命令、跑测试、修 Bug,支持 Windows、macOS、Linux 三大平台。本文把 Codex下载、安装、登录、汉化、基础使用一次讲全,并整理了国内用户最常踩的坑,跟着做 10 分钟就能跑起来。
2680 8
|
9天前
|
Web App开发 缓存 安全
巨魔商店 TrollStore 安装教程(2026):免电脑在线安装与全机型安装器矩阵_iOS巨魔安装
巨魔商店(TrollStore)是iOS 14–17.0(特定版本)的永久签名工具,无需越狱,利用CoreTrust漏洞实现IPA签名长期有效,彻底告别7天重签。支持免电脑在线安装(TrollHelperOTA),适配多机型/系统组合,开源免费,安全可控。(239字)
2261 0