VK Cup 2017 - Квалификация 2
因为资格赛1已经通过了,资格赛2随便打打玩。这次题目比上次还简单,FallDream看了两眼觉得太水就不做了,我一个人闲着无聊只好默默做了
A. Новый пароль
题目大意:给出N和K,要求构造一个长为N,出现K种字符,相邻字符不相同的字符串。(2<=K<=N<=100,K<=26)
思路:第i个字符输出i%K+'a'。
#include<cstdio>
int main()
{
int n,k,i;
scanf("%d%d",&n,&k);
for(i=;i<n;++i)putchar('a'+i%k);
}
B. Максимизируй сумму цифр
题目大意:给出N,求不超过N的各位数字和最大的数字。(N<=10^18)
思路:枚举一个非零位减一,后面全部换成9,更新答案。
#include<iostream>
#define ll long long
using namespace std;
int p[];
void ts(ll x){for(int i=;x;++i,x/=)p[i]=x%;}
ll ti(){ll r=;for(int i=;i--;)r=r*+p[i];return r;}
int sum(){int r=;for(int i=;i<;++i)r+=p[i];return r;}
int main()
{
ll x,ans;int i,j,mx;
cin>>x;ts(ans=x);mx=sum();
for(i=;i<;++i)if(p[i])
{
for(--p[i],j=;j<i;++j)p[j]=;
if(sum()>mx)mx=sum(),ans=ti();
}
cout<<ans;
}
C. Онлайн-курсы в БГУ
题目大意:共有N门课程,每门课程学之前必须学一些其他课程,一个人要学K门课程,要求构造一个学的课程最少的方案,按顺序输出,没有方案输出-1。(N<=100000,所有课程学之前必须学的加起来不超过100000个)
思路:先建反图BFS出所有必须学的,然后拓扑排序。
#include<cstdio>
char B[<<],*S=B,C;int X;
inline int read()
{
while((C=*S++)<''||C>'');
for(X=C-'';(C=*S++)>=''&&C<='';)X=(X<<)+(X<<)+C-'';
return X;
}
#define MN 100000
struct edge{int nx,t;}e[MN*+];
int h[MN+],rh[MN+],en,q[MN+],qn,u[MN+],r[MN+];
inline void ins(int*h,int x,int y){e[++en]=(edge){h[x],y};h[x]=en;}
int main()
{
fread(B,,<<,stdin);
int n,i,j,x;
n=read();qn=read();
for(i=;i<=qn;++i)u[q[i]=read()]=;
for(i=;i<=n;++i)for(j=read();j--;)ins(h,x=read(),i),ins(rh,i,x);
for(i=;i<=qn;++i)for(j=rh[q[i]];j;j=e[j].nx)if(!u[e[j].t])u[q[++qn]=e[j].t]=;
for(i=;i<=n;++i)if(u[i])for(j=h[i];j;j=e[j].nx)++r[e[j].t];
for(x=qn,qn=,i=;i<=n;++i)if(u[i]&&!r[i])q[++qn]=i;
for(i=;i<=qn;++i)for(j=h[q[i]];j;j=e[j].nx)if(u[e[j].t]&&!--r[e[j].t])q[++qn]=e[j].t;
if(qn<x)return puts("-1"),;
printf("%d\n",x);
for(i=;i<=x;++i)printf("%d ",q[i]);
}
D. Нарисуй скобки!
题目大意:给你一个长为N的括号序列,要求你把它……画出来……(N<=100)
思路:大模拟()
#include<cstdio>
#define MN 100
#define ML 250
char s[MN+],ans[MN+][ML+];
int main()
{
int n,i,j,p,l,r;
scanf("%d%s",&n,s);
for(i=l=r=;i<n;++i,r=l>r?l:r)l+=s[i]=='['?:-;
for(i=p=;i<n;++i,++p)
{
ans[l][p]=ans[r][p]='+';
for(j=l+;j<r;++j)ans[j][p]='|';
if(s[i]=='[')ans[l][p+]=ans[r][p+]='-';
if(s[i]==']')ans[l][p-]=ans[r][p-]='-';
if(s[i]=='['&&s[i+]=='[')++l,--r;
if(s[i]=='['&&s[i+]==']')p+=;
if(s[i]==']'&&s[i+]==']')--l,++r;
}
for(i=;i<=r;++i,puts(""))for(j=;j<p;++j)putchar(ans[i][j]?ans[i][j]:' ');
}
VK Cup 2017 - Квалификация 2的更多相关文章
- VK Cup 2017 - Квалификация 1
CF上的VK Cup 2017资格赛1,好像很水,因为只有俄文所以语言是最大的障碍--不过之后正式赛貌似就有英文了.(比赛貌似只有开俄文模式才看的到--) 时长1天,不随时间扣分.FallDream ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 菜鸡只会ABC!
Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) 全场题解 菜鸡只会A+B+C,呈上题解: A. Bear and ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3)(A.B.C,3道暴力题,C可二分求解)
A. Is it rated? time limit per test:2 seconds memory limit per test:256 megabytes input:standard inp ...
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) A B C D 水 模拟 二分 贪心
A. Is it rated? time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2)(A.思维题,B.思维题)
A. Vicious Keyboard time limit per test:2 seconds memory limit per test:256 megabytes input:standard ...
- VK Cup 2017 - Round 1
和FallDream组队瞎打一通--B两个人写的都挂了233,最后只剩下FallDream写的A和我写的C,最后我yy了个E靠谱做法结果打挂了,结束之后改了改就A了,难受. AC:AC Rank:18 ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) 题解【ABCDE】
A. Vicious Keyboard 题意:给你一个字符串,里面只会包含VK,这两种字符,然后你可以改变一个字符,你要求VK这个字串出现的次数最多. 题解:数据范围很小,暴力枚举改变哪个字符,然后c ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何
A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #405 (rated, Div. 2, based on VK Cup 2017 Round 1) E
Description Bear Limak prepares problems for a programming competition. Of course, it would be unpro ...
随机推荐
- C语言——第0次作业(二)
1.翻阅邹欣老师的关于师生关系博客,并回答下列问题,每个问题的答案不少于500字: 1.最理想的师生关系是健身教练和学员的关系,在这种师生关系中你期望获得来自老师的哪些帮助? 在现代软件工程讲义 0 ...
- 使用 memoryview 和 struct 查看一个 GIF 图像的首部
>>> import struct >>> fmt = '<3s3sHH' # ➊ >>> with open('filter.gif', ...
- python 实现cm批量上传
import requests import json import time import random url = 'http://cm.admin.xxxx.com/customer/aj_ad ...
- 51Nod P1100 斜率最大
传送门: https://www.51nod.com/onlineJudge/questionCode.html#!problemId=1100 由于2 <= N <= 10000, 所以 ...
- 流程控制语句(MySQL/MariaDB )
本文目录:1.BEGIN...END2.true和false3.if结构4.case结构5.loop.leave和iterate6.repeat循环7.while循环 MySQL/MariaDB中的符 ...
- java异常常见面试问题
java异常常见面试问题 一.java异常的理解 异常主要是处理编译期不能捕获的错误.出现问题时能继续顺利执行下去,而不导致程序终止,确保程序的健壮性. 处理过程:产生异常状态时,如果当前的conte ...
- H5 FormData对象的作用及用法
JS: function uploadFileAndParam() { var url = "http://localhost:42561/api/upload/UploadPost&quo ...
- Spring Security 入门(1-3-2)Spring Security - http元素 - intercept-url配置
http元素下可以配置登录页面,也可以配置 url 拦截. 1.直接配置拦截url和对应的访问权限 <security:http use-expressions="false" ...
- Java设计模式(七)Decorate装饰器模式
一.场景描述 (一)问题 系统中最初使用Crystal Report(水晶报表)工具生成报表,并将报表发送给客户端查看,此时定义一CrystalReport工具类即可完成水晶报表的生成工作. 后续报表 ...
- windbg分析Kernel32.dll导出表
写在前面的话: 继续上篇,在获得了Kernel32.dll基址的基础上,分析它的导出表结构: 对PE结构不太熟悉的同学,可以参考看雪论坛里的一篇帖子:https://bbs.pediy.com/thr ...