首页 > 其他分享 >2024/1/21-2024/1/28

2024/1/21-2024/1/28

时间:2024-01-28 12:56:20浏览次数:26  
标签:std 21 people int 28 long 2024 using save

M. Gitignore

Your git project (you don't need to be familiar with git to solve this problem) has some files that should be ignored from synchronizing. You need to calculate the minimum number of lines needed for gitignore.

Formally, your project is a folder. A folder can have files and sub folders. There are no empty folders (i.e. folders without any files or sub folders inside). Initially, the git software will synchronize all the files in your project. However, you can specify some files and folders in the settings (which is called gitignore) to exclude them from synchronizing. For each line in gitignore, you can specify either a file or all the files in a folder. You can not ignore the whole project folder (i.e. an empty line in gitignore).

You are given paths for all the files in the project and whether they should be ignored or shouldn't. Your task is to calculate the minimum number of lines for gitignore.

map暴力硬写就完了,要大胆暴力

#include"bits/stdc++.h"
using namespace std;
using ll=long long;

void save_the_people() {
    int n,m;
    cin>>n>>m;
    int ans{n};
    map<string,int> mp;
    string s1[n],s2[m];
    for(int i{0};i<n;i++){
        cin>>s1[i];
    }
    for(int i{0};i<m;i++){
        cin>>s2[i];
    }
    for(int i{0};i<m;i++){
        int p=s2[i].size();
        string ss="";
        for(int j{0};j<p;j++){
            ss+=s2[i][j];
            if(s2[i][j]=='/'){
                mp[ss]=1;
            }
        }
    }

    for(int i{0};i<n;i++){
        int p=s1[i].size();
        string ss="";
        for(int j{0};j<p;j++){
            ss+=s1[i][j];
            if(s1[i][j]=='/'){
                if(mp[ss]==0) { mp[ss] = 2; }

            else if(mp[ss]==2){
                ans--;
                break;
            }}
        }
    }
    cout<<ans<<"\n";
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t{1};
    cin>>t;
    while(t--) {
        save_the_people();
    }
}

J. Let's Play Jigsaw Puzzles!

模拟,先找出左上角那个,然后一次排出一排,剩下的再依次以这一排位基排列;
注意使用快速读取;

#include"bits/stdc++.h"
using namespace std;
using ll=long long;
const int N=1005;
int n[N*N],s[N*N],w[N*N],e[N*N];
int a[N][N];
void save_the_people() {
    int m;
    cin>>m;

    for(int i{1};i<=m*m;i++){
        cin>>n[i]>>s[i]>>w[i]>>e[i];
        if(n[i]==-1&&w[i]==-1)a[1][1]=i;
    }
    for (int i{2};i<=m;i++) a[1][i]=e[a[1][i-1]];
    for (int i{2};i<=m;i++)
        for (int j{1};j<=m;j++) a[i][j]=s[a[i-1][j]];
    for(int i{1};i<=m;i++){
        for(int j{1};j<=m;j++){
            cout<<a[i][j]<<" \n"[j==m];
        }
    }
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t{1};
    //cin>>t;
    while(t--) {
        save_the_people();
    }
}

C. Engineer Artem

Artem is building a new robot. He has a matrix a consisting of n rows and m columns. The cell located on the i-th row from the top and the j-th column from the left has a value ai,j written in it.

If two adjacent cells contain the same value, the robot will break. A matrix is called good if no two adjacent cells contain the same value, where two cells are called adjacent if they share a side.

Artem wants to increment the values in some cells by one to make a good.

More formally, find a good matrix b that satisfies the following condition —

For all valid (i,j), either bi,j=ai,j or bi,j=ai,j+1.
For the constraints of this problem, it can be shown that such a matrix b
always exists. If there are several such tables, you can output any of them. Please note that you do not have to minimize the number of increments.
奇偶构造即可;
构造题注意使用逆运算,位分解,直接构造等;
本题直接构造即可

#include"bits/stdc++.h"
using namespace std;
using ll=long long;

void save_the_people() {
    int n,m;
    cin>>n>>m;
    vector<vector<int>> a(n+1,vector<int> (m+1)),b(n+1,vector<int> (m+1));

    for(int i{1};i<=n;i++){
        for(int j{1};j<=m;j++){
            cin>>a[i][j];
            if((i+j)%2==0&&a[i][j]%2==0)a[i][j]++;
            if((i+j)%2==1&&a[i][j]%2==1)a[i][j]++;
        }
    }

    for(int i{1};i<=n;i++){
        for(int j{1};j<=m;j++){
            cout<<a[i][j]<<' ';
        }cout<<"\n";
    }
}
signed main() {

    int t{1};
    cin>>t;
    while(t--) {
        save_the_people();
    }
}

E. Another MEX Problem

题目链接:https://codeforces.com/contest/1870/problem/E

#include"bits/stdc++.h"
using namespace std;
using ll=long long;
const int maxn = 1e6 + 7;
const int N = 2e5 + 5;
#define mem(a,x) memset(a,x,sizeof(a));
void save_the_people(){
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    int dp[n+1][n+1];
    mem(dp,0);
    dp[0][0] = 1;
    int mex[n+1];
    mem(mex,-1);
    int cnt[n+1];

    for(int i=1;i<=n;i++) {
        mem(cnt,0);
        int cur = 0;
        for(int k=0;k<=n;k++) {
            dp[i][k] = dp[i-1][k];
        }
        for(int j=i;j!=0;j--) {
            cnt[a[j]]++;
            bool flag = 0;
            while(cnt[cur]) {
                cur++;
                flag = 1;
            }
            if(flag && cur != mex[j]) {
                for(int k=0;k<=n;k++) {
                    if(dp[j-1][k]) {
                        dp[i][k^cur] = 1;
                    }
                }
            }
            mex[j] = cur;
        }
    }

    for(int k=n;k>=0;k--) {
        if(dp[n][k]) {
            cout<<k;
            return;
        }
    }

}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int tcase{1};cin>>tcase;
    while(tcase--) {
        save_the_people(); 
        cout<<'\n';
    }
}

D. Prefix Purchase

题目链接:https://codeforces.com/contest/1870/problem/D
即找出能构造出的字典序最大的数组

从后往前取min,传递最小值,
从前往后取大构造

#include"bits/stdc++.h"
using namespace std;
using ll=long long;
const int N=1e9+5;
void newnew(){
    int n;
    cin >> n;

    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        std::cin >> c[i];
    }
    for (int i = n - 2; i >= 0; i--) {
        c[i] =min(c[i], c[i + 1]);
    }

    int k;
    cin >> k;

    vector<int> a(n);
    int t = k;
    for (int i = 0; i < n; i++) {
        int v = c[i] - (i ? c[i - 1] : 0);
        if (v > 0) {
            t =min(t, k / v);
        }
        k -= t * v;
        a[i] = t;
        cout << a[i] << " \n"[i == n - 1];
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _=1;cin>>_;
    while(_--){
        newnew();
    }
}

非常弹的球

刚上高一的森森为了学好物理,买了一个“非常弹”的球。虽然说是非常弹的球,其实也就是一般的弹力球而已。森森玩了一会儿弹力球后突然想到,假如他在地上用力弹球,球最远能弹到多远去呢?他不太会,你能帮他解决吗?当然为了刚学习物理的森森,我们对环境做一些简化:

假设森森是一个质点,以森森为原点设立坐标轴,则森森位于(0, 0)点。
小球质量为w/100 千克(kg),重力加速度为9.8米/秒平方(m/s^2 )。
森森在地上用力弹球的过程可简化为球从(0, 0)点以某个森森选择的角度ang (0<ang<π/2) 向第一象限抛出,抛出时假设动能为1000 焦耳(J)。
小球在空中仅受重力作用,球纵坐标为0时可视作落地,落地时损失p%动能并反弹。
地面可视为刚体,忽略小球形状、空气阻力及摩擦阻力等。

简单推一下公式 x=E/G

#include<bits/stdc++.h>
using namespace std;
using ll= long long;

int main()
{
    double w,p,v,s{0};
    cin>>w>>p;
    v=2*1000*100/w;
    while(v>0.000001){
        s+=v/9.8;
        v*=(100-p)*0.01;
    }
    printf("%.3f",s);
    
}

学习高级语法,c++中,struct≈calss,同样可以直接定义函数;

标签:std,21,people,int,28,long,2024,using,save
From: https://www.cnblogs.com/manjuan/p/17992749

相关文章

  • 1.28
    以下是开发医疗保险欺诈识别监测模型的一般性步骤:数据集分析与预处理:对给定的16000条数据集进行初步分析,了解数据的结构、特征。进行数据清洗,处理缺失值、异常值等。进行多维特征信息分析,以了解医疗保险欺诈的潜在特征。特征工程:提取能够描述医疗保险欺诈的特征因子......
  • 算法模板 v1.4.1.20240128
    算法模板v1.1.1.20240115:之前的历史版本已经不可寻,创建了第一份算法模板。v1.2.1.20240116:删除“编译”-“手动开栈”与“编译”-“手动开O优化”;将“编译”-“CF模板”中的第20行代码cin>>T;注释;删除“读写”及其目录下的内容;删除“图论”-“欧拉图”-“混合图”;删除“图论”-......
  • Codeforces Round 921 (Div. 2)
    CodeforcesRound921(Div.2)比赛地址A.WeGotEverythingCovered!思路这个就是一个简单的拼接,这里很容易的发现我们最后最优的方法就是将所要拼写的字母按顺序拼接成n份就好了,但是这里需要主义一下简单的优化Code#include<bits/stdc++.h>usingnamespacestd;#define......
  • CF Round 921 (Div. 2)
    linkA一种可行的方案是将前\(k\)个字母重复\(n\)次,对于每个要找的字符串,从\(n\)段中分别选取一个字符就可以得到。B如果\(x\)是答案的话,它一定满足\(x|n,\frac{x}{n}\leqm\),直接枚举答案,时间复杂度\(O(\sqrtn)\)。C沿着A的思路继续思考,如果能将\(s\)分成至......
  • 2024新版Windows 11要来了!16GB内存需求引热议 只是推荐配置
    最近,TrendForce集邦咨询的一份报告指出,微软已经将AIPC的内存基线设置为16GB。有媒体表示,这也意味着,新版Windows11的AI功能需要至少16GB内存才能运行。消息曝光后引发热议。对此,WC报道称,微软尚未就上述内存需求发表官方评论。16GB内存很可能只是微软的推荐配置,而非最低配置要求。W......
  • 2024年1月的论文推荐
    又到月底了,在月初推荐论文的基础上又整理了10篇推荐阅读的论文1、MosaicBERThttps://mosaicbert.github.io/一种用于快速预训练的双向编码器。MosaicBERT是针对快速预训练优化的自定义BERT架构。主要架构修改:FlashAttention,ALiBi,门控线性单元和低精度的LayerNorm。 http......
  • 2024 OI/VEX/啊啊啊? 赛季游记
    不定期更新,随便写。中马建交80周年CreateJR赛项什么远古比赛,2024/01的时间用2023赛季的规则(挺好)。Day-41/24在破败不堪的上海市安生学校集训。点的是外卖捏,鸡翅饭和美味的思密达辣白菜,辣白菜真的很好吃。我狂吃。比赛平均分87,最高分131,哇哇哇哇!六队真是个**,比赛......
  • 唐氏宝宝打PKUWC2024游记
    本人太菜了第一次打\(\text{PKUWC}\),学弟都打第二次了。\(\text{Day0}\)从长沙感到重庆,高铁上午\(8:00\)做到下午\(14:00\)被坐死,但是想想之后的比赛还要被罚坐更久就没说啥了,为啥不买飞机票?高铁的午饭时真**(赛博坦语言)贵,还难吃极了。看见hhx买了一杯奶茶跟我说全都是......
  • THUWC2024 游记
    省流:D1T3,Pretest97,D2和4.so决斗两小时(胜利)。day0从成都早上坐火车,中午到了重庆。坐轻轨到了酒店附近,虽然我不住酒店。lxs带着吃了一碗面。重庆的面挺好吃的。在酒店大厅坐着的时候有个东北老哥过来搭讪。但是我是社恐......
  • THUWC 2024 游记
    Day-1抵达重庆!吃火锅被辣死了/kkDay0试机!不会做题/tuuDay1起的很早!但是为什么我都到考场了天还是黑的。这个T1很签到啊!想了一会会了\(3^nm\),获得了77分的高分!又想了一会会了\(3^n+2^nm\),写了下过了,开T2。这个T2看着就很poly啊!先写了写\(m=1\),然后又写了矩乘......