E: Cats and Fish

时间限制:1000ms
单点时限:1000ms
内存限制:256MB

描述

There are many homeless cats in PKU campus. They are all happy because the students in the cat club of PKU take good care of them. Li lei is one of the members of the cat club. He loves those cats very much. Last week, he won a scholarship and he wanted to share his pleasure with cats. So he bought some really tasty fish to feed them, and watched them eating with great pleasure. At the same time, he found an interesting question:

There are m fish and n cats, and it takes ci minutes for the ith cat to eat out one fish. A cat starts to eat another fish (if it can get one) immediately after it has finished one fish. A cat never shares its fish with other cats. When there are not enough fish left, the cat which eats quicker has higher priority to get a fish than the cat which eats slower. All cats start eating at the same time. Li Lei wanted to know, after x minutes, how many fish would be left.

输入

There are no more than 20 test cases.

For each test case:

The first line contains 3 integers: above mentioned m, n and x (0 < m <= 5000, 1 <= n <= 100, 0 <= x <= 1000).

The second line contains n integers c1,c2 … cn,  ci means that it takes the ith cat ci minutes to eat out a fish ( 1<= ci <= 2000).

输出

For each test case, print 2 integers p and q, meaning that there are p complete fish(whole fish) and q incomplete fish left after x minutes.

样例输入
2 1 1
1
8 3 5
1 3 4
4 5 1
5 4 3 2 1
样例输出
1 0
0 1
0 3

暴力模拟下第几分钟第几条鱼的状态就好了

#include <bits/stdc++.h>
using namespace std;
struct Node
{
int c,s;
} a[];
int cmp(Node a,Node b)
{
return a.c<b.c;
}
int main()
{
ios::sync_with_stdio(false);
int m,n,x;
while(cin>>m>>n>>x)
{
for(int i=; i<n; i++)
cin>>a[i].c,a[i].s=;
sort(a,a+n,cmp);
for(int i=; i<=x; i++)
{
for(int j=; j<n&&m; j++)
{
if(a[j].s==)
{
a[j].s=a[j].c;
m--;
}
}
for(int j=; j<n; j++)
if(a[j].s)
{
a[j].s--;
}
}
int f=;
for(int j=; j<n; j++)
if(a[j].s)
{
f++;
}
printf("%d %d\n",m,f);
}
return ;
}

F: Secret Poems

时间限制:1000ms
单点时限:1000ms
内存限制:256MB

描述

The Yongzheng Emperor (13 December 1678 – 8 October 1735), was the fifth emperor of the Qing dynasty of China. He was a very hard-working ruler. He cracked down on corruption and his reign was known for being despotic, efficient, and vigorous.

Yongzheng couldn’t tolerate people saying bad words about Qing or him. So he started a movement called “words prison”. “Words prison” means literary inquisition. In the famous Zhuang Tinglong Case, more than 70 people were executed in three years because of the publication of an unauthorized history of the Ming dynasty.

In short, people under Yongzheng’s reign should be very careful if they wanted to write something. So some poets wrote poems in a very odd way that only people in their friends circle could read. This kind of poems were called secret poems.

A secret poem is a N×N matrix of characters which looks like random and meaning nothing. But if you read the characters in a certain order, you will understand it. The order is shown in figure 1 below:

figure 1                                                           figure 2

Following the order indicated by arrows, you can get “THISISAVERYGOODPOEMITHINK”, and that can mean something.

But after some time, poets found out that some Yongzheng’s secret agent called “Mr. blood dripping” could read this kind of poems too. That was dangerous. So they introduced a new order of writing poems as shown in figure 2. And they wanted to convert the old poems written in old order as figure1 into the ones in new order. Please help them.

输入

There are no more than 10 test cases.

For each test case:

The first line is an integer N( 1 <= N <= 100), indicating that a poem is a N×N matrix which consist of capital letters.

Then N lines follow, each line is an N letters string. These N lines represent a poem in old order.

输出

For each test case, convert the poem in old order into a poem in new order.

样例输入
5
THSAD
IIVOP
SEOOH
RGETI
YMINK
2
AB
CD
4
ABCD
EFGH
IJKL
MNOP
样例输出
THISI
POEMS
DNKIA
OIHTV
OGYRE
AB
DC
ABEI
KHLF
NPOC
MJGD

本来以为深搜好写,结果写炸了。还是直接for比较稳

#include <bits/stdc++.h>
using namespace std;
char s[][],c[][];
string c1,c2;
int n;
void la()
{
int j=,now=,U=,D=n,L=,R=n,i=,N=n*n;
if(N==)
{
printf("%c\n",c1[]);
}
else
{
while(now<N)
{
while(j<R&&now<N)
{
c[i][j]=c1[now++];
j++;
}
while(i<D&&now<N)
{
c[i][j]=c1[now++];
i++;
}
while(j>L&&now<N)
{
c[i][j]=c1[now++];
j--;
}
while(i>U&&now<N)
{
c[i][j]=c1[now++];
i--;
}
i++;
j++;
U++,D--;
L++,R--;
if(now==N-)c[i][j]=c1[now++];
}
for(i=; i<=n; i++)
{
printf("%c",c[i][]);
for(j=; j<=n; j++)
printf("%c",c[i][j]);
printf("\n");
}
}
return ;
}
int main()
{
while(cin>>n)
{
for(int i=; i<=n; i++)
scanf("%s",s[i]+);
c1="",c2="";
for(int i=; i<=n; i++)
if(i%)
{
int t=i;
for(int j=; j<=i; j++)
{
c1+=s[t--][j];
} }
else
{
int t=;
for(int j=i; j>; j--)
{
c1+=s[t++][j];
}
} for(int i=; i<n; i++)
if(i%)
{
int x=n-i+,y=n,t=i;
while(t--)
{
c2+=s[x++][y--];
} }
else
{
int x=n,y=n-i+,t=i;
while(t--)
{
c2+=s[x--][y++];
}
}
reverse(c2.begin(),c2.end());
c1=c1+c2;
la();
}
return ;
}

ACM-ICPC北京赛区2017网络同步赛的更多相关文章

  1. hihoCoder 1632 Secret Poems(ACM-ICPC北京赛区2017网络同步赛)

    时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 The Yongzheng Emperor (13 December 1678 – 8 October 1735), was ...

  2. hihoCoder 1631 Cats and Fish(ACM-ICPC北京赛区2017网络同步赛)

    时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are many homeless cats in PKU campus. They are all happy ...

  3. hihoCoder 1578 Visiting Peking University 【贪心】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)

    #1578 : Visiting Peking University 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Ming is going to travel for ...

  4. ACM-ICPC北京赛区(2017)网络赛1【模拟+枚举+数组操作】

    题目1 : Visiting Peking University 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 Ming is going to travel for n ...

  5. hihoCoder 1582 Territorial Dispute 【凸包】(ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)

    #1582 : Territorial Dispute 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In 2333, the C++ Empire and the Ja ...

  6. hihoCoder 1584 Bounce 【数学规律】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)

    #1584 : Bounce 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 For Argo, it is very interesting watching a cir ...

  7. hihoCoder 1586 Minimum 【线段树】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)

    #1586 : Minimum 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You are given a list of integers a0, a1, …, a2 ...

  8. ACM-ICPC北京赛区(2017)网络赛_Minimum

    题目9 : Minimum 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You are given a list of integers a0, a1, -, a2^k ...

  9. ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛 题目9 : Minimum

    时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 You are given a list of integers a0, a1, …, a2^k-1. You need t ...

随机推荐

  1. LoadRunner使用(2)

    一.基础函数 在VU左边导航栏中,有三个LoadRunner框架函数,分别是Vuser_init(),Action(),vuser_end().这三个函数存在于任何Vuser类型的脚本中. vuser ...

  2. python基础教程总结15——2 画幅好画

    要求:从Internet上下载数据文件:  分析数据文件并提取感兴趣的部分 工具:图形生成包(ReportLab,PYX等) 数据:太阳黑子和射电辐射流量(http://services.swpc.n ...

  3. 如何将SAP Multi Target应用部署到SAP云平台的Cloud Foundry环境去

    SHINA是SAP HANA Interactive Education的缩写,是一个demo应用,用于演示如何开发SAP HANA原生应用. 这个应用包含了sample数据以及HANA数据库表,vi ...

  4. HTTP 错误 404.15 - Not Found请求筛选模块被配置为拒绝包含的查询字符串过长的请求

    web项目中,get方式传值是通过地址栏中的url参数进行传递的.除了浏览器对url长度的限制大小不一之外,出于安全考虑, IIS中对于URL中参数大小也是有限制的,默认为2048KB. 如果参数大于 ...

  5. opencv将rgb图像转换成灰度图

    python写法: import cv2 img = cv2.imread(img_dir, cv2.IMREAD_GRAYSCALE) cv2.imwrite(dis_dir, img) imrea ...

  6. JQuery EasyUI学习记录(二)

    1.jquery easyUI动态添加选项卡(查看jquery easyUI手册) 1.1 用于动态添加一个选项卡 1.1.1 选中指定的选项卡和判断某个选项卡是否存在 测试代码: <a id= ...

  7. NOIP模拟赛 czy的后宫4

    czy的后宫4 [问题描述] czy有很多妹子,妹子虽然数量很多,但是质量不容乐观,她们的美丽值全部为负数(喜闻乐见). czy每天都要带N个妹子到机房,她们都有一个独一无二的美丽值,美丽值为-1到- ...

  8. 【dp】饥饿的牛

    普通dp题 题目描述 牛在饲料槽前排好了队.饲料槽依次用1到n(1 ≤ n ≤ 2000)编号.每天晚上,一头幸运的牛根据约翰的规则,吃其中一些槽里的饲料. 约翰提供b个区间的清单.一个区间是一对整数 ...

  9. Golang 简单静态web服务器

    直接使用 net.http 包,非常方便 // staticWeb package main import ( "fmt" "net/http" "s ...

  10. 下载linaro android 4.4.2 for panda4460

    $ export MANIFEST_REPO=git://android.git.linaro.org/platform/manifest.git$ export MANIFEST_BRANCH=li ...