The first set OFF improve --2005NOIP

 

20:05:51 Youth is not escape the water disappeared in the blink of an eye fingertips. Waste of force, and then forced to regret it. - Mayday "Crazy World"

The first question who took up scholarship

http://219.153.61.2:9000/contest/238/problem/1070

This question focuses on playing the code, more suitable for use structure, variable

#include<bits/stdc++.h>
using namespace std;
struct as{
    char st[20];
    int c;
    int j;
    char a;
    char b;
    int d;
    int jxj=0;
}ss[1003];
int main()
{
    int n,p,q,sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>ss[i].st;
        cin>>ss[i].c;
        cin>>ss[i].j;
        cin>>ss[i].a;
        cin>>ss[i].b;
        cin>>ss[i].d;
        if(ss[i].d>=1&&ss[i].c>80)ss[i].jxj+=8000;
        if(ss[i].c>85&&ss[i].j>80)ss[i].jxj+=4000;
        if(ss[i].c>90)ss[i].jxj+=2000;
        if(ss[i].c>85&&ss[i].b=='Y') ss[i].jxj+=1000;
        if(ss[i].j>80&&ss[i].a=='Y') ss[i].jxj+=850;
    }
    p=ss[1].jxj;
    for(int i=1;i<=n;i++)
    {
        if(ss[i].jxj>p)
        {
            p=ss[i].jxj;
            q=i;
        }
        sum+=ss[i].jxj;
    }
    cout<<ss[q].st<<endl<<p<<endl<<sum; 
    return 0; 
}

 A simple question like this must be carefully carefully carefully! ! !

21:41:23 If another space-time can not change the other one body to another ending imagine you just want to see your future in the past I just want to see you - "see you see you see you."

The second question across the river

http://219.153.61.2:9000/problem/1069

This question is a dp, but if only a simple dp, can only get L <1000 was 30 points. First, c ++ spatial complexity is not supported by an array of 10 (9) opening of this size, secondly, for the latter cycle length, the time complexity will be out of range, so that an optimization of this question needs to be done. The path is very long, but the number of stones is very small, but the walk is not the best frog went stone place, so only when needed in the path continues mod once, the program can be greatly optimized. There is no need to open an array of 10 ^ 9.

State transition equation: f [i] = min (f [i], f [ik] + vis [i]);

#include<bits/stdc++.h>
using namespace std;
int s,t,l,m,a[1000009],f[100009];
bool vis[100001];
int main()
{
    scanf("%d%d%d%d",&l,&s,&t,&m);
    for(int i=1;i<=m;i++)
    cin>>a[i];
    memset(f,60,sizeof(f));
    f[0]=0;
    int o=0;
    sort(a,a+m+2);
    for(int i=1;i<=m+1;i++) 
    {
        if(a[i]-a[i-1]<=t*s)
        o+=a[i]-a[i-1];
        else
        o+=(a[i]-a[i-1])%t+t;
        vis[o]=true;
    }
    for(long long i=1;i<=o+t;i++)
    { 
        for(int k=s;k<=t;k++)
        {
            if(i-k>=0)
            f[i]=min(f[i],f[i-k]+vis[i]);
        }
    }
    int ans=999999;
    for(int i=o;i<=o+t;i++)
    ans=min(ans,f[i]);
    printf("%d",ans);
    return 0;
}

22:20:30 backs are false is really nothing you are not persistent hundred years ago you and I are not I - "Hundred Years of Solitude"

The third question bonfire party [O (n)]

http://219.153.61.2:9000/problem/1068

Here does not refer to the m points must be in one piece, just that find out the m points from the original sequence in the exchange, the exchange price for m. This is the pit, I will think for a long time.

Greedy: Suppose able to form a ring, then the cost of replacing a certain number may be equal to the number of positions is not at all. It certainly is not in their original position, because the position of a point can only have one, but it has been taken to a certain point. The initial sequence of fixed state, enumerate the resulting displacement sequence, each time to find it again.

Many found the number will not be in place, these states are wasted. Thus obtained to the number of column permutation, long, the same statistics for each number of the number of long distance to find the initial state can be optimized.

#include<bits/stdc++.h>
using namespace std;
const int N=50001;
int a[N],b[N];
int s[N],x[N],y[N],ans;
int i,j,n;
int main()
{
    scanf("%d",&n);
    for(i=1; i<=n; i++)
    scanf("%d%d",&a[i],&b[i]);
    s[1]=1,s[n]=a[1];
    s[2]=b[1];
    for(i=3;i<n;i++)
    if(a[s[i-1]]==s[i-2]) s[i]=b[s[i-1]];
    else s[i]=a[s[i-1]];
    for(i=1;i<=n;i++)
    {
        int t1=i+1,t2=i-1;
        if(t1>n) t1=1;
        if(t2<1) t2=n;
        if((s[t1]!=a[s[i]]||s[t2]!=b[s[i]])&&(s[t2]!=a[s[i]]||s[t1]!=b[s[i]]))
        {
            printf("-1");
            return 0;
        }
    }
    for(i=1;i<=n;i++)
    {
        x[(s[i]-i+n)%n]++;
        y[(s[i]+i-1)%n]++;
    }
    for(i=0;i<n;i++)
    {
        if (ans<x[i]) ans=x[i];
        if (ans<y[i]) ans=y[i];
    }
    printf("%d",n-ans);
    return 0;
}

23:07:51 irreplaceable world is embracing you feel Wan sea of ​​people no one belongs to me gentle - "a"

The fourth title equivalent expression

http://219.153.61.2:9000/contest/238/problem/1067

To an expression is evaluated, it must first get rid of the excess expression wrapped in parentheses. If not contain any symbol in the expression, only digital (or a a), then we return to direct digital (or a ^ 1). Otherwise, find the lowest priority and not be wrapped in parentheses operator. Find a far right (because our operators are left associative).

It is easy to think of violent demolition brackets. However, this method has two troublesome areas

1. The need to achieve due to a storage structure and support for multiple operating Formula

2. (a-1)^10^10^10^10expressions such structure will store many things to explode.

In general this expression and other issues are usually solved by using the stack

#include<bits/stdc++.h>
#define ll long long
#define oo 10020123
#define mod 100000007
using namespace std;
ll xz(ll x,ll t){
    ll ans=1;
    for(int i=1;i<=t;i++)
    ans=ans*x%mod;
    return ans;
}
ll sby(char *s,int l,int r,ll a)
{
    int o=0,mm=52,mn=+oo,cnt=0,p[52],num=0;
    memset(p,0x3f,sizeof(p));
    for(int i=r;i>=l;i--)
    {
        if(s[i]==')')o+=100;
        if(s[i]=='(')o-=100;
        if(s[i]=='^')p[i]=o+3,cnt++;
        if(s[i]=='*')p[i]=o+2,cnt++;
        if(s[i]=='+')p[i]=o+1,cnt++;
        if(s[i]=='-')p[i]=o+1,cnt++;
        if(mn>p[i])mn=p[i],mm=i;
    }
    if(cnt==0)
    {
        for(int i=l;i<=r;i++)if(s[i]=='a')return a;
        for(int i=l;i<=r;i++)if(isdigit(s[i]))num=num*10+s[i]-'0';
        return num;
    }
    else
    {
        if(s[mm]=='^')return xz(sby(s,l,mm-1,a),sby(s,mm+1,r,a));
        if(s[mm]=='*')return (sby(s,l,mm-1,a)*sby(s,mm+1,r,a))%mod;
        if(s[mm]=='+')return (sby(s,l,mm-1,a)+sby(s,mm+1,r,a))%mod;
        if(s[mm]=='-')return (sby(s,l,mm-1,a)-sby(s,mm+1,r,a))%mod;
    }
    return 0;
}
int main()
{
    int l[27],n,ans[15];
    char ss[27][52];    
    scanf("%[^\r]",ss[0]),getchar();
    l[0]=strlen(ss[0]);
    cin>>n,getchar();
    for(int i=1;i<=n;i++)
    {
        scanf("%[^\r]",ss[i]),getchar();
        l[i]=strlen(ss[i]);
    }
    for(int i=0;i<=10;i++)
    ans[i]=sby(ss[0],0,l[0]-1,i-5);
    for(int i=1;i<=n;i++)
    {
        int f=1;
        for(int j=0;j<=10;j++)
        if(ans[j]!=sby(ss[i],0,l[i]-1,j-5))
        {
            f=0;
            break;
        }
        if(f)
        printf("%c",'A'+i-1);
    }
    return 0;
}

Well! ! ! We're done! ! !

23:53:31 you take me to find another heaven far more beautiful than expected we embrace this a paradise for every dream, has endless joys - "Another Heaven"

Guess you like

Origin www.cnblogs.com/wybxz/p/12203803.html