头像

发廊探险家




离线:13小时前


最近来访(38)
用户头像
NZX
用户头像
工Jun
用户头像
DRC
用户头像
aki_96
用户头像
Birdy
用户头像
evecome
用户头像
我是菜狗啊啊啊啊啊
用户头像
yxc的小迷妹
用户头像
LwaiX
用户头像
Tnxts
用户头像
W_shelt
用户头像
an_87
用户头像
Yumer
用户头像
stOtue

分享 板子

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define four(i, a, b) for (ll i = a; i <= b; i++)
#define fourr(i, a, b) for (ll i = a; i >= b; i--)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define ll long long
#define un unsigned
#define inf 0x7fffffff
#define mem(a, b) memset(a, b, sizeof(a))
#define lowbit(x) (x & (-x))
#define pii pair<int, int>
#define LL ll
#define YES puts("yes")
#define NO puts("no")

template <class T> inline void read(T &s)
{
    T w = 1;
    s = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = s * 10 + ch - '0', ch = getchar();
    s *= w;
}

const ll maxn = 35;
const ll maxm = 3e5 + 5;
const ll mod = 100003;
const int base = 4;

void solve()
{

}

int main()
{
    // int t;
    // cin>>t;
    // for(int i=1;i<=t;i++)
    solve();

}



#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include <algorithm>
#include <set>

using namespace std;
#define four(i, a, b) for(int i=a;i<=b;i++)
#define fourr(i, a, b) for(int i=a;i>=b;i--)
#define Max(a, b) (a>b?a:b)
#define Min(a, b) (a<b?a:b)
#define ll long long
#define inf 0x3f3f3f3f
#define endl '\n'
#define mem(a, b) memset(a,b,sizeof(a))
#define lowbit(x) (x&(-x))
#define pii pair<int,int>
const ll maxn = 50 + 5;
const ll maxm = 1e3 + 5;
#define x first
#define y second
int n, l, s;
int px[maxm], py[maxm];
bool mp[maxn][maxn];

bool judge(pii it, pii st) {
    return   it.x - st.x >= 0 && it.y - st.y >= 0 && it.x - st.x <= s && it.y - st.y <= s;
}

void solve() {
    cin >> n >> l >> s;
    four(i, 1, n) {
        cin >> px[i] >> py[i];
    }
    int k = 0;
    fourr(i, s, 0) {
        four(j, 0, s) {
            cin >> mp[i][j];
            k += mp[i][j];
        }
    }

    int ans = 0;
    four(i, 1, n) {
        pii st = {px[i], py[i]};

        int cnt =0;
        if(st.x+s>l||st.y+s>l)
        continue;
        four(j, 1, n) {
            pii it = {px[j], py[j]};
            if (judge(it, st)) {
                if (mp[it.x-st.x][it.y-st.y])cnt++;
                else {cnt=-100;break;}
            }
        }

        ans+=(cnt==k);
    }
    cout << ans << endl;
}

int main() {
//    iostream::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);
    solve();
}


活动打卡代码 AcWing 4455. 出行计划

数据范围很贴心的>0 :)

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define four(i, a, b) for (ll i = a; i <= b; i++)
#define fourr(i, a, b) for (ll i = a; i >= b; i--)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define ll long long
#define un unsigned
#define inf 0x7fffffff
#define mem(a, b) memset(a, b, sizeof(a))
#define lowbit(x) (x & (-x))
#define pii pair<int, int>
#define LL ll
#define YES puts("yes")
#define NO puts("no")

template <class T> inline void read(T &s)
{
    T w = 1;
    s = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = s * 10 + ch - '0', ch = getchar();
    s *= w;
}

const ll maxn = 3e5 + 5;
const ll maxm = 15;
const ll mod = 100003;
const int base = 4;

int n, m, k;
int tr[maxn];
void add(int x, int v)
{
    if(x<=0){
        x=1;
    }
    for (; x <= 3e5+1; x += lowbit(x))
    {
        tr[x] += v;
    }
}

int ask(int x)
{
    int ans = 0;
    for (; x >=1; x -= lowbit(x))
    {
        ans += tr[x];
    }
    return ans;
}
void solve()
{
    cin >> n >> m >> k;
    four(i, 1, n)
    {
        int a, t;
        cin >> a >> t;
        int st=a-t+1-k;
        int ed=a-k;
        add(st,1);
        add(ed+1,-1);
    }
    four(i, 1, m)
    {
        int x;
        cin>>x;
        cout<<ask(x)<<endl;
    }
}

int main()
{
    // int t;
    // cin>>t;
    // for(int i=1;i<=t;i++)
    solve();
}


活动打卡代码 AcWing 4700. 何以包邮?

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define four(i, a, b) for (ll i = a; i <= b; i++)
#define fourr(i, a, b) for (ll i = a; i >= b; i--)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define ll long long
#define un unsigned
#define inf 0x7fffffff
#define mem(a, b) memset(a, b, sizeof(a))
#define lowbit(x) (x & (-x))
#define pii pair<int, int>
#define LL ll
#define YES puts("yes")
#define NO puts("no")

template <class T> inline void read(T &s)
{
    T w = 1;
    s = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = s * 10 + ch - '0', ch = getchar();
    s *= w;
}

const ll maxn = 35;
const ll maxm = 3e5 + 5;
const ll mod = 100003;
const int base = 4;
int a[maxn];
bool dp[maxm];
int n, m;
void solve()
{
    cin >> n >> m;
    int sum = 0;
    dp[0] = 1;
    four(i, 1, n)
    {
        cin >> a[i];
        sum += a[i];
    }
    int ans = sum;
    four(i, 1, n)
    {
        fourr(j, sum, a[i])
        {
            dp[j] |= dp[j - a[i]];
            if (dp[j] && j >= m)
                ans = Min(ans, j);
        }
    }
    cout<<ans<<endl;
}

int main()
{
    // int t;
    // cin>>t;
    // for(int i=1;i<=t;i++)
    solve();
}


活动打卡代码 AcWing 4699. 如此编码

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define four(i, a, b) for (ll i = a; i <= b; i++)
#define fourr(i, a, b) for (ll i = a; i >= b; i--)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define ll long long
#define un unsigned
#define inf 0x7fffffff
#define mem(a, b) memset(a, b, sizeof(a))
#define lowbit(x) (x & (-x))
#define pii pair<int, int>
#define LL ll
#define YES puts("yes")
#define NO puts("no")

template <class T> inline void read(T &s)
{
    T w = 1;
    s = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = s * 10 + ch - '0', ch = getchar();
    s *= w;
}

const ll maxn = 25;
const ll maxm = 15;
const ll mod = 100003;
const int base = 4;
ll n;
ll a[maxn];
ll m;
ll b[maxn];
void solve()
{
    cin >> n >> m;

    ll c = 1;

    four(i, 1, n)
    {

        cin >> a[i];
        c *= a[i];

    }

    fourr(i, n, 1)
    {

        c /= a[i];
        b[i] = m / c;

        m %= c;
    }
    four(i, 1, n)
    {
        cout << b[i] << " ";
    }
}

int main()
{
    // int t;
    // cin>>t;
    // for(int i=1;i<=t;i++)
    solve();
}


活动打卡代码 AcWing 4509. 归一化处理

#include<bits/stdc++.h>
using namespace std;
#define db double
const int maxn=1e3+5;
#define four(i,a,b) for(int i=a;i<=b;i++)
db x[maxn];
db avg_x;
db sqare_x;

int main(){
    int n;
    cin>>n;
    avg_x=0;
    four(i,1,n){
        cin>>x[i];
        avg_x+=x[i];
    }
    avg_x/=n;
    four(i,1,n){
        sqare_x+=pow(x[i]-avg_x,2);
    }
    sqare_x/=n;
    four(i,1,n){
        printf("%.5lf\n",(x[i]-avg_x)/sqrt(sqare_x));
    }
}


活动打卡代码 AcWing 4454. 未初始化警告

#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
bool vis[maxn];
int main(){
    vis[0]=1;
    int n,k;
    cin>>n>>k;
    int ans=0;
    for(int i=1;i<=k;i++){
        int a,b;
        cin>>a>>b;
        if(!vis[b])
        ans++;
        vis[a]=1;
    }
    cout<<ans<<endl;
}


活动打卡代码 AcWing 4652. 纸张尺寸

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

int main(){
    int a[]={1189,841};
    string s;
    cin>>s;
    int d=s[1]-'0';
    while(d--){
        int *p=(a[1]>a[0]?&a[1]:&a[0]);
        *p/=2;
    }

    cout<<max(a[1],a[0])<<endl<<min(a[1],a[0]);
}


活动打卡代码 AcWing 4655. 重新排序

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define four(i, a, b) for (ll i = a; i <= b; i++)
#define fourr(i, a, b) for (ll i = a; i >= b; i--)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define ll long long
#define un unsigned
#define inf 0x7fffffff
#define mem(a, b) memset(a, b, sizeof(a))
#define lowbit(x) (x & (-x))
#define pii pair<int, int>
#define LL ll
#define YES puts("yes")
#define NO puts("no")

template <class T> inline void read(T &s)
{
    T w = 1;
    s = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = s * 10 + ch - '0', ch = getchar();
    s *= w;
}
//区间修改 单点查询 树状数组
const ll maxn = 1e5 + 5;
const ll maxm = 15;
const ll mod = 100003;
const int base = 4;
int n;
ll a[maxn];
int tr[maxn];
void add(int x, int val)
{
    if(x==0)return ;
    for (int i=x;i <= n; i += lowbit(i))
    {
        tr[i] += val;
    }
}
int ask(int x)
{
    int sum = 0;
    for (int i = x; i > 0; i -= lowbit(i))
    {
        sum += tr[i];
    }
    return sum;
}
int m;
int times[maxn];
void solve()
{

    cin >> n;
    four(i, 1, n)
    {
        read(a[i]);
    }
    cin >> m;
    ll sum = 0;
    four(i, 1, m)
    {
        int l, r;
        read(l);
        read(r);
        add(l, 1);
        add(r+1, -1);
    }

    four(i, 1, n)
    {
        times[i] = ask(i);
        sum += times[i] * a[i];
    }
    sort(times + 1, times + 1 + n, greater<int>());

    sort(a + 1, a + 1 + n, greater<int>());

    four(i, 1, n)
    {
        sum -= times[i] * a[i];
    }
    cout << -1 * sum << endl;
}

int main()
{
    // int t;
    // cin>>t;
    // for(int i=1;i<=t;i++)
    solve();
}


活动打卡代码 AcWing 1107. 魔板

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
#define four(i, a, b) for (ll i = a; i <= b; i++)
#define fourr(i, a, b) for (ll i = a; i >= b; i--)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define ll long long
#define un unsigned
#define inf 0x7fffffff
#define mem(a, b) memset(a, b, sizeof(a))
#define lowbit(x) (x & (-x))
#define pii pair<int, int>
#define LL ll
#define YES puts("yes")
#define NO puts("no")
#define Str string
template <class T> inline void read(T &s)
{
    T w = 1;
    s = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9')
    {
        if (ch == '-')
            w = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9')
        s = s * 10 + ch - '0', ch = getchar();
    s *= w;
}

const ll maxn = 11;
const ll maxm = 15;
const ll mod = 100003;
const int base = 4;
int n;
string des;
string A(Str x) // 1
{

    reverse(x.begin(), x.end());
    return x;
}
string B(Str x) // 3
{
    Str k ;k= {x[3], x[0], x[1], x[2], x[5], x[6], x[7], x[4]};
    return k;
}
Str C(Str x) // 3
{
    Str k ;k= {x[0], x[6], x[1], x[3], x[4], x[2], x[5], x[7]};
    return k;
}
bool check(Str x)
{
    if (x == des)
        return 1;
    else
        return 0;
}
struct node
{
    string s;
    char op;
};
map<string, node> pre; //前驱结点
void show(Str x)
{
    Str now = x;
    stack<char> st;
    while (now != "12345678")
    {
        st.push(pre[now].op);
        now = pre[now].s;
    }
    cout<<st.size()<<endl;
    while (!st.empty())
    {
        cout << st.top();
        st.pop();
    }
}

void bfs()
{
    queue<string> q;
    q.push("12345678");
    while (!q.empty())
    {
        string x = q.front();
        q.pop();
        if (check(x))
        {
            show(x);
            return;
        }
        string y;
        y = A(x);
        if (!pre[y].op)
        {
            q.push(y);
            pre[y].s = x;
            pre[y].op = 'A';
        }
        y = B(x);
        if (!pre[y].op)
        {
            q.push(y);
            pre[y].s = x;
            pre[y].op = 'B';
        }
        y = C(x);
        if (!pre[y].op)
        {
            q.push(y);
            pre[y].s = x;
            pre[y].op = 'C';
        }
    }
}

void solve()
{

    four(i, 1, 8)
    {
        char x;
        cin >> x;
        des.push_back(x);
    }
    bfs();
}

int main()
{
    // int t;
    // cin>>t;
    // for(int i=1;i<=t;i++)
    solve();
}