Live2d Test Env

2017年西南民族大学程序设计竞赛-网络同步赛(代码)

 

20598954    nmphy    D    答案正确    8    512    486    C++    2017-12-30 14:30:35
20598712    nmphy    E    答案正确    3    504    695    C++    2017-12-30 14:25:59
20598181    nmphy    E    答案正确    3    484    659    C++    2017-12-30 14:15:16
20597638    nmphy    E    答案正确    3    504    505    C++    2017-12-30 14:05:08//比赛时候这里显示的是WA,而且显示准确率5%
20597208    nmphy    F    答案正确    3    272    569    C++    2017-12-30 13:57:09
20596793    nmphy    H    答案正确    3    384    312    C++    2017-12-30 13:49:00
20596485    nmphy    J    答案正确    15    512    493    C++    2017-12-30 13:43:23
20596125    nmphy    G    答案正确    4    396    768    C++    2017-12-30 13:36:12
20596077    nmphy    G    答案正确    3    384    768    C++    2017-12-30 13:35:22
20595884    nmphy    G    答案错误    4    384    840    C++    2017-12-30 13:31:43
20595709    nmphy    G    答案错误    4    384    825    C++    2017-12-30 13:28:29
20595099    nmphy    I    答案正确    4    384    386    C++    2017-12-30 13:16:36
20594924    nmphy    K    答案正确    4    436    555    C++    2017-12-30 13:13:09
20594652    nmphy    D    段错误    3    384    485    C++    2017-12-30 13:07:57
20594225    nmphy    C    答案正确    71    3904    560    C++    2017-12-30 12:59:14
20594201    nmphy    C    答案正确    69    4028    560    C++    2017-12-30 12:58:48
20593760    nmphy    B    答案正确    3    512    553    C++    2017-12-30 12:49:38
20593541    nmphy    A    答案正确    516    13056    988    C++    2017-12-30 12:44:16

反正就是12.30左右知道他们有比赛,赶紧注册的。。14.30AK,(其中还有E题耽误的不少时间)排名第7。。。可见其题难道。。。难道我是难题渣。。。水题王。。。打表。。。贪心。。。

E题比赛时错了很多次,后来刷新后就A了。。。可能数据有点极端。(耽误了我20分钟。比完才告诉我A了,我以为10题挂机,结果AK了)。

A:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1010;
int x[maxn][maxn],y[maxn][maxn];
char ch[maxn][maxn],opt[10];
int main()
{
    int n,m,q,i,j,a,b;
    while(~scanf("%d%d%d",&n,&m,&q)){
        for(i=1;i<=n;i++)
         for(j=1;j<=m;j++)
          cin>>ch[i][j];
        for(i=1;i<=n;i++)
         for(j=1;j<=m;j++)
          x[i][j]=x[i][j-1]+(ch[i][j]=='#'?1:0);
        for(i=1;i<=n;i++)
         for(j=1;j<=m;j++)
          y[i][j]=y[i-1][j]+(ch[i][j]=='#'?1:0);
        for(i=1;i<=q;i++){
            scanf("%d%d%s",&a,&b,opt);
            if(opt[0]=='D'){
                if(y[n][b]-y[a-1][b]==0)  printf("YES\n");
                else printf("NO\n");
            }
            else if(opt[0]=='U'){
                 if(y[a][b]-y[0][b]==0) printf("YES\n");
                 else printf("NO\n");
            }
            else if(opt[0]=='R'){
                if(x[a][m]-x[a][b-1]==0)  printf("YES\n");
                else printf("NO\n");
            }
            else if(opt[0]=='L')    {
                if(x[a][b]-x[a][0]==0) printf("YES\n");
                else printf("NO\n");
            }      
        }
    } return 0;
}
View Code

B:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int maxn=1010000;
char ch[maxn];
int vis[100];
int main()
{
    while(~scanf("%s",ch)){
        int L=strlen(ch);
        for(int i=0;i<=10;i++) vis[i]=0;
        bool Flag=true;int cnt=0;
        for(int i=0;i<L;i++) {
            if(ch[i]<'0'||ch[i]>'9'){ Flag=false;break;}
            if(vis[ch[i]-'0']==0){
               cnt++;
               vis[ch[i]-'0']=1;
               if(cnt>=2) { Flag=false;break;}
            }
        }
        if(Flag) printf("YES\n");
        else printf("NO\n");
    } return 0;
}
View Code

C:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
ll ans;
struct in
{
    ll a;
    ll b;
    ll c;
}x[100010];
bool cmp(in x,in y){
    return x.c>y.c;
}
int main()
{
    int i,j,k,n;
    while(~scanf("%d%d",&n,&k)){
        for(i=1;i<=n;i++) scanf("%lld",&x[i].a);
        for(i=1;i<=n;i++) scanf("%lld",&x[i].b);
        for(i=1;i<=n;i++) x[i].c=x[i].a-x[i].b;
        sort(x+1,x+n+1,cmp);
        for(i=1;i<=k;i++) ans+=x[i].a;
        for(i=k+1;i<=n;i++) ans+=x[i].b;
        printf("%lld\n",ans);
    } return 0;
}
View Code

D:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
const int maxn=10010;
ll ans,w[maxn],sum[maxn];
int main()
{
    int i,j,n,m,L,R;
    while(~scanf("%d",&n)){
        ans=0;
        for(i=1;i<=n;i++) scanf("%lld",&w[i]),sum[i]=sum[i-1]+w[i];
        scanf("%d",&m);
        for(i=1;i<=m;i++){
           scanf("%d%d",&L,&R);
           if(sum[R]-sum[L-1]>0) ans+=sum[R]-sum[L-1];
        }
        printf("%lld\n",ans);
    }  return 0;
}
View Code

E:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
const int Mod=1000000007;
ll ans1,ans2;
ll q_pow(ll a,ll x)
{
    ll res=1;a%=Mod;
    while(x){
        if(x&1LL) res=res*a%Mod;
        x>>=1;
        a=a*a%Mod;
    } return res;
}
int main()
{
    ll m,n;
    while(~scanf("%lld%lld",&n,&m)){
        m%=Mod;
        ans1=q_pow(m,n);
        ans2=q_pow(m-1,n-1);
        ans2=ans2*m%Mod;
        printf("%lld\n",((ans1-ans2)%Mod+Mod)%Mod);
    } return 0;
}
View Code

F:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
int x[]={0,1,2,2,3,3,4,4};
char c[20][20];
int main()
{
    int n,ans,i,j;
    while(~scanf("%d",&n)){
        if(n==0) return 0;
        ans=0;
        for(i=1;i<=13;i++){
            scanf("%s",c[i]+1);
            for(j=1;j<=13;j++){
                 if(c[i][j]=='#') {
                     int tmp=i;
                     if(14-i<tmp) tmp=14-i;
                     if(j<tmp) tmp=j;
                     if(14-j<tmp) tmp=14-j;
                     ans+=x[tmp];
                 }
            }
        }
        printf("%.2lf\n",(double)(1.0*ans)/n);
    } return 0;
}
View Code

G:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
char a[10],b[10];
int s[100];
int main()
{
    int n,i,j,ans1,ans2;
    s['J'-'A'+1]=1;
    s['M'-'A'+1]=2;
    s['T'-'A'+1]=3;
    s['S'-'A'+1]=4;
    s['H'-'A'+1]=5;
    while(~scanf("%d",&n)){
        ans1=0;ans2=0;
        for(i=1;i<=n;i++){
            scanf("%s%s",a,b);
            if(s[a[0]-'A'+1]==s[b[0]-'A'+1]) ans1++,ans2++;
            else if(s[a[0]-'A'+1]==s[b[0]-'A'+1]-1) ans1+=3;
            else if(s[b[0]-'A'+1]==s[a[0]-'A'+1]-1) ans2+=3;
            else if(s[a[0]-'A'+1]==1&&s[b[0]-'A'+1]==5) ans2+=3;
            else if(s[b[0]-'A'+1]==1&&s[a[0]-'A'+1]==5) ans1+=3;
        }
        if(ans1>ans2) printf("Alice\n");
        else if(ans1<ans2)printf("Bob\n");
        else printf("Draw\n");
    }return 0;
}
View Code

H:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
int main()
{
    int n,i;
    while(~scanf("%d",&n)){
        for(i=1;i<=n;i++) printf("gu...");
        printf("\nThe story is so boring. And I am so hungry!\n");
    } return 0;
}
View Code

I:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
ll ans;
ll dp[30][2];
int main()
{
    int n,i,j;
    while(~scanf("%d",&n)){
        dp[1][1]=1;dp[1][0]=1;
        for(i=2;i<=n;i++){
            dp[i][1]=dp[i-1][1]+dp[i-1][0];
            dp[i][0]=dp[i-1][1];
        }
        printf("%lld\n",dp[n][0]+dp[n][1]);
    }
    return 0;
}
View Code

J:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;
const int maxn=100010;
char c[maxn],a[10],b[10];
int x[30];
int Up[maxn];
int main()
{
    int i,n,j,m,L;
    while(~scanf("%s",c)){
        for(i=1;i<=26;i++) x[i]=i;
        L=strlen(c);
        scanf("%d",&m);
        for(i=1;i<=m;i++){
            scanf("%s%s",a,b);
            swap(x[a[0]-'a'+1],x[b[0]-'a'+1]);
        }
        for(i=0;i<L;i++) printf("%c",x[c[i]-'a'+1]+'a'-1);
    } return 0;
}
View Code

K:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<string>
#define ll long long 
using namespace std;
const int maxn=10010;
ll sum[maxn],Max;
int main()
{
    int n,m,i,j,L,R;
    while(~scanf("%d%d",&n,&m)){
        Max=0;for(i=1;i<=5000;i++) sum[i]=0;
        for(i=1;i<=n;i++) {
            scanf("%d%d",&L,&R);
            sum[L]++;
            sum[R+1]--;
        }
        for(i=1;i<=5000;i++) {
            sum[i]+=sum[i-1];
            if(sum[i]>Max) Max=sum[i];
        }
        if(Max%m==0) printf("%lld\n",Max/m);
        else printf("%lld\n",Max/m+1);
    } return 0;
}
View Code

 

posted @ 2017-12-30 21:57  nimphy  阅读(432)  评论(0编辑  收藏  举报