2018年ACM-ICPC焦作现场赛补题

一点点的补焦作的题 ,慢慢更新。

题目链接:https://codeforces.com/gym/102028

目录

A

B

C

D

E

F

G

H

I

J

 


A

A. Xu Xiake in Henan Province

time limit per test

2.0 s

memory limit per test

1024 MB

input

standard input

output

standard output

Shaolin Monastery, also known as the Shaolin Temple, is a Chan ("Zen") Buddhist temple in Dengfeng County, Henan Province. Believed to have been founded in the 55-th century CE, the Shaolin Temple is the main temple of the Shaolin school of Buddhism to this day.

Longmen Grottoes, are some of the finest examples of Chinese Buddhist art. Housing tens of thousands of statues of Buddha and his disciples, they are located 1212 kilometres (7.57.5 mi) south of present-day Luoyang in Henan province.

White Horse Temple is, according to tradition, the first Buddhist temple in China, established in 6868 AD under the patronage of Emperor Ming in the Eastern Han dynasty capital Luoyang.

The Yuntai Mountain is situated in Xiuwu County, Jiaozuo, Henan Province. The Yuntai Geo Park scenic area is classified as an AAAAA scenic area by the China National Tourism Administration. Situated within Yuntai Geo Park, with a fall of 314 metres, Yuntai Waterfall is claimed as the tallest waterfall in China.

They are the most famous local attractions in Henan Province.

Now it's time to estimate the level of some travellers. All travellers can be classified based on the number of scenic spots that have been visited by each of them.

  • A traveller that visited exactly 00 above-mentioned spot is a "Typically Otaku".
  • A traveller that visited exactly 11 above-mentioned spot is a "Eye-opener".
  • A traveller that visited exactly 22 above-mentioned spots is a "Young Traveller".
  • A traveller that visited exactly 33 above-mentioned spots is a "Excellent Traveller".
  • A traveller that visited all 44 above-mentioned spots is a "Contemporary Xu Xiake".

Please identify the level of a traveller.

Input

The input contains several test cases, and the first line contains a positive integer TT indicating the number of test cases which is up to 104104.

For each test case, the only one line contains four integers A1A1, A2A2, A3A3 and A4A4, where AiAi is the number of times that the traveller has visited the ii-th scenic spot, and 0≤A1,A2,A3,A4≤1000≤A1,A2,A3,A4≤100. If AiAi is zero, it means that the traveller has never been visiting the ii-th spot.

Output

For each test case, output a line containing one string denoting the classification of the traveller which should be one of the strings "Typically Otaku", "Eye-opener", "Young Traveller", "Excellent Traveller" and "Contemporary Xu Xiake" (without quotes).

Example

input

Copy

5
0 0 0 0
0 0 0 1
1 1 0 0
2 1 1 0
1 2 3 4

output

Copy

Typically Otaku
Eye-opener
Young Traveller
Excellent Traveller
Contemporary Xu Xiake

过于简单直接上代码吧。

#include <bits/stdc++.h>
using namespace std;
const int MAXN=2e5+7;
typedef long long ll;
string str[200];
typedef pair<string,int> P;
vector<vector<P> >v;
map<pair<string,int>,int>m;
int a[MAXN];
int n;
int t,x;
int main() {
    while(cin >> t) {
        map<int,int>m;
        for(int i = 1; i <= t; i++) {
//                m.clear();
            int cnt = 0;
            for(int j = 1; j <= 4; j++) {
                cin >> x;
                if(x) cnt++;
            }
            if(cnt == 0) {
                printf("Typically Otaku\n");
            } else if(cnt == 1) {
                printf("Eye-opener\n");

            } else if(cnt == 2) {
                printf("Young Traveller\n");

            } else if(cnt == 3) {
                printf("Excellent Traveller\n");

            } else if(cnt == 4) {
                printf("Contemporary Xu Xiake\n");

            }
        }
    }
    return 0;
}


B

C

D

E

F

G

H

I

I. Distance

time limit per test

6.0 s

memory limit per test

1024 MB

input

standard input

output

standard output

There are nn points on a horizontal line, labelled with 11 through nn from left to right.

The distance between the ii-th point and the (i+1)(i+1)-th point is aiai.

For each integer kk ranged from 11 to nn, you are asked to select exactly kk different given points on the line to maximize the sum of distances between all pairs of selected points.

Input

The input contains several test cases, and the first line contains a positive integer TT indicating the number of test cases which is up to 10001000.

For each test case, the first line contains an integer nn indicating the number of points, where 2≤n≤1052≤n≤105.

The second line contains (n−1)(n−1) positive integers a1,a2,⋯,an−1a1,a2,⋯,an−1, where 1≤ai≤1041≤ai≤104.

We guarantee that the sum of nn in all test cases is up to 106106.

Output

For each test case, output a line containing nn integers, the ii-th of which is the maximum sum of distances in case k=ik=i. You should output exactly one whitespace between every two adjacent numbers and avoid any trailing whitespace in this line.

Example

input

Copy

1
5
2 3 1 4

output

Copy

0 10 20 34 48

Note

The figure below describes the sample test case.

The only best selection for k=2k=2 should choose the leftmost and the rightmost points, while a possible best selection for k=3k=3 could contain any extra point in the middle.

题意:给你n个点之间的距离,让你每次选择i个不同的点(1 <= i <= n),询问选择1到n个不同的点,最大的距离。

首先我们可以在下面画一下,要找到最大距离,肯定是从两边选择,一次选择左边、一次再选择右边,这样依次下去

我们可以画个图,假设我们现在有1到5个点,而且已经选择了1和5了,那么我们可以选择4和2,就可以得到下面这个图(画的很丑,不要嫌弃QvQ)

可以发现,每次我们所增加的贡献就是l到r的区间和,比如选择2的时候,1到2和2到5,可以用上次的贡献来得到,对于2和4,就是l到r的区间和,所以我们用类似双指针的那种写法,定义一个l和r,然后对于每次,l--或者r++,(可以证明,无论先变哪个都是等值的),然后保存上次的贡献,这次的贡献l到r的区间和+上次的贡献,就可以得到这次的总的贡献。

代码如下:

#include <bits/stdc++.h>
using namespace std;
const int MAXN=2e5+7;
typedef long long ll;
string str[200];
typedef pair<string,int> P;
vector<vector<P> >v;
map<pair<string,int>,int>m;
ll a[MAXN];
ll pres[MAXN];
ll posts[MAXN];
ll presum[MAXN];
ll postsum[MAXN];
bool cmp(int a,int b) {
    return a > b;
}
int n,t;
int main() {
    while(cin >> t) {
        while(t--) {
            memset(posts,0,sizeof(posts));
            cin >> n;
            for(ll i = 2; i <= n; i++) cin >> a[i];
            for(ll i = 1; i <= n; i++) pres[i] = pres[i - 1] + a[i];
            ll ans = 0;
            ll l = 1,r = n - 1;
            if(n == 2) {
                cout << 0 << " " << pres[n] << endl;
                continue;
            } else
                cout << 0 << " " << pres[n] << " ";
            ans = pres[n];
            ll num = ans;
            for(int i = 3; i <= n; i++) {
                if(i & 1) {
                    ans += num;
                    l++;
                } else {
                    num += pres[r] - pres[l];
                    ans += num;
                    r--;
                }
                if(i == n) cout << ans << endl;
                else
                    cout << ans <<  " ";
            }
        }
    }
    return 0;
}

J

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值