ssl提高组周六模拟赛【2018.9.8】

前言

开学后,新学年新气象,学校题库也迎来了新的改动,界面大改变,也可以比赛了。
所以这周就有比赛了,而在纪中被虐习惯后回来渴望继续被虐就来参加提高组模拟赛(反正今年也参加提高组)


成绩

只放 Rank 110 R a n k   1 ∼ 10

Rank R a n k Person P e r s o n Score S c o r e
1 2015hjw 2015 h j w 200
2 2015yjy 2015 y j y 140
3 2017myself 2017 m y s e l f 120
4 2015lzx 2015 l z x 100
5 2017xxy 2017 x x y 80
6 2017xjq 2017 x j q 70
6 2015trx 2015 t r x 70
8 2015cjx 2015 c j x 60
9 2017lw 2017 l w 40
10 2017zyc 2017 z y c 20
10 2017hzb 2017 h z b 20
10 2017lrz 2017 l r z 20
10 2017hjq 2017 h j q 20

正题


T1:nssl1141,jzoj3470 T 1 : n s s l 1141 , j z o j 3470 − 最短路【 SPFA S P F A ,暴力】

博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82529745


nssl1142,jzoj3487 n s s l 1142 , j z o j 3487 − 剑与魔法【堆,贪心】

博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82529832


T3:nssl1143,jzoj3493 T 3 : n s s l 1143 , j z o j 3493 − 三角形【排序,数学,几何】

博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82529996


一些 code c o d e


T3随机数据

#include
#include
#include
#define random(x) rand()%x
using namespace std;
int n,x,y,a[1000][1000];
int main()
{
    srand(time(0));
    freopen("data.in","w",stdout);
    n=500;
    printf("500\n");
    for(int i=1;i<=n;i++)
    {
        x=random(100);y=random(100);
        while(a[x][y])x=random(100),y=random(100);
        a[x][y]=true;
        printf("%d %d\n",x,y);
    }
}

T3暴力

#include
#include
#define N 3010
#define gcd(x,y) abs(__gcd(x,y))
using namespace std;
int n,ans,x[N],y[N];
bool check(int x1,int y1,int x2,int y2,int x3,int y3)
{
    if(x1>x2) swap(x1,x2),swap(y1,y2);
    if(x1>x3) swap(x1,x3),swap(y1,y3);
    if(x2>x3) swap(x2,x3),swap(y2,y3);
    //if(!(y1<=y2&&y2<=y3||y1>=y2&&y2>=y3)) return true;
    int a1=x2-x1,a2=x3-x2,b1=y2-y1,b2=y3-y2;
    if(!a1&&!a2||!b2&&!b1) return false;
    if(!a1||!a2||!b1||!b2) return true;
    int g1=gcd(a1,b1),g2=gcd(a2,b2);
    a1/=g1;a2/=g2;b1/=g1;b2/=g2;
    if(a1==a2&&b1==b2)return false;
}
int main()
{
    freopen("data.in","r",stdin);
    freopen("data.ans1","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
      scanf("%d%d",&x[i],&y[i]);
    for(int i=3;i<=n;i++)
      for(int j=2;jfor(int k=1;kif(check(x[k],y[k],x[j],y[j],x[i],y[i]))
          {
            //printf("%d,%d %d,%d %d,%d\n",x[k],y[k],x[j],y[j],x[i],y[i]);
            ans++;
          }
    printf("%d",ans);
}

T3对拍程序

#include
#include
#include
using namespace std;
int main()
{
    while(true)
    {
        system("sjxr.exe");
        system("sjx1.exe");
        double st=clock();
        system("sjx2.exe");
        double ed=clock();
        if(system("fc data.ans1 data.ans2")){
            printf("WA");
            return 0;
        }
        else
        {
            printf("AC time:%0.2lf\n",ed-st);
        }
    }
}

T1 WA40代码

#include
#include
#include
#define N 50010
using namespace std;
struct line{
    int to,next,w;
}a[N*2];
int n,m,x,y,w,k,s,t,f[N],v[N],tot,ls[N],ans;
queue<int> q;
void addl()
{
    scanf("%d%d%d",&x,&y,&w);
    a[++tot].to=y;a[tot].w=w;
    a[tot].next=ls[x];ls[x]=tot;
}
void spfa(int x)
{
    memset(f,127/3,sizeof(f));
    q.push(x);v[x]=1;f[x]=0;
    while(!q.empty())
    {
        int x=q.front();q.pop();
        for(int i=ls[x];i;i=a[i].next)
        {
            int y=a[i].to;
            if(f[x]+a[i].wif(!v[y])
                {
                    v[y]=true;
                    q.push(y);
                }
            }
        }
        v[x]=false;
    }
}
int main()
{
    scanf("%d%d%d%d%d",&n,&m,&k,&s,&t);
    for(int i=1;i<=m;i++)addl();
    spfa(s);
    for(int i=1;i<=k;i++)
    {
        scanf("%d",&x);
        if(f[x]>=707406378){
            printf("-1");
            return 0;
        }
        ans+=f[x];
        spfa(x);
    }
    if(f[t]>=707406378){
        printf("-1");
        return 0;
    }
    ans+=f[t];
    printf("%d",ans);
}

T2 WA10程序

#include
#include
#define N 200010
using namespace std;
int cnt,n,m,rp[N],e[N],get[N],ans,a[N],let,num;
char ch[2];
void up(int x)
{
    while(x>1&&a[x>>1]>a[x])
    {
        swap(a[x>>1],a[x]);
        x>>=1;
    }
}
void down(int x)
{
    int y=x<<1;
    while(y<=num&&a[y]1<=num&&a[y+1]if(a[y]>a[y+1]) y++;
        swap(a[x],a[y]);
        x=y;
        y<<=1;
    }
}
int main()
{
    scanf("%d",&cnt);
    for(int i=1;i<=cnt;i++)
    {
        scanf("%s ",ch);
        if(ch[0]=='c'){
            scanf("%d",&rp[++n]);
        }
        else scanf("%d",&e[++m]),get[m]=n,e[m]--;
    }
    let=1;num=0;
    for(int i=1;i<=n;i++)
    {
        if(numlet]||let==m)
        {
            a[++num]=rp[i];
            up(num);
        }
        else if(a[1]1]=rp[i];
            down(1);
        }
        while(get[let]==i&&let!=m)
        {
            let++;
            while(num>e[let]){
                swap(a[1],a[num]);
                num--;
                down(1);
            }
        }
    }
    if(num<=e[let]){
        printf("-1");
        return 0;
    }
    int ans=0;
    for(int i=1;i<=num;i++) ans+=a[i];
    printf("%d",ans);
}

T3 WA70代码

#include
#include
#include
#define N 3010
#define gcd(x,y) abs(__gcd(x,y))
#define p 300007
#define hashmath(x,y) abs(x+y+x*y*y)%p
using namespace std;
int n,ans,x[N],y[N],num[p];
struct node{
    int a,b;
}hash[p];
int locate(node x)
{
    int wz=hashmath(x.a,x.b);
    while(num[wz%p]&&(hash[wz%p].a!=x.a||hash[wz%p].b!=x.b)&&wzreturn wz%p;
}
node check(int x1,int y1,int x2,int y2)
{
    if(x1>x2) swap(x1,x2),swap(y1,y2);
    int a1=x2-x1,b1=y2-y1;
    if(!a1||!b1) return (node){(bool)a1,(bool)b1};
    int g1=gcd(a1,b1);
    a1/=g1;b1/=g1;
    return (node){a1,b1};
}
void tj(int x1,int y1,int x2,int y2)
{
    node now=check(x1,y1,x2,y2);
    int wz=locate(now);
    ans-=num[wz];
    hash[wz]=now;num[wz]++;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
      scanf("%d%d",&x[i],&y[i]);
    for(int i=3;i<=n;i++)
    {
        memset(num,0,sizeof(num));
        memset(hash,0,sizeof(hash));
        tj(x[i],y[i],x[1],y[1]);
        for(int j=2;j1;
            tj(x[i],y[i],x[j],y[j]);
        }
    }
    printf("%d",ans);
}

尾声

没了

你可能感兴趣的:(模拟赛)