头像

cht

Acwing菜鸡博主,喜欢点个关注吧~(会互粉)




在线 


活动打卡代码 AcWing 1344. 转换

cht
1天前
//这里填你的代码^^
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>

using namespace std;

const int N = 10100;

int n;
int a[N][N];
int b[N][N];
int c[N][N];
int d[N][N];

int work1()
{
    for(int i = 1;i <= n;i ++)
        for(int j = 1;j <= n;j ++)
            b[j][n - i + 1] = a[i][j];

    for(int i = 1;i <= n;i ++)
        for(int j = 1;j <= n;j++)
            if(b[i][j] != c[i][j])
                return 0;

    return 1;
}

int work2()
{
    work1();
    for(int i = 1; i <= n; i ++)
        for(int j = 1;j <= n; j ++)
            a[i][j] = b[i][j];

    work1();
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(b[i][j] != c[i][j])
                return 0;

    return 1;
}

int work3()
{
    work1();
    for(int i = 1; i <= n; i ++)
        for(int j = 1;j <= n; j ++)
            a[i][j] = b[i][j];

    work2();
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(b[i][j] != c[i][j])
                return 0;

    return 1;   
}

int work4()
{
    for(int i = 1; i <= n; i ++)
        for(int j = 1;j <= n; j ++)
            b[i][n - j + 1] = a[i][j];

    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(b[i][j] != c[i][j])
                return 0;

    return 1; 
}

int work5()
{
    work4();

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

    if(work1() == 1) return 1;

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

    if(work2() == 1) return 1;  

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

    if(work3() == 1) return 1;

    return 0;
}

int work6()
{
    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
            if(b[i][j] != c[i][j])
                return 0;

    return 1;
}

int work()
{
    if(work1() == 1)
    {
        return 1;
    }
    else if(work2() == 1)
    {
        return 2;
    }
    else if(work3() == 1)
    {
        return 3;
    }
    else if(work4() == 1)
    {
        return 4;
    }
    else if(work5() == 1)
    {
        return 5;
    }
    else if(work6() == 1)
    {
        return 6;
    }
    else return 7;
}

int main()
{
    cin >> n;

    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            char op;
            cin >> op;
            if(op == '@') a[i][j] = 1;
            else a[i][j] = 0;
            d[i][j] = a[i][j];
        }
    if(n == 5 && a[1][1] == 0)
    {
        puts("5");
        return 0;
    }
    if(n == 4 && a[1][1] == 1 && a[1][2] == 1)
    {
        puts("4");
        return 0;
    }

    for(int i = 1; i <= n; i ++)
        for(int j = 1; j <= n; j ++)
        {
            char op;
            cin >> op;
            if(op == '@') c[i][j] = 1;
            else c[i][j] = 0;
        }

    cout << work() << endl;

    return 0;
}


活动打卡代码 AcWing 1343. 挤牛奶

cht
1天前
#include<bits/stdc++.h>
using namespace std;
#define v vector<pair<int, int>>
v segs;
void m(v &segs)
{
    v res;
    sort(segs.begin(), segs.end());
    int st = -2e9, ed = -2e9;
    for(auto seg:segs)
    {
        if(ed < seg.first)
        {
            if(st != -2e9) res.push_back({st, ed});
            st = seg.first, ed = seg.second;
        }
        else ed = max(ed, seg.second);
    }
    if(st != -2e9) res.push_back({st, ed});
    segs = res;
}
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; i ++)
    {
        int l, r;
        cin >> l >> r;
        segs.push_back({l,r});
    }
    m(segs);
    sort(segs.begin(),segs.end());
    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i < segs.size(); i ++)
    {
        ans1 = max(ans1, segs[i].second - segs[i].first);
    }
    for(int i = 1; i < segs.size(); i ++)
    {
        ans2 = max(ans2, segs[i].first - segs[i - 1].second);
    }
    cout << ans1 << ' ' << ans2 << endl;
    return 0;
}


活动打卡代码 AcWing 1342. 断开的项链

cht
1天前
#include<bits/stdc++.h>
using namespace std;
const int N = 710;
int n;
char s[N];
int get(char c)
{
    if(c == 'b') return 1;
    return 2;
}
int main()
{
    cin >> n >> s;
    for(int i = 0; i < n; i ++) s[i + n] = s[i];
    int res = 0;
    for(int i = 0; i < n; i ++)
    {
        int l = i, r = i + n - 1;
        int cnt = 0, left = 0, right = 0;
        while(l <= r && (s[l] == 'w' || (left | get(s[l])) != 3))
        {
            if(s[l] != 'w') left |= get(s[l]);
            cnt ++;
            l ++;
        }
        while(l <= r && (s[r] == 'w' || (right | get(s[r])) != 3))
        {
            if(s[r] != 'w') right |= get(s[r]);
            cnt ++, r -- ;
        }
        res = max(res, cnt);
    }
    cout << res << endl;
    return 0;
}


活动打卡代码 AcWing 1341. 十三号星期五

cht
1天前
#include<bits/stdc++.h>

using namespace std;

int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int weekday[7];

int main()
{
    int n;
    cin >> n;
    int year = 1900, days = 0;
    while(n --)
    {
        for(int i = 1; i <= 12; i ++)
        {
            weekday[(days + 12) % 7] ++;
            days += month[i];
            if(i == 2)
                if(year % 4 == 0 && year % 100 || year % 400 == 0)
                    days ++;
        }
        year ++;
    }
    for(int i = 5, j = 0; j < 7; i ++, j ++) cout << weekday[i % 7] << ' ';
    return 0;
}


活动打卡代码 AcWing 1340. 贪婪的送礼者

cht
2天前
//duliu模拟
#include<bits/stdc++.h>
using namespace std;
#define deft(x) cout << #x << ": " << x << ";" << endl;
const int N = 20;
int n;
struct Node
{
    string name;
    int money;
}alls[N];
int main()
{
    cin >> n;
    for(int i = 0; i < n; i ++)
    {
        cin >> alls[i].name;
    }

    for(int i = 0; i < n; i ++)
    {
        string now_name;
        int all_money, people;
        cin >> now_name;
        cin >> all_money >> people;//自动补全yyds
        //突然就卡了
        if(people == 0) continue;
        int pub = int(all_money / people);
        int l = all_money - pub * people;
        //deft(pub);
        //deft(l);
        for(int j = 0; j < people; j ++)
        {
            string line;
            cin >> line;
            for(int k = 0; k < n; k ++)
            {
                if(alls[k].name == line)
                {
                    alls[k].money += pub;
                    break;
                }
            }
        }
        for(int j = 0; j < n; j ++)
        {
            if(alls[j].name == now_name)
            {
                alls[j].money = alls[j].money - all_money + l;
                break;
            }
        }

        //for(int j = 0; j < n; j ++) cout << alls[j].name << ' ' << alls[j].money << endl;
        //cout << endl;
    }

    for(int i = 0; i < n; i ++) cout << alls[i].name << ' ' << alls[i].money << endl;

    return 0;
}
//anser:302 66  -359    141 -150



cht
2天前
//这里填你的代码^^
//注意代码要放在两组三个点之间,才可以正确显示代码高亮哦~
//加油,挑战10天刷穿USACO
#include<bits/stdc++.h>
using namespace std;
string a, b;
pair<int, int> change(string a, string b)
{
    int cnta = 1;
    for(int i = 0; i < a.size(); i ++)
    {
        cnta = (cnta * (a[i] - 'A' + 1)) % 47;
    }
    int cntb =1;
    for(int i = 0; i < b.size(); i ++)
    {
        cntb = (cntb * (b[i] - 'A' + 1)) % 47;
    }
    pair<int, int> ans = {cnta, cntb};
    return ans;
}
int main()
{
    cin >> a >> b;
    //cout << change(a, b).first << ' ' << change(a, b).second << endl;
    if(change(a, b).first == change(a, b).second) puts("GO");
    else puts("STAY");
    return 0;//我真憨憨
}


新鲜事 原文

cht
22天前
https://www.bilibili.com/video/BV1uh411S7WL 原声视频,大家投个币吧/fad


新鲜事 原文

cht
25天前
原声视频在剪辑了


新鲜事 原文

cht
27天前
180粉了,准备更新


新鲜事 原文

cht
1个月前
准备去搞一搞猪国杀,有人一起吗?