前言
开学后,新学年新气象,学校题库也迎来了新的改动,界面大改变,也可以比赛了。
所以这周就有比赛了,而在纪中被虐习惯后回来渴望继续被虐就来参加提高组模拟赛(反正今年也参加提高组)
成绩
只放Rank 1∼10Rank1∼10
RankRank | PersonPerson | ScoreScore |
---|---|---|
1 | 2015hjw2015hjw | 200 |
2 | 2015yjy2015yjy | 140 |
3 | 2017myself2017myself | 120 |
4 | 2015lzx2015lzx | 100 |
5 | 2017xxy2017xxy | 80 |
6 | 2017xjq2017xjq | 70 |
6 | 2015trx2015trx | 70 |
8 | 2015cjx2015cjx | 60 |
9 | 2017lw2017lw | 40 |
10 | 2017zyc2017zyc | 20 |
10 | 2017hzb2017hzb | 20 |
10 | 2017lrz2017lrz | 20 |
10 | 2017hjq2017hjq | 20 |
正题
T1:nssl1141,jzoj3470−T1:nssl1141,jzoj3470−最短路【SPFASPFA,暴力】
博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82529745
nssl1142,jzoj3487−nssl1142,jzoj3487−剑与魔法【堆,贪心】
博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82529832
T3:nssl1143,jzoj3493−T3:nssl1143,jzoj3493−三角形【排序,数学,几何】
博客链接:https://blog.csdn.net/Mr_wuyongcong/article/details/82529996
一些codecode
T3随机数据
#include<cstdlib>
#include<cstdio>
#include<ctime>
#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<cstdio>
#include<algorithm>
#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;j<i;j++)for(int k=1;k<j;k++)if(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<windows.h>
#include<ctime>
#include<cstdio>
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<cstdio>
#include<queue>
#include<cstring>
#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].w<f[y]){f[y]=f[x]+a[i].w;if(!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<cstdio>
#include<algorithm>
#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]<a[x]||y+1<=num&&a[y+1]<a[x]){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(num<e[let]||let==m){a[++num]=rp[i];up(num);}else if(a[1]<rp[i]){a[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<cstdio>
#include<cstring>
#include<algorithm>
#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)&&wz<p) wz++;return 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;j<i;j++){ans+=j-1;tj(x[i],y[i],x[j],y[j]);}}printf("%d",ans);
}
尾声
没了