头像

阿飘




离线:4小时前


最近来访(17)
用户头像
._30
用户头像
Balance_1
用户头像
haki-lwd
用户头像
LlP_1
用户头像
yyds666
用户头像
面向薪资
用户头像
JiaHangLi
用户头像
haniwn
用户头像
xueseng
用户头像
木瓜星灵
用户头像
jinss
用户头像
只想白嫖
用户头像
yxc

活动打卡代码 AcWing 1442. 单词处理器

阿飘
3个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
string s[105], c; 
int a[105];
int main()
{
    int n, k;
    cin >> n >> k;
    int len = k;
    for(int i = 1; i <= n; i ++ )cin >> s[i];
    for(int i = 1; i <= n; i ++ )
    {
        if(s[i].size() > len)
        {
            len = k;
            puts("");
        }
        if( s[i].size() + s[i+1] .size() <= len)
        {
            cout << s[i] << ' ';
            len -= s[i].size();
        }
        else if(s[i].size() <= len)
        {
            cout << s[i];
            len -= s[i].size();
        }
    }
}


活动打卡代码 AcWing 1442. 单词处理器

阿飘
3个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
string s[105], c; 
int a[105];
int main()
{
    int n, k;
    cin >> n >> k;
    int len = k;
    for(int i = 1; i <= n; i ++ )cin >> s[i];
    for(int i = 1; i <= n; i ++ )
    {
        if(s[i].size() > len)
        {
            len = k;
            puts("");
        }
        if( s[i].size() + s[i+1] .size() <= len)
        {
            cout << s[i] << ' ';
            len -= s[i].size();
        }
        else if(s[i].size() <= len)
        {
            cout << s[i];
            len -= s[i].size();
        }
    }
}


活动打卡代码 AcWing 1459. 奶牛体操

阿飘
3个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
int n , m;
int a[100][100];
int b[100][100];
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i ++ )
        for(int j = 1; j <= m; j ++ )
        cin >> a[i][j];

    for(int i = 1; i <= n; i ++ )
    {
        for(int j = 1; j < m; j ++ )
        {
            for(int k = j+1; k <= m; k ++ )
            {
                b[a[i][j]][a[i][k]] += 1;
            }
        }
    }


    int res = 0;
    for(int i = 1; i <= m; i ++ )
        for(int j = 1; j <= m; j ++ )
        if(b[i][j] == n) res ++;

        cout << res << endl;
}



活动打卡代码 AcWing 3745. 牛的学术圈 I

阿飘
3个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
const int N = 100010;
int n, k;
int a[N];
bool cmp(int x, int y)
{
    return x > y;
}
int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; i ++ )
    {
        cin >> a[i];
    }

    sort(a+1, a+n+1 , cmp);
    int h = 0;
    for(int i = 1; i <= n; i ++ )
    {
        if(a[i] >= i) h = i;
        else break;
    }
    int res = 0;
    if(a[h+1] < h) 
    {
        cout << h << endl;
        return 0;
    }

    for(int i = 1; i <= h+1; i ++ )
    {
        if(a[i] == h) res ++;
    }
    if(res <= k) cout << h+1 << endl;
    else 
    cout << h << endl;
}


活动打卡代码 AcWing 3370. 牛年

阿飘
3个月前
#include<bits/stdc++.h>

using namespace std;
map<string , int> q , lb;
map<string , string> nian;
int main()
{
    q["Ox"] = 1;
    q["Tiger"] = 2;
    q["Rabbit"] = 3;
    q["Dragon"] = 4;
    q["Snake"] = 5;
    q["Horse"] = 6;
    q["Goat"] = 7;
    q["Monkey"] = 8;
    q["Rooster"] = 9;
    q["Dog"] = 10;
    q["Pig"] = 11;
    q["Rat"] = 12;

    int n;
    cin >> n;
    lb["Bessie"] = 10000;
    nian["Bessie"] = "Ox";
    string a[10];
    while(n--)
    {
        cin >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8];
        nian[a[1]] = a[5];
        if(a[4] == "previous")
        {
            if(nian[a[8]] == a[5]) lb[a[1]] = lb[a[8]] - 12;
            else lb[a[1]] = lb[a[8]] - (q[nian[a[8]]]-q[a[5]]+12)%12;
        }
        else
        {
            if(nian[a[8]] == a[5]) lb[a[1]] = lb[a[8]] + 12;
            else lb[a[1]] = lb[a[8]] + (q[a[5]]-q[nian[a[8]]]+12)%12;
        }
    }
    cout << abs(lb["Bessie"] - lb["Elsie"]) << endl;

    return 0;
}



阿飘
3个月前
#include<bits/stdc++.h>

using namespace std;
string s, c;
map<char,int> a;

int main()
{
    cin >> s >> c;
    int res = 1;

    for(int i = 0; i < s.size(); i ++ )
    {
        a[s[i]] = i;
    }
    for(int i = 1; i < c.size(); i ++ )
    {
        if(a[c[i]] <= a[c[i-1]]) res ++;
    }
    cout << res << endl;
    return 0;
}



阿飘
3个月前
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
int a[10];

int main()
{
    for(int i = 1; i <= 7; i ++ ) cin >> a[i];
    sort(a+1 , a+8);

    cout << a[1] << ' ' << a[2] << ' ' << a[7]-a[1]-a[2] << endl;
}


活动打卡代码 AcWing 4308. 组合字符串

阿飘
3个月前
#include<bits/stdc++.h>

using namespace std;
string a, b;
string r(20,'z');
int main()
{
    cin >> a >> b;
    for(int i = 1; i <= a.size(); i ++ )
    for(int j = 1; j <= b.size(); j ++ )
    {
        r = min(r, a.substr(0,i)+b.substr(0,j));
    }
    cout << r << endl;
    return 0;
}


活动打卡代码 AcWing 902. 最短编辑距离

阿飘
4个月前
//这里填你的代码
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 1010;
char a[N], b[N];
int f[N][N];
int main()
{
    int n, m;
    scanf("%d%s" , &n,a+1);
    scanf("%d%s" , &m,b+1);
    for(int i = 0; i <= n; i ++ ) f[i][0] = i;
    for(int i = 0; i <= m; i ++ ) f[0][i] = i;

    for(int i = 1; i <= n; i ++ )
    for(int j = 1; j <= m; j ++ )
    {
        f[i][j] = min(f[i-1][j]+1,f[i][j-1]+1);
        if(a[i] == b[j]) f[i][j] = min(f[i][j] , f[i-1][j-1]);
        else f[i][j] = min(f[i][j] , f[i-1][j-1]+1);
    }
    cout << f[n][m] << endl;
    return 0;
}
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~



阿飘
4个月前
//这里填你的代码^^
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 100010;

int n;
int a[N];
int q[N];

int main()
{
    cin >> n;
    for(int i = 0; i < n; i ++ ) cin >> a[i];

    q[0] = -2e9;
    int len = 0;
    for(int i = 0; i < n; i ++ )
    {
        int l = 0, r = len;
        while(l < r)
        {
            int mid = l + r + 1 >> 1;
            if(q[mid] < a[i]) l = mid;
            else r = mid - 1;
        }
        len = max(len , r+1);
        q[r+1] = a[i];
    }

    cout << len << endl;
    return 0;
}
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~