Featured image of post 20210724测试

20210724测试

封面来源

Pixiv 95640265

20210724测试

T1

image-20210724112821699

Solution

直接模拟

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
 * @Date: 2021-07-24 08:05:23
 * @LastEditors: Steve Li
 * @LastEditTime: 2021-07-24 11:03:14
 * @FilePath: \李博睿\a.cpp
 */
#include<bits/stdc++.h>
using namespace std;
int k[5];
string x,s;
string t[5];
queue<int> id[5];
namespace sol1{
    inline void Solve(){
        freopen("a.in","r",stdin);
        freopen("a.out","w",stdout);
        ios::sync_with_stdio(false);
        cin.tie(0),cout.tie(0);
        cin>>k[1]>>k[2]>>k[3];
        cin>>x;
        int len=x.length();
        for(int i=0;i<len;i++){
            if(x[i]>='a'&&x[i]<='i'){
                t[1].push_back(x[i]);
                id[1].push(i);
            }
            else if(x[i]>='j'&&x[i]<='r'){
                t[2].push_back(x[i]);
                id[2].push(i);
            }
            else if((x[i]>='s'&&x[i]<='z')||x[i]=='_'){
                t[3].push_back(x[i]);
                id[3].push(i);
            }
        }
        for(int i=1;i<=len;i++){
            s.append(" ");
        }
        for(int j=1;j<=3;j++){
            for(int i=1;i<=k[j];i++){
                t[j]=" "+t[j];
            }
            for(int i=1,len=t[j].length()-k[j]-1;i<=k[j];i++){
                t[j][i-1]=t[j][len+i];
            }
            for(int i=1;i<=k[j];i++){
                t[j].pop_back();
            }
            for(int i=0;i<t[j].length();i++){
                s[id[j].front()]=t[j][i];
                id[j].pop();
            }
        }
        printf("%s",s.c_str());
    }
}
int main(){
    sol1::Solve();
}

T2

image-20210724113133335

Solution

没打完,拿个部分分就跑

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * @Date: 2021-07-24 08:05:23
 * @LastEditors: Steve Li
 * @LastEditTime: 2021-07-24 11:01:44
 * @FilePath: \李博睿\b.cpp
 */
#include<bits/stdc++.h>
using namespace std;
int n,ans = 0x3fffffff;
int a[10010],sum[10010];
inline int hg(int i,int j){
    // int mx = max(i,j),mi = min(i,j);
    return (i-j)*(i-j)+(sum[i]-sum[j])*(sum[i]-sum[j]);
}
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
namespace sol1{
    inline void Solve(){
        freopen("b.in","r",stdin);
        freopen("b.out","w",stdout);
        cin>>n;
        for(int i=1;i<=n;i++){
            a[i]=read();
            sum[i]=sum[i-1]+a[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=1;j<i;j++){
                ans = min(ans,hg(i,j));
            }
        }
        printf("%d\n",ans);
    }
}
int main(){
    sol1::Solve();
}

T3

image-20210724113258754

Solution

我感觉暴力应该能过吧

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * @Date: 2021-07-24 08:05:23
 * @LastEditors: Steve Li
 * @LastEditTime: 2021-07-24 11:24:32
 * @FilePath: \李博睿\c.cpp
 */
#include<bits/stdc++.h>
using namespace std;
const int N = 2e6+20;
int fa[N],a[N],f1[N],f2[N];
int n,q;
#define il inline
vector<int> sons[N];//u的子节点
il int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
il int f11(int u){
    if(u==1||f1[fa[u]]+1<a[u]){
        return a[u];
    }
    return f1[fa[u]]+1;
}
il int f22(int u){
    if(u==1||f1[fa[u]]+1<a[u]){
        return 1;
    }
    if(f1[fa[u]]+1==a[u]){
        return f2[fa[u]]+1;
    }
    return f2[fa[u]];
}
il void update(int u){
    f1[u]=f11(u),f2[u]=f22(u);
    for(int i=0;i<sons[u].size();i++){
        update(sons[u][i]);
    }
    return;
}
int main(){
    freopen("c.in","r",stdin);
    freopen("c.out","w",stdout);
    n = read();
    for(int i=1;i<=n;i++){
        a[i]=read();
    }
    for(int i=1;i<=n-1;i++){
        int u=read(),v=read();
        fa[v]=u;
        sons[u].push_back(v);
    }
    update(1);
    q=read();
    while(q--){
        int op = read();
        if(op==0){
            int u = read();
            a[u]=read();
            update(u);
        }
        if(op==1){
            int u = read();
            printf("%d %d",f1[u],f2[u]);
        }
    }
}

T4

image-20210724113517730

Solution

拿50分没问题了

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * @Date: 2021-07-24 08:05:23
 * @LastEditors: Steve Li
 * @LastEditTime: 2021-07-24 10:59:49
 * @FilePath: \李博睿\d.cpp
 */
#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
const int mod = 1000000007,N = 50010;
int n;
int a[N];
int f[N];//方案数
int dp[N];
int ans;
namespace sol1{
    inline void Solve(){
        freopen("d.in","r",stdin);
        freopen("d.out","w",stdout);
        n = read();
        int mx = 0;
        for(int i=1;i<=n;i++){
            a[i]=read();
            f[i]=1;
            dp[i]=0;
        }
        for(int i=1;i<=n;i++){
            dp[i]=1;
            for(int j=1;j<i;j++){
                if(a[j]<a[i]){
                    if(dp[i]<dp[j]+1){
                        dp[i]=dp[j]+1;
                        f[i]=f[j];
                    }
                    else if(dp[i]==dp[j]+1){
                        f[i]=(f[i]+f[j])%mod;
                    }
                }
            }
            mx = max(mx,dp[i]);
        }
        for(int i=1;i<=n;i++){
            if(dp[i]==mx){//在这个点可以取得LIS
                ans=(ans+f[i])%mod;
            }
        }
        printf("%d\n",ans%mod);
    }
}
signed main(){
    sol1::Solve();
}
所念皆星河
Built with Hugo
主题 StackJimmy 设计