SDUT 2021 Winter Team Contest - 7(Gym 102861)

48 篇文章 0 订阅
34 篇文章 0 订阅

A - Sticker Album

题目链接

答案:

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int MOD = 20210213;
const int N = 1e6 + 10;
const int M = 65;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
int dxy[][2]={{0,1},{1,0},{1,1},{-1,1}};
using namespace std;

double dp[3*N];

void solve(){
    ll n,l,r;
    cin>>n>>l>>r;
    double res=0;
    ll len=r-l+1;
    bep(i,n-1,0){
        if(l>0) dp[i]=res/(double)len+1;
        else dp[i]=res/(double)(len-1)+len/(double)(len-1);
        res-=dp[i+r];
        if(l>0) res+=dp[i+l-1];
        else res+=dp[i];
    }
    printf("%.5f\n",dp[0]);
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
	return 0;
}

B - Battleship

题目链接

答案:

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int MOD = 20210213;
const int N = 2e5 + 10;
const int M = 55;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
int dxy[][2]={{0,1},{0,-1},{1,0},{-1,0}};
using namespace std;

int vis[M][M];

void solve(){
    int t;
    cin>>t;
    while(t--){
        int d,l,r,c;
        cin>>d>>l>>r>>c;
        if(!d){
            int k=c+l-1;
            if(k<1||k>10){
                puts("N");
                return ;
            }
            rep(j,c,k) vis[r][j]++;
        }
        else if(d==1){
            int k=r+l-1;
            if(k<1||k>10){
                puts("N");
                return ;
            }
            rep(j,r,k) vis[j][c]++;
        }
    }
    rep(i,1,10){
        rep(j,1,10){
            if(vis[i][j]>1){
                puts("N");
                return ;
            }
        }
    }
    puts("Y");
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
	return 0;
}


F - Fastminton

题目链接

答案:

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int MOD = 20210213;
const int N = 2e5 + 10;
const int M = 55;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
int dxy[][2]={{0,1},{0,-1},{1,0},{-1,0}};
using namespace std;

string s;
int resa,resb,l,r;

void solve(){
    cin>>s;
    int len=s.size();
    bool flag=0;
    rep(i,0,len-1){
        if(s[i]=='S'){
            if(!flag) resb++;
            else resa++;
        }
        if(s[i]=='R'){
            flag=!flag;
            if(!flag) resb++;
            else resa++;
        }
        if(resa-resb>=2&&resa>=5) resa=resb=0,l++;
        if(resb-resa>=2&&resb>=5) resa=resb=0,r++;
        if(resa>=10) resa=resb=0,l++;
        if(resb>=10) resa=resb=0,r++;
        if(s[i]=='Q'){
            if(i!=len-1){
                if(!flag) printf("%d (%d*) - %d (%d)\n",r,resb,l,resa);
                else printf("%d (%d) - %d (%d*)\n",r,resb,l,resa);
            }
            else{
                if(l>r) printf("%d - %d (winner)\n",r,l);
                else printf("%d (winner) - %d\n",r,l);
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
	return 0;
}


G - Game Show!

题目链接

答案:

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int MOD = 20210213;
const int N = 2e5 + 10;
const int M = 55;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
int dxy[][2]={{0,1},{0,-1},{1,0},{-1,0}};
using namespace std;

int dp[N];
int mp[N];

void solve(){
    int n;
    cin>>n;
    rep(i,1,n){
        cin>>dp[i];
        mp[i]=mp[i-1]+dp[i];
    }
    int maxn=0;
    rep(i,1,n) maxn=max(maxn,mp[i]);
    if(maxn>=0){
        maxn+=100;
        cout<<maxn<<endl;
    }
    else cout<<100<<endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
	return 0;
}


L - Lavaspar

题目链接

答案:

#include <iostream>
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define INF 0x3f3f3f3f
#define inf 0x3f3f3f3f3f3f3f3f
#define rep(i,a,b) for(auto i=a;i<=b;++i)
#define bep(i,a,b) for(auto i=a;i>=b;--i)
#define lowbit(x) x&(-x)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(-1)
#define pb push_back
#define eps 1e-6
const int mod = 1e9 + 7;
const int MOD = 20210213;
const int N = 2e5 + 10;
const int M = 65;
int dx[]={-1, 0, 1, 0};
int dy[]={0, 1, 0, -1};
int dxy[][2]={{0,1},{1,0},{1,1},{-1,1}};
using namespace std;

int n,m,q;
char s[M][M];
char str[M];
map<char,int>mp[M];
map<int,int>st[M][M];

void DFS(int x,int y,int xx,int yy){
    int px=x;
    int py=y;
    map<char,int>dp;
    int tot=0;
    while(px>=1&&py>=1&&px<=n&&py<=m){
        dp[s[px][py]]++;
        tot++;
        if(tot>15) break;
        rep(i,1,q){
            if(dp!=mp[i]) continue;
            int qx=x;
            int qy=y;
            while(1){
                st[qx][qy][i]=1;
                if(qx==px&&qy==py) break;
                qx+=xx;
                qy+=yy;
            }
        }
        px+=xx;
        py+=yy;
    }
}

void solve(){
    cin>>n>>m;
    rep(i,1,n){
        rep(j,1,m){
            cin>>s[i][j];
        }
    }
    cin>>q;
    rep(i,1,q){
        cin>>(str+1);
        int len=strlen(str+1);
        rep(j,1,len) mp[i][str[j]]++;
    }
    rep(i,1,n){
        rep(j,1,m){
            rep(k,0,3){
                DFS(i,j,dxy[k][0],dxy[k][1]);
            }
        }
    }
    int tot=0;
    rep(i,1,n){
        rep(j,1,m){
            if((int)st[i][j].size()>=2) tot++;
        }
    }
    cout<<tot<<endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值