首页 > 其他分享 >西南民族大学 春季 2023 训练赛 7

西南民族大学 春季 2023 训练赛 7

时间:2023-04-16 16:56:04浏览次数:48  
标签:arr int cin 春季 back 训练赛 2023 include pintia

题目详情 - L1-1 人与神 (pintia.cn)

换成php直接输出(

To iterate is human, to recurse divine.

题目详情 - L1-2 两小时学完C语言 (pintia.cn)

void solve()
{
    cin >> n >> k >> m;
    cout << n - k * m << endl;
}

题目详情 - L1-3 强迫症 (pintia.cn)

void solve()
{
    cin >> n;
    m = n/100;
    if(m < 100){
        if(m < 22)
        printf("20%02d-%02d",m,n%100);
        else
            printf("19%02d-%02d",m,n%100);
    }
    else{
        printf("%d-%02d",m,n%100);
    }
}

题目详情 - L1-4 降价提醒机器人 (pintia.cn)

void solve()
{
    cin >> n >> m;
    for(int i = 0 ; i < n; i++){
        double x;
        cin >> x;
        if(x < m)
            printf("On Sale! %.1lf\n",x);
    }
}

题目详情 - L1-5 大笨钟的心情 (pintia.cn)

void solve()
{
    for(int i = 0; i < 24 ; i++)
        cin >> pat[i];
    while(cin >> m){
        if(m < 0 || m >= 24) 
            break;
        cout << pat[m] << ' ' << (pat[m] > 50 ? "Yes" : "No") << endl; 
    }
}

题目详情 - L1-6 吉老师的回归 (pintia.cn)

用getline如果是存字符串数组的话记得把第一行的缓存的换行给getchar()掉......

void solve()
{
    string s1 = "qiandao", s2 = "easy";
    cin >> n >> m;
    for(int i = 0; i <= n; i++) {
        string s;
        getline(cin , s);
        if(s.find(s1) == string::npos && s.find(s2) == string::npos)
        {

            if(m < 0){
                cout << s << endl;
                return ;
            }
            m--;          
        }
    }
    cout << "Wo AK le" << endl;
}

题目详情 - L1-7 天梯赛的善良 (pintia.cn)

map<int,int> mp;
void solve()
{
    cin >> n;
    int minn = inf, maxx = -inf,v[N];
    for(int i = 0; i < n; i++){
        cin >> pat[i];
        mp[pat[i]] ++;
        minn = min(minn, pat[i]);
        maxx = max(maxx, pat[i]);
    }
    cout << minn << ' ' << mp[minn] << endl;
    cout << maxx << ' ' << mp[maxx] << endl;
}

 

题目详情 - L1-8 乘法口诀数列 (pintia.cn)

vector<int> v;
void solve()
{
    int a1,a2;
    cin >> a1 >> a2 >> n;
    v.push_back(a1);
    v.push_back(a2);
    int d = n;
    int cnt = 0;
    while(d--){
        int x = v[cnt];
        int y = v[++cnt];
        if(x * y >= 10){
            v.push_back(x * y / 10);
            v.push_back((x * y) % 10);
        }
        else{
            v.push_back(x * y);
        }
    }
    for(int i = 0; i < n; i++)
        cout << v[i] << (i == n - 1 ? "\n" : " ") ;
}

题目详情 - L2-1 包装机 (pintia.cn)

用栈进行模拟即可,轨道我用的是vector来存,可能需要注意的点就是框满了和轨道空了的情况.

void solve()
{
    int s;
    stack<char> kuang;
    cin >> n >> m >> s;
    vector<string> str;
    str.push_back(" ");
    for(int i = 1; i <= n; i ++){
        string s1;
        cin >> s1;
        str.push_back(s1);
    }
    int k;
    string ans = "";
    while(cin >> k && k != -1){
        if(k == 0){
            if(kuang.empty()) continue;
            ans += kuang.top();
            kuang.pop();
        }
        else {
            if (str[k].empty()) continue;
            if ((int) kuang.size() >= s) {
                ans += kuang.top();
                kuang.pop();
            }
            char c = str[k][0];
            kuang.push(c);
            str[k].erase(0, 1);
        }
    }
    cout << ans << endl;
}

 

题目详情 - L2-2 病毒溯源 (pintia.cn)

因为最开始变异的病毒可能是随机的,所以要先找到他的根病毒(?和根节点差不多一个意思吧),然后从这个点开始dfs,找到最长的变异链即可, 对于他说的最小序列,个人觉得这里有两种方法,一是当两者长度相等时,直接令ans1等于小的那个即可(vector可直接比较),二是在存结点的时候可以排个序,这样就能保证最开始的那条变异即是最小序列.

#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <set>
#include <utility>
#define inf 0x3f3f3f3f
#define endl '\n'
//#define int long long
#define f first
//#define s second

using namespace std;

const int N = 1e6+10, M = 1e6 + 10;

//typedef long long ll;
typedef pair<int,int> PII;
//queue<PII> q1;
//priority_queue <int,vector<int>,greater<int> > q2;
int n,m,t,sa,pa,q,k,sorce,pat[N];
/*
*/
vector<int> shu[N];
vector<int> ans1,arr;
bool vis[N];
int hai[N];
int ans = 0 ;
void dfs(int x, vector<int> &arr){
    if(arr.size() > ans1.size()){
        ans1 = arr;
    }
    if(arr.size() == ans1.size())
    {
        if(ans1 > arr)
            ans1 = arr;
    }
    for(auto j : shu[x]){
        arr.push_back(j);
        dfs(j, arr);
        arr.pop_back();
    }
    return ;
}
void solve()
{
    cin >> n;
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int x;
            cin >> x;
            vis[x] = true;
            shu[i].push_back(x);
        }
       // sort(shu[i].begin(), shu[i].end());
    }
    for(int i = 0; i < n; i ++){
        if(!vis[i]){
            arr.push_back(i);
            dfs(i,arr);
            break;
        }
    }
    cout << ans1.size() << endl;
    for(int i =0; i < ans1.size(); i++)
        cout << ans1[i] << (i == ans1.size() -1 ? "\n" : " ") ;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int Ke_scholar  = 1;
    while(Ke_scholar--)
    {
        solve();
    }
    return 0;
}

题目详情 - L2-3 清点代码库 (pintia.cn)

用map记录每个相同功能代码出现的次数,然后再将其赋值到结构体,最后对结构体进行排序并输出即可.

#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define endl '\n'
//#define int long long

using namespace std;

//typedef long long ll;
typedef pair<int,int> PII;
//queue<PII> q1;
map<vector<int>, int > mp;
//priority_queue <int,vector<int>,greater<int> > q2;
int n,m,t,k;
/*
*/
struct Ans{
    int num;
    vector<int> a;
    bool operator < (const Ans& s)const{
        if(num == s.num)
            return s.a > a;
        return num > s.num;
    }
};
vector<Ans> ans;
void solve()
{
    cin >> n >> m;
    for(int i = 0 ; i < n; i++){
        vector<int> p;
        int x;
        for(int j = 0; j < m; j++){
            cin >> x;
            p.push_back(x);
        }
            mp[p]++;
    }
    cout << mp.size() << endl;
    for(auto i : mp){
        Ans x;
        x.num = i.second;
        x.a = i.first;
        ans.push_back(x);
    }
    sort(ans.begin(), ans.end());
    for(auto i : ans){
        cout << i.num;
        for(auto j : i.a){
            cout << ' ' << j;
        }
        cout << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int Ke_scholar  = 1;
    while(Ke_scholar--)
    {
        solve();
    }
    return 0;
}

题目详情 - L2-4 哲哲打游戏 (pintia.cn)

此题是之前一道一样的题.

也是最后一道.

题解传送门->西南民族大学 春季 2023 训练赛 5 - Ke_scholar - 博客园 (cnblogs.com)

标签:arr,int,cin,春季,back,训练赛,2023,include,pintia
From: https://www.cnblogs.com/Kescholar/p/17323544.html

相关文章

  • 2023.04.16 - TS编译之后的JS不具备校验功能
    TypeScript编译后的JavaScript文件并不具备类型检查的功能,因为JavaScript语言本身是动态类型、弱类型的,在运行时无法推断变量的类型,只能在编译时推断。而将TypeScript文件编译成JavaScript文件时,会把TypeScript中的类型声明和类型检查都去掉,只保留JavaScript代码,所以......
  • KubeSphere 社区双周报 | OpenFunction 支持 Dapr 状态管理 | 2023.03.31-04.13
    KubeSphere社区双周报主要整理展示新增的贡献者名单和证书、新增的讲师证书以及两周内提交过commit的贡献者,并对近期重要的PR进行解析,同时还包含了线上/线下活动和布道推广等一系列社区动态。本次双周报涵盖时间为:2023.03.31-2023.04.13。贡献者名单新晋KubeSphereCon......
  • 2023高效的mysql 随机语句 200万数据为例 用了 0.0030秒
    是的,如果数据表中有200万条记录,使用 ORDERBYRAND() 这种方式来随机选择记录会非常慢,因为MySQL需要对整个表进行排序,然后再返回指定数量的记录。这个过程需要消耗大量的时间和资源。为了提高效率,可以考虑使用其他方法来实现随机选择记录。以下是一些常用的方法:使用 WHER......
  • 2023-3-16 #45 花花绿绿的色块勉勉强强拼凑成
    这是之前的博客。鸽了一年的ZYLOI终于举办了!讲完题的一刻,感觉心中的大石头终于落下来了!265P9150邮箱题很不错的题!!分置换环考虑,我们将一个置换环上的结点重新编号为\(1,2,\cdots,n\),倍长后断环为链。我们尝试维护若干条有序的链,每条链由一些点双连成。从后往前扫描每个点,......
  • 深度分析Palantir的投资价值,Palantir2023年将实现强劲反弹?
    在本文中,猛兽财经将通过对Palantir的股票关键指标、商业模式、盈利能力、影响Palantir2023年股价的关键利好因素等方面,对Palantir进行全面、深度的分析。Palantir股票的关键指标自从Palantir(PLTR)的股价在2021年1月25日大幅上涨至35.18美元后,其股价就开始下跌,并在2022年底下跌到了......
  • 2023年春面向对象第二单元
    23年春面向对象第二单元分析与总结目录概述JVM基础  JVM简介  JVM内存结构  java类的加载机制  JVM结构与多线程的关联架构  电梯  调度器  类图分析  对任务要求的回答bug分析总结概述  OO第二单元主要围绕着java多线程编程展开。在理论部分,课......
  • 2023.15 人工智能训练师
    AI在消灭一些职业岗位的同时,也会带来一些新的岗位,人工智能训练师就是其中之一。2020年,「人工智能训练师」正式成为新职业并纳入国家职业分类目录,是指「使用智能训练软件,在人工智能产品实际使用过程中进行数据库管理、算法参数设置、人机交互设计、性能测试跟踪及其他辅助作......
  • 2023年4月16日09:03:49
    昨天就画了软件工程的图,其他没有干。昨天的画图过程中有一个问题,就是自己没有很专注的去画图,不然那个图应该可以早点完成。现在你的SpringBoot又学完了一遍,什么叫有,但没办法,确实是又,但我学的很快,也学到了很多跟以前不一样的东西,现在我又有一个个人“规律那就是我不断的学,不断的......
  • 2023.4.16
    1#include<iostream>2usingnamespacestd;3//设计圆类和点类,判断点和圆的关系4classPoint5{6public:7voidsetX(intx)8{9m_X=x;10}11intgetX()12{13returnm_X;14}15voidsetY(inty)......
  • 2023年Rust发展如何?
    1.引言Rust是一种系统编程语言,它注重安全、并发和内存效率。自2010年首次发布以来,Rust一直在快速发展,吸引了越来越多的开发者加入其社区。Rust语言的设计目标是提供一种安全、并发和实用的语言,它可以满足系统编程的需求,同时也适用于其他领域。2.Rust在2022年的发展趋势在202......