7.18 18级牛客多校第三场

比赛过程

  前面还可以吧,就是太莽了常犯sb错误wa掉,后边被E和F卡死了,dp和数学好难qwq。

题解

A

题意

  给你个字符串,从前往后遍历,一共有4种字符:

  • type 0: There are no fish and no clam in this stage.
  • type 1: There are no fish and one clam in this stage.
  • type 2: There are one fish and no clam in this stage.
  • type 3: There are one fish and one clam in this stage.

  你可以做出下面四种操作之一:

  • 直接捕一条鱼(如果有鱼的话)。
  • 消费一个鱼饵捕一条鱼(如果无鱼有鱼饵的话)
  • 做鱼饵(如果有clam的话)
  • 啥也不干

  问你从头到尾你最多可以获得几条鱼。

解法
  1. 从时间早考虑到时间晚
  • 有蛤蜊就做鱼饵,没蛤蜊就就尝试用鱼饵钓鱼。最后若发现还剩 x 包鱼饵,就
    把制作比较晚的 x / 2 包鱼饵的时间拿来钓鱼。
  1. 从时间晚考虑到时间早
  • 若时间 i 有鱼饵,且时间 i 之后还留有没做鱼饵也没钓鱼的时间点,就在时间 i
    做鱼饵,否则该时间就预留着,等着用小于 i 的时间点做的鱼饵钓鱼。
代码

比赛用的解法二

#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<utility>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define RFOR(a,b,c) for(int a=b;a>=c;a--)
#define debug(x) cout<<x<<'\n'
#define all(x) (x).begin(), (x).end()
#define ls(x) x.resize(unique(all(x)) - x.begin())
using namespace std;
const int maxn=2e5+5005;
int sum[maxn];
int main() {
    IO;
	int t, n;
	string s;
	cin >> t;
    while(t--){
		cin >> n >> s;
		ll ans = 0;
        FOR(i,0,n-1) if(s[i]=='2'||s[i]=='3') ans++;
        int a = 0, b = 0;
        RFOR(i,n-1,0){
            if(s[i]=='0') b++;
            else if(s[i]=='1'){
                if(b!=0) b--, ans++;
                else if(a!=0) a--, ans++;
                else a++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

B

题意

  有一个字符串,有两种操作:

  1. 询问第 x 个字符。
  2. 把最左边的 x 个字符搬到最右边或把最右边 x 个字符搬到最左边。
解法

  维护一个指向字符串第一个字母的指针就行

代码
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<utility>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define RFOR(a,b,c) for(int a=b;a>=c;a--)
#define debug(x) cout<<x<<'\n'
#define all(x) (x).begin(), (x).end()
#define ls(x) x.resize(unique(all(x)) - x.begin())
using namespace std;
const int maxn=1e6+5;
int main() {
    IO;
    string s;
	int t, ling = 0, l , x;
	char c;
	cin >> s >> t;
	l = s.size();
	while(t--){
		cin >> c >> x;
		if(c=='M') ling = (ling - x + l) % l;
        else cout << s[(x - ling - 1 + l) % l] << endl;
    }
    return 0;
}

C

题意

  给你的图案是右手的形状,然后给你一堆手的坐标,让你判断是左手还是右手。

解法

  找道长度分别为6和9的直线做个向量叉乘就行了,注意eps不能小于1e-6

代码
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<utility>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define RFOR(a,b,c) for(int a=b;a>=c;a--)
#define debug(x) cout<<x<<'\n'
#define all(x) (x).begin(), (x).end()
#define ls(x) x.resize(unique(all(x)) - x.begin())
using namespace std;
typedef pair<double,double> Pd;
const double eps = 1e-3;
double getdis(Pd a,Pd b){
    return sqrt((a.first - b.first) * (a.first - b.first) + (a.second - b.second) * (a.second - b.second));
}
int judge(int a,int b,int c, int d){
    if(a*d-c*b>0)
        return 1;
    return 0;
}
int main() {
    IO;
    int t;
    cin >> t;
    vector<Pd> v;
	while(t--){
		int s[20] = {0};
        v.clear();
        FOR(i,1,20){
			double x, y;
            cin >> x >> y;
            v.push_back(make_pair(x, y)); 
        }
        FOR(i,0,19){
            int j =(i+1)%20;
			double dis = getdis(v[i],v[j]);
			if(fabs(dis-6)<eps){
				s[i]++, s[j]++;
			}
			else if(fabs(dis-9)<eps){
				s[i]++, s[j]++;
			}
        }
		Pd x1, x2, x3;
		FOR(i,0,19){
			if(s[i]==2){
				x1 = v[i];
			}
		}
		FOR(i,0,19){
			if(s[i]==1){
				double dis = getdis(x1,v[i]);
				if(fabs(dis-6)<eps) x3 = v[i];
				else x2 = v[i];
			}
		}
		if(judge(x2.first-x1.first,x2.second-x1.second,x3.first-x1.first,x3.second-x1.second)){
            cout << "right" << endl;
        }
        else
            cout << "left" << endl;
    }
    return 0;
}

D

题意
解法
代码

E

题意

  就是给你一个包含 n 个元素(n 为偶数)的序列 a a a ,然后选择任意两个元素组合,每个元素只能组合一次且所有的元素都必须组合,定义 c o s t cost cost 为所有组合元素的差的绝对值之和。现在让你求两种组合方案的 c o s t cost cost 之和的最小值,注意方案与方案之间不能出现任何相同的组合。

解法

  易得把 a a a 排序之后两两组合是 c o s t cost cost 最小的方案,问题在于怎么求次小的方案。然后一般我们都可以想到错一位,形如 ( a 2 , a 3 ) ( a 4 , a 5 ) ( a 6 , a 7 ) ( a 1 , a 8 ) (a_2,a_3)(a_4,a_5)(a_6,a_7)(a_1,a_8) (a2,a3)(a4,a5)(a6,a7)(a1,a8) 的组合,下面分类讨论一下:

  • n = 4 n=4 n=4 时,次小只有 ( a 2 , a 3 ) ( a 1 , a 4 ) (a_2,a_3)(a_1,a_4) (a2,a3)(a1,a4) 一种组合,和最小的方案加和一下,此时的 c o s t cost cost ( a 2 − a 1 ) + ( a 4 − a 3 ) + ( a 4 − a 1 ) + ( a 3 − a 2 ) = 2 ∗ ( a 4 − a 1 ) (a_2-a_1)+(a_4-a_3)+(a_4-a_1)+(a_3-a_2)=2*(a_4-a_1) (a2a1)+(a4a3)+(a4a1)+(a3a2)=2(a4a1)

  • n = 6 n=6 n=6 时,因为如果把 6 拆成 4 和 2 肯定会有一个组合与最小方案冲突,所以只能把这6个当成整体,然后分析之后可以发现此时 c o s t cost cost 应该是 2 ∗ ( a 6 − a 1 ) 2*(a_6-a_1) 2(a6a1) (证明略)

  • n = 8 n=8 n=8 时,易得 ( a 8 − a 1 ) (a_8-a_1) a8a1 肯定比 ( a 4 − a 1 ) + ( a 8 − a 5 ) (a_4-a_1)+(a_8-a_5) (a4a1)+(a8a5) 要大 ,所以 n = 8 n=8 n=8 时可以拆成两个 n = 4 n=4 n=4 来做

  • n = 10 n=10 n=10时, 同理可拆成一个 n = 4 n=4 n=4 和一个 n = 6 n=6 n=6

  • n ≥ 12 n\geq12 n12 时,这时候发现既可以拆成三个 n = 4 n=4 n=4 又可以拆成2个 n = 6 n=6 n=6,这就涉及到 2 ∗ { ( a 4 − a 1 ) + ( a 8 − a 5 ) + ( a 12 − a 9 ) } 2*\lbrace(a_4-a_1)+(a_8-a_5)+(a_{12}-a_9)\rbrace 2{(a4a1)+(a8a5)+(a12a9)} 2 ∗ { ( a 6 − a 1 ) + ( a 12 − a 7 ) } 2*\lbrace(a_6-a_1)+(a_{12}-a_7)\rbrace 2{(a6a1)+(a12a7)} 的大小比较,这就涉及到具体的 a a a 序列是什么,所以必须要DP了

代码
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<utility>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define RFOR(a,b,c) for(int a=b;a>=c;a--)
#define debug(x) cout<<x<<'\n'
#define all(x) (x).begin(), (x).end()
#define ls(x) x.resize(unique(all(x)) - x.begin())
using namespace std;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn=2e5+5;
ll a[maxn];
ll dp[maxn];
int main() {
    IO;
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        FOR(i,1,n){
            cin >> a[i];
            dp[i] = 0;
        }
        sort(a + 1, a + 1 + n);
        dp[2] = INF;
        dp[4] = 2 * (a[4] - a[1]);
        dp[6] = 2 * (a[6] - a[1]);
        FOR(i,8,n){
            dp[i] = min(dp[i - 4] + 2 * (a[i] - a[i - 3]), dp[i - 6] + 2 * (a[i] - a[i - 5]));
        }
        cout << dp[n] << endl;
    }
    return 0;
}

F

题意

  给你一个分数 a b ( 1 ≤ a , b ≤ 2 × 1 0 6 ) \frac ab(1\leq a,b\leq2×10^6) ba(1a,b2×106) 让你构造出两个分数 c d , e f \frac cd,\frac ef dc,fe 满足 c d − e f = a b \frac cd-\frac ef=\frac ab dcfe=ba d , f < b ≤ 4 × 1 0 12 d,f<b\leq4×10^{12} d,f<b4×1012 ,没有满足条件的输出-1 -1 -1 -1

解法

  先判断 G C D ( a , b ) GCD(a,b) GCD(a,b) 是否等于1,等于的话很容易就可以构造出答案,否则分解分母 b b b ,使得 d ∗ f = b d*f=b df=b G C D ( d , f ) = 1 GCD(d,f)=1 GCD(d,f)=1,如果 d d d f f f 只有出现1的分解,则输出-1,否则再用 EXGCD 求 c , e c,e c,e ,注意最后还要处理一下 c , e c,e ce 是负数的情况。

代码
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<utility>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define RFOR(a,b,c) for(int a=b;a>=c;a--)
#define debug(x) cout<<x<<'\n'
#define all(x) (x).begin(), (x).end()
#define ls(x) x.resize(unique(all(x)) - x.begin())
using namespace std;
long long PRIMES[223] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409};
const int maxn=2e5+5;
ll a[maxn];
ll dp[maxn];
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll exgcd(ll l,ll r,ll &x,ll &y){
    if(r==0){x=1;y=0;return l;}
    else{
        ll d=exgcd(r,l%r,y,x);
        y-=l/r*x;
        return d;
    }
}
int main() {
    //IO;
    int t;
    cin >> t;
    while(t--){
        int a, b;
        ll c, d, e, f;
        cin >> a >> b;
        int g=gcd(a,b);
        if(g!=1){
            printf("%d %d %d %d\n",a/g+1,b/g,1,b/g);
            continue;
        }
        d = 1, f = b;
        FOR(i,0,222){
            if(f%PRIMES[i]==0){
                while(f%PRIMES[i]==0){
                    d *= PRIMES[i];
                    f /= PRIMES[i];
                }
                break;
            }
        }
        if(d==1||f==1){
            cout << "-1 -1 -1 -1" << endl;
            continue;
        }
        exgcd(f, d, c, e);
        e = (e % f) * (-a);
        e = (e % f + f) % f + f;
        c = (a + e * d) / f;
        cout << c << " " << d << " " <<  e << " " << f << endl;
    }
    return 0;
}

G

题意
解法
代码

L

题意

  签到题,把 Y Y Y 写成 y y y 结果wa了一发就很傻逼

解法

  transform(s.begin(), s.end(), s.begin(), ::tolower);

代码
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<unordered_map>
#include<vector>
#include<stack>
#include<string>
#include<cstring>
#include<cstdio>
#include<utility>
#define ll long long
#define ull unsigned long long
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define endl '\n'
#define pi acos(-1)
#define lowbit(x) ((x)&(-(x)))
#define debug(x) cout<<x<<'\n'
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define RFOR(a,b,c) for(int a=b;a>=c;a--)
#define debug(x) cout<<x<<'\n'
#define all(x) (x).begin(), (x).end()
#define ls(x) x.resize(unique(all(x)) - x.begin())
using namespace std;
int main() {
    IO;
	string s;
	cin >> s;
	transform(s.begin(), s.end(), s.begin(), ::tolower);
	if(s.find("lovely")==0){
		cout << "lovely" << endl;
	}
	else
		cout << "ugly" << endl;
	return 0;
}
# 高校智慧校园解决方案摘要 智慧校园解决方案是针对高校信息化建设的核心工程,旨在通过物联网技术实现数字化校园的智能化升。该方案通过融合计算机技术、网络通信技术、数据库技术和IC卡识别技术,初步实现了校园一卡通系统,进而通过人脸识别技术实现了更精准的校园安全管理、生活管理、教务管理和资源管理。 方案包括多个管理系统:智慧校园管理平台、一卡通卡务管理系统、一卡通人脸库管理平台、智能人脸识别消费管理系统、疫情防控管理系统、人脸识别无感识别管理系统、会议签到管理系统、人脸识别通道管理系统和图书馆对接管理系统。这些系统共同构成了智慧校园的信息化基础,通过统一数据库和操作平台,实现了数据共享和信息一致性。 智能人脸识别消费管理系统通过人脸识别终端,在无需接触的情况下快速完成消费支付过程,提升了校园服务效率。疫情防控管理系统利用热成像测温技术、视频智能分析等手段,实现了对校园人员体温监测和疫情信息实时上报,提高了校园公共卫生事件的预防和控制能力。 会议签到管理系统和人脸识别通道管理系统均基于人脸识别技术,实现了会议的快速签到和图书馆等场所的高效通行管理。与图书馆对接管理系统实现了一卡通系统与图书馆管理系统的无缝集成,提升了图书借阅的便捷性。 总体而言,该智慧校园解决方案通过集成的信息化管理系统,提升了校园管理的智能化水平,优化了校园生活体验,增强了校园安全,并提高了教学和科研的效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值