中国东信杯”广西大学第三届程序设计竞赛

A++++++++++++++++++
链接:https://ac.nowcoder.com/acm/contest/12263/A
来源:牛客网

题目描述
有一天,小西的好朋友Antinomy来到西大参观,发现校园里有两副巨大的画,一幅的标题是《创新》,一幅的标题是《创业》,但都是空白的。

于是Antinomy问小西:“这两幅画应该是画的什么呀?”

小西:“里面是正在从事创新或者创业的同学。”

Antinomy:“什么是创新?”

小西:“从事高水平科研技术研究和参加高水平学科竞赛,简单来说就是学术活动和技能训练。”

Antinomy:“什么是创业?”

小西:“基于行业实际发展情况和实时政治经济情况,在有限资本下创立可持续盈利且具有较大发展空间的活动。”

小西:“至于为什么这两幅画是空白的,因为同学们都在参加创新创业竞赛。”

众所周知,创新创业类竞赛是我们学校人均参加的重量级竞赛,这一类别的竞赛在评奖评优或推免评比的考核中占据绝对性优势,即所谓的“A+”类竞赛。

但众所周知,之所以A+类竞赛是A+类竞赛,只是因为最高只能是这么多,现在Antinomy想知道,假设没有这个限制,给出竞赛名称冠名的Title集合,请求出这个竞赛的等级。

小西认为,对于给出的nn个title中,每能组成一对<national,international><national,international>(也就是中国国际),那么竞赛的等级就可以在A的基础上增加一个+。

输入描述:
输入第一行为测试用例TT,接下来有TT组测试数据

每组测试用例第一行为一个整数nn,表示有nn个title

接下来nn行每行一个字符串表示第ii个title,title只可能是national或者international

1 \leq T \leq 1001≤T≤100

3 \leq n \leq 10^43≤n≤10
4

输出描述:
对于每组测试用例输出此时的竞赛等级

示例1
输入
复制
4
3
national
international
national
4
national
international
national
international
4
national
national
national
national
4
international
international
national
national
输出
复制
A+
A++
A
A++

判断就性,注意map无中生有

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
//#include <ext/rope>
#include <bits/stdc++.h> 

using namespace std;
//using namespace __gnu_cxx;

#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl "\n"
//#define x first
//#define y second

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; 

//typedef __int128 INT;
typedef pair<double, int> PDI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;

inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int N = 2e5 + 10;
const int M = 3 * N;
const int mod = 998244353;
const int PP = 131;
const int inf = 0x3f3f3f3f;
//const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);

map<string, int> mp;

signed main(){
	//ios;
	int T;
	gt(T);
	while(T --){
		mp.clear();
		int n;
		cin >> n;
		for (int i = 1; i <= n; i ++){
			string str;
			cin >> str;
			mp[str] ++;
		}
		
		int ans = inf;
		if (mp["national"])   ans = min(ans, mp["national"]);
		else  ans = 0;
		if (mp["international"])    ans = min(ans, mp["international"]);
		else  ans = 0;
		
		cout << "A";
		for (int i = 0; i < ans; i ++)   cout << "+";
		cout << endl;
	}
	
    return 0;
}

GDP Carry

链接:https://ac.nowcoder.com/acm/contest/12263/B
来源:牛客网

题目描述
小西和Antinomy又来到君武楼,这里正在做A+类竞赛校赛的答辩,他们偷偷翻了翻参加答辩的项目组的项目计划书,发现每个计划书都有日流水这样的指标,他们决定做一个游戏。

现在有nn个项目计划书,每个计划书上有一个日流水数字,将这nn个日流水视为一个长度为nn的序列ff,两人轮流操作,Antinomy先手,

Antinomy每次需要把ff中非空的连续的一段移除,要求这一段的元素和需要为奇数;小西也每次需要把F中非空的连续的一段移除,但是这一段的元素和需要为偶数,如果轮到谁的时候无法操作下去那么这个人就判定为输。移除一段之后,原来这一段之前的部分和原来这一段之后的部分也视为连续。

已知他们都会采取最优的策略,给出这nn个日流水,请问最后谁会赢呢?

输入描述:
第一行输入nn,表示ff的长度,接下来一行nn个整数分别表示f_0,f_1,…,f_{n-1}f
0

,f
1

,…,f
n−1

3 \leq n \leq 10^63≤n≤10
6

1 \leq f_i \leq 10^9​1≤f
i

≤10
9

输出描述:
输出一行一个字符串表示胜利者,如果Antinomy胜利那么输出Antinomy,否则输出XiJam

示例1
输入
复制
4
1 2 3 4
输出
复制
Antinomy
示例2
输入
复制
3
2 2 4
输出
复制
XiJam

想象那个过程即可,奇数和偶数是常出现的

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
//#include <ext/rope>
#include <bits/stdc++.h> 

using namespace std;
//using namespace __gnu_cxx;

#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl "\n"
//#define x first
//#define y second

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; 

//typedef __int128 INT;
typedef pair<double, int> PDI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;

inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int N = 2e5 + 10;
const int M = 3 * N;
const int mod = 998244353;
const int PP = 131;
const int inf = 0x3f3f3f3f;
//const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);


signed main(){
	ios;
	int n;
	cin >> n;
	bool flag = false;
	for (int i = 1; i <= n; i ++){
		int x;
		cin >> x;
		if (x & 1)    flag = true;
	}
	
	if (flag)      cout << "Antinomy" << endl;
	else  cout << "XiJam" << endl;
	
    return 0;
}

Interpretability

链接:https://ac.nowcoder.com/acm/contest/12263/C
来源:牛客网

题目描述
小西和Antinomy在翻A+级比赛答辩的PPT时,发现PPT里列举的诸多指标之间都有相互支撑的关系,他们共同组织成了让评委看起来觉得很厉害同时也能站得住脚的观感。

说到站得住脚,众所周知三角形具有良好的稳定性,小西和Antinomy还发现,这一堆PPT列出的指标里,每个指标都有一个可信度。

如果任意三个指标的可信度,将其视为长度时能组成一个三角形的话,那么这三个指标就能相互支撑,从而看起来站得住脚。

经过整理之后发现,每个指标的可信度都是22的正整数次幂,且可信度为2^i2
i
的指标有f_if
i

个,只考虑三个指标相互支撑的情况,每个指标只能被用在一个相互支撑的三角形里。

现在Antinomy和小西想知道,给定一个数字nn,以及nn个数字f_1,f_2,…f_nf
1

,f
2

,…f
n

,这些指标最多能形成多少个相互支撑的三角形体系?

输入描述:
第一行输入一个数字nn

接下来一行有单个空格分隔的nn个数字,分别表示f_1,f_2,…f_nf
1

,f
2

,…f
n

,即可信度为2^i2
i
的指标有f_if
i

个,例如如果f_2=3f
2

=3,那么表示有33个长度为2^22
2
的指标。

3 \leq n \leq 4 \times 10^53≤n≤4×10
5

1 \leq f_i \leq 10^91≤f
i

≤10
9

输出描述:
输出一行一个整数表示最多能形成多少个三角形体系。

示例1
输入
复制
3
1 1 1
输出
复制
0
示例2
输入
复制
5
1 2 2 2 2
输出
复制
3
示例3
输入
复制
3
3 3 3
输出
复制
3
备注:
提示:并不是非要把2^i2
i
存下来

首先找性质,发现两个一样的大的,可以和任意一个小的组合,那就是说问这样的数有多少对,从前到后枚举,如果一个数出现的次数是小于3的,或者这个数对3取余数小于3,并且这些数和前面的也没法组合,那么这些数就是废物数,和后面的可以组合,加到废物数里面,然后尽量消灭废物数,每个数和前面的废物数的最大程度的结合,然后剩下不能结合的数,大于3的自我消化,剩下的充作废物数供给后面利用,一直贪心

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
//#include <ext/rope>
#include <bits/stdc++.h> 

using namespace std;
//using namespace __gnu_cxx;

#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl "\n"
//#define x first
//#define y second

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; 

//typedef __int128 INT;
typedef pair<double, int> PDI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;

inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int N = 4e5 + 10;
const int M = 3 * N;
const int mod = 998244353;
const int PP = 131;
const int inf = 0x3f3f3f3f;
//const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);

int a[N];
int n;

signed main(){
	ios;
	cin >> n;
	for (int i = 1; i <= n; i ++)    cin >> a[i];
	
	int ans = 0;
	int sum = 0;
	for (int i = 1; i <= n; i ++){
		int temp = (min(sum, a[i] / 2));
		ans += temp;
		a[i] -= (2 * temp);
		sum -= temp;
		if (a[i] < 3)  sum += a[i];
		else     sum += (a[i] % 3);
	}
	
	for (int i = 1; i <= n; i ++){
		ans += (a[i] / 3);
	}
	
	cout << ans << endl;
	
    return 0;
}

Antinomy与黑风海
链接:https://ac.nowcoder.com/acm/contest/12263/E
来源:牛客网

为了继续探寻带走了水晶公的爱梅特赛尔克的踪迹,沉迷《原初幻想41》的冒险者Antinomy进入了黑风海,原生种无影爱梅特赛尔克在黑风海使用创造魔法重现了原初世界分裂前的首都:亚马乌罗提

Antinomy发现亚马乌罗提是一座精心规划过的城市,且科技高度发达,或者说魔法高度发达(?)。

但是走着走着Antinomy发现任务点实在太远也太多了,在古代人面前也是光之打工人。他想知道从他现在的位置SS出发,每个任务点之间是单向连接的(别问我为什么是单向),每次去交完任务还要返回到SS才能交下一个任务,总共有n-1n−1个任务点,他想知道交完这n-1n−1个任务再回到SS,最少需要多长时间。

我们约定S的值为1,另外,既然能接到任务,那么任务一定是可完成的,换句话说从S出发一定能达到每个任务点,从每个任务点也一定能回到S。
输入描述:
第一行输入一行两个整数nn和mm表示 (任务点的数量+起点的数量) 和 任务点之间道路 的数量

接下来mm行每行三个整数a,b,ca,b,c,分别表示有一条从aa任务点到bb任务点的单向连接,需要花费cc的时间。

1 \leq n \leq 10^61≤n≤10
6

1 \leq m \leq 10^61≤m≤10
6

1 \leq a, b \leq n1≤a,b≤n
1 \leq c \leq 10^91≤c≤10
9

输出描述:
输出一行一个整数表示最少需要多少时间

示例1
输入
复制
5 10
2 3 5
1 5 5
3 5 6
1 2 8
1 3 8
5 3 4
4 1 8
4 5 3
3 5 6
5 4 2
输出
复制
83
备注:

问的就是从一号店到所有点的距离和,从所有点到1号点的距离和,前一个好算,后面的就是更换边的连接情况,然后跑最短路即可

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
//#include <ext/rope>
#include <bits/stdc++.h> 

using namespace std;
//using namespace __gnu_cxx;

#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl "\n"
//#define x first
//#define y second

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; 

//typedef __int128 INT;
typedef pair<double, int> PDI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;

inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int N = 2e6 + 10;
const int M = 3 * N;
const int mod = 998244353;
const int PP = 131;
const int inf = 0x3f3f3f3f;
//const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);

int h[N], e[N], w[N], ne[N], idx;
int n, m;
int dist[N];
bool st[N];

struct Edge{
	int a, b, w;
}edge[N];

void add(int a, int b, int c){
	e[idx] = b, ne[idx] = h[a], w[idx] = c, h[a] = idx ++;
}

int dijkstra(){
	priority_queue<PII, vector<PII>, greater<PII>> heap;
	heap.push({0, 1});
	memset(dist, 0x3f, sizeof dist);
	dist[1] = 0;
	memset(st, 0, sizeof st);
	
	while(heap.size()){
		auto t = heap.top();
		heap.pop();
		
		int ver = t.second, distance = t.first;
		
		if (st[ver])   continue;
		st[ver] = true;
		
		for (int i = h[ver]; ~i; i = ne[i]){
			int j = e[i];
			if (dist[j] > dist[ver] + w[i]){
				dist[j] = dist[ver] + w[i];
				heap.push({dist[j], j});
			}
		} 
	}
	
	int res = 0;
	for (int i = 2; i <= n; i ++)    res += dist[i];
	
	return res;
}

signed main(){
	ios;
	cin >> n >> m;
	memset(h, -1, sizeof h);
	
	for (int i = 1; i <= m; i ++){
		int a, b, c;
		cin >> a >> b >> c;
		edge[i] = {b, a, c};
		add(a, b, c);
	}
	
	int ans = dijkstra();
	
	idx = 0;
	memset(h, -1, sizeof h);
	
	for (int i = 1; i <= m; i ++){
		add(edge[i].a, edge[i].b, edge[i].w);
	}
	
	ans += dijkstra();
	
	cout << ans << endl;
	
    return 0;
}

Antinomy与伊修加德
链接:https://ac.nowcoder.com/acm/contest/12263/G
来源:牛客网

沉迷《原初幻想41》的冒险者Antinomy来到了伊修加德——苍穹之禁城,在光之战士到来前,已经经过了千年的龙诗战争,对艾欧泽亚其他国家一直采取封闭的态度。随着邪龙尼德霍格的消灭,龙诗战争也终于画下句号,伊修加德和龙族,以及莫古力们也需要共同探索出一条新的共存道路。

在5.0之后终于开放了雪都伊修加德的重建活动,这里成了生产系玩家打工人的天堂,除了伊修加德柠檬这一特产外,这里也盛产诸多不同烹调方式的拉拉肥,比如干锅、炭烤、油焖等等。

Antinomy也是烹饪系工匠,烹饪了一天拉拉肥之后,他发现还剩下nn种烹调方式的拉拉肥没卖完,每种都只剩一个了,同时交易板上还有mm个盘子正在出售。

Antinomy想买一些盘子来装拉拉肥,这样可以打包卖出去,每个拉拉肥不能拆开卖。

每个拉拉肥都有售价,第ii个拉拉肥卖出去后的售价是p_ip
i

金币。

每个盘子也需要花钱买,第ii个盘子需要花c_ic
i

金币,能装b_ib
i

个拉拉肥。

每个拉拉肥可以卖也可以不卖,但卖就必须要放在一个盘子里。Antinomy的利润就是卖出去的拉拉肥售价总和,减去盘子的花费。

Antinomy想知道她现在的最大利润是多少。假设Antinomy有足够多的本金,不用担心买不起盘子的问题。
输入描述:
第一行输入两个整数nn和mm表示拉拉肥的数量和盘子的数量。
接下来nn行每行一个整数p_ip
i

表示第ii个拉拉肥的售价
然后接下来mm行每行两个整数b_ib
i

和c_ic
i

,表示第ii个盘子能装多少个拉拉肥,以及买入的花费

1 \leq n \leq 10^41≤n≤10
4

1 \leq m \leq 5\times 10^21≤m≤5×10
2

1 \leq p_i,b_i,c_i \leq 10^41≤p
i

,b
i

,c
i

≤10
4

输出描述:
输出一行一个整数表示Antinomy能获得的最大利润。
示例1
输入
复制
4 3
180
160
170
190
2 100
3 120
4 250
输出
复制
480
说明
买1号盘子装1号和2号拉拉肥,买2号盘子装3和4号拉拉肥
示例2
输入
复制
2 2
1000
2000
1 6666
1 7777
输出
复制
0
说明
不卖

可以等效一下01背包,每个盘子可以等效为用或者不用,即为物品,每个盘子,每个盘子的价值取决于他的物品,用几个物品就花费了几个体积,也知道了多少个的价值,所以拉拉个数是背包容量,每个盘子是物品,但是不同的是,容量可以用一部分,盘子也可以用一部分, 并且体积小的话,盘子可以用一部分容量,价值也减少,价值从大到小排序,尽量先用大的

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <map>
#include <unordered_map>
#include <vector>
#include <cmath>
//#include <ext/rope>
#include <bits/stdc++.h> 

using namespace std;
//using namespace __gnu_cxx;

#define gt(x) x = read()
#define int long long
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl "\n"
//#define x first
//#define y second

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; 

//typedef __int128 INT;
typedef pair<double, int> PDI;
typedef pair<int, int> PII;
typedef unsigned long long ULL;

inline int read(){
    int x = 0, f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9'){
        x = (x<<1) + (x<<3) + (ch^48);
        ch = getchar();
    }
    return x * f;
}

inline void print(int x) {
  if (x < 0) { putchar('-'); x = -x; }
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}

const int N = 1e5 + 10;
const int M = 3 * N;
const int mod = 998244353;
const int PP = 131;
const int inf = 0x3f3f3f3f;
//const int INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-10;
const double PI = acos(-1);

int n, m;
int p[N];
int b[N], c[N];
int f[N];
int s[N];

bool cmp(int a, int b){
	return a > b;
}

signed main(){
	ios;
	cin >> n >> m;
	for (int i = 1; i <= n; i ++)    cin >> p[i];
	
	sort(p + 1, p + 1 + n, cmp);
	
	for (int i = 1; i <= n; i ++){
		s[i] = s[i - 1] + p[i];
	}
	
	for (int i = 1; i <= m; i ++)   cin >> b[i] >> c[i];
	
	int res = 0;
	for (int i = 1; i <= m; i ++){
		for (int j = n; j >= 0; j --){
			if (j >= b[i])     f[j] = max(f[j - b[i]] - c[i] + s[j] - s[j - b[i]], f[j]);
			else   f[j] = max(f[j], s[j] - c[i]);
			
			res = max(res, f[j]);
		}
	}
	
	cout << res << endl;
	
    return 0;
}
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值