11.14 文综考试

11.14 文综考试

在别人考理综的时候,我们在考文综

T1 历史

不会。

#include<bits/stdc++.h>
#define int long long
char buf[1<<20],*p1,*p2;
#define uc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
#define ph putchar
using namespace std;
const int inf=1e9+7;
inline int in();
inline void out(int x);
int a=in(),k=in(),m=in(),mky,ax,lx=-1,lyr,ayr=-1;
int hea[10000010],lst[10000010],ext[10000010];
bool bkl[10000010],oier;
main(void) {
	register int i,mu;
	for(i=0; i<k; i++) {
		mky=i*i%k;
		if(!bkl[mky]) {
			bkl[mky]=1;
			hea[mky]=i;
		} else ext[lst[mky]]=i;
		lst[mky]=i,ext[i]=-1;
	}	register int qt,rt;
	while(a) {
		if(!bkl[a%k]) {
			ax=-1;
			if(!oier&&m>=a&&(m-a)%k==0)
				ayr=lyr+(m-a)/k;
			break;
		}	qt=ceil(sqrt(a)),mu=qt%k;
		for(i=hea[a%k]; i>=0; i=ext[i])
			if(i>=mu)break;
		if(i<0)i=hea[a%k]+k;
		qt+=i-mu,rt=qt*qt;
		if(!oier&&m>=a&&m<=rt&&(m-a)%k==0)
			ayr=lyr+(m-a)/k,oier=1;
		if(lx==rt)break;
		lyr+=(rt-a)/k+1,a=qt;
		ax=max(ax,rt),lx=rt;
	}	out(ax),ph('\n'),out(ayr);
}
inline int in() {
	register int x=0;
	register char s=uc;
	register bool f=0;
	while((s<'0'||s>'9')&&s!='-')s=uc;
	if(s=='-')f=1,s=uc;
	while(s>='0'&&s<='9')x=(x<<1)+(x<<3)+(s^48),s=uc;
	return f?-x:x;
}
inline void out(int x) {
	if(x<0)ph('-'),x=~x+1;
	if(x>9)out(x/10);
	ph((x%10)^48);
}

T2 地理

唯一做出来的题。难道说这预示着我选科要选地理?

题目大意:
给出一个\(N*N*N\)的正方体,正方体上0表示障碍,1表示平地,可从平地以\(1s/\)格的速度走到相邻的四格。可沿棱转移到另一个面。同时存在\(m\)个虫洞,可从一点在\(1s\)到达另一点。
\(Q\)次询问,询问一点走到另一点的最短时间。若无法到达则输出\(-1\)

数据范围:
\(1\leq N\leq10,0\leq m\leq 1000,1\leq q \leq 10^5\)
不要把这道题看得太难。
这道题真的很简单。
真的。

\(QAQ\)


其实就是\(BFS\),好像把能到达的边连起来之后\(Floyd\)也能跑。
注意要在询问之前先把所有方案数算出来,为了保险用6维的数组存答案。
真的就是\(BFS\)而已。
而已。
真的

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
using namespace std;
int n;
bool Map[7][12][12];//1:U 2:L 3:F 4:R 5:B 6:D 
inline int sel(char x){switch(x){case 'U':{return 1;}case 'L':{return 2;}case 'F':{return 3;}case 'R':{return 4;}case 'B':{return 5;}case 'D':{return 6;}}}
struct cd{
	int sum;
	int to1[601],tox[601],toy[601];
	bool ap;
}map1[7][12][12];
char T[100];
bool mark[7][12][12];
int dis[7][12][12][7][12][12];
struct node{
	int pm,x,y;
	int dis;
};
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

node change(int p,int x,int y)
{
	node tmp;
	switch(p){
		case 1:{
			if(x==0){
				tmp.pm=4;
				tmp.x=1;
				tmp.y=n-y+1;
			}
			if(x==n+1){
				tmp.pm=2;
				tmp.x=1;
				tmp.y=y;
				
			}
			if(y==0){
				tmp.pm=5;
				tmp.x=1;
				tmp.y=x;
			}
			if(y==n+1){
				tmp.pm=3;
				tmp.x=1;
				tmp.y=n-x+1;
			}
			return tmp;
			break;
		}
		case 2:{
			if(x==0){
				tmp.pm=1;
				tmp.x=n;
				tmp.y=y;
			}
			if(x==n+1){
				tmp.pm=6;
				tmp.x=1;
				tmp.y=y;
			}
			if(y==0){
				tmp.pm=5;
				tmp.x=x;
				tmp.y=n;
			}
			if(y==n+1){
				tmp.pm=3;
				tmp.x=x;
				tmp.y=1;
			}
			return tmp;
			break;
		}
		case 3:{
			if(x==0){
				tmp.pm=1;
				tmp.x=n-y+1;
				tmp.y=n;
			}
			if(x==n+1){
				tmp.pm=6;
				tmp.x=y;
				tmp.y=n;
			}
			if(y==0){
				tmp.pm=2;
				tmp.x=x;
				tmp.y=n;
			}
			if(y==n+1){
				tmp.pm=4;
				tmp.x=x;
				tmp.y=1;
			}
			return tmp;
			break;
		}
		case 4:{
			if(x==0){
				tmp.pm=1;
				tmp.x=1;
				tmp.y=n-y+1;
			}
			if(x==n+1){
				tmp.pm=6;
				tmp.x=n;
				tmp.y=n-y+1;
			}
			if(y==0){
				tmp.pm=3;
				tmp.x=x;
				tmp.y=n;
			}
			if(y==n+1){
				tmp.pm=5;
				tmp.x=x;
				tmp.y=1;
			}
			return tmp;
			break;
		}
		case 5:{
			if(x==0){
				tmp.pm=1;
				tmp.x=y;
				tmp.y=1;
			}
			if(x==n+1){
				tmp.pm=6;
				tmp.x=n-y+1;
				tmp.y=1;
			}
			if(y==0){
				tmp.pm=4;
				tmp.x=x;
				tmp.y=n;
			}
			if(y==n+1){
				tmp.pm=2;
				tmp.x=x;
				tmp.y=1;
			}
			return tmp;
			break;
		}
		case 6:{
			if(x==0){
				tmp.pm=2;
				tmp.x=n;
				tmp.y=y;
			}
			if(x==n+1){
				tmp.pm=4;
				tmp.x=n;
				tmp.y=n-y+1;
			}
			if(y==0){
				tmp.pm=5;
				tmp.x=n;
				tmp.y=n-x+1;
			}
			if(y==n+1){
				tmp.pm=3;
				tmp.x=n;
				tmp.y=x;
			}
			return tmp;
			break;
		}
	}
}
int bfs(int sp,int sx,int sy)
{
	memset(mark,0,sizeof(mark));
	queue<node>q;
	q.push((node){sp,sx,sy,0});	
	while(q.size()){
		node tmp=q.front();
		int p=tmp.pm,x=tmp.x,y=tmp.y;
		q.pop();
		if(mark[p][x][y])continue;
		mark[p][x][y]=1;
		dis[sp][sx][sy][p][x][y]=tmp.dis;
		for(int i=0;i<4;i++){
			int fx=x+dx[i],fy=y+dy[i];
			if(fx==0||fx==n+1||fy==0||fy==n+1){
				node p1=change(p,fx,fy);
				if(!Map[p1.pm][p1.x][p1.y])continue;
				p1.dis=tmp.dis+1;
				q.push(p1);
			}
			else{
				node p2;
				if(!Map[p][fx][fy])continue;
				p2.pm=p;p2.x=fx;p2.y=fy;p2.dis=tmp.dis+1;
				q.push(p2);
			}
			
		}
		if(map1[p][x][y].ap){
			cd t=map1[p][x][y];
			for(int i=1;i<=t.sum;i++)
			{
				node p3;
			p3.pm=t.to1[i];p3.x=t.tox[i];p3.y=t.toy[i];p3.dis=tmp.dis+1;
			if(!Map[p3.pm][p3.x][p3.y])continue;
			q.push(p3);
			}
		}
	}
}
int main()
{
	memset(dis,0x3f,sizeof(dis));
	ios::sync_with_stdio(0);
	cin.tie(0);
//	freopen("geog.in","r",stdin);
//	freopen("geog.out","w",stdout);
	int i,j;
	cin>>n;
	for(i=1;i!=n+1;++i){
		cin>>T;
		for(j=1;j!=n+1;++j){
			Map[1][i][j]=T[j-1]-'0';
		}
	}
	for(i=1;i!=n+1;++i)
	{
		cin>>T;
		for(j=1;j!=4*n+1;++j){
			Map[1+(j-1)/n+1][i][(j-1)%n+1]=T[j-1]-'0';
		}
	}
	for(i=1;i!=n+1;++i){
		cin>>T;
		for(j=1;j!=n+1;++j){
			Map[6][i][j]=T[j-1]-'0';
		}
	}
	int m;
	cin>>m;
	for(i=1;i<=m;++i)
	{
		char f1,f2;
		int x1,y1,x2,y2;
		cin>>f1>>x1>>y1>>f2>>x2>>y2;
		int ff1=sel(f1),ff2=sel(f2);
		map1[ff1][x1][y1].sum+=1;map1[ff2][x2][y2].sum+=1;
		map1[ff1][x1][y1].ap=1;map1[ff1][x1][y1].to1[map1[ff1][x1][y1].sum]=ff2;map1[ff1][x1][y1].tox[map1[ff1][x1][y1].sum]=x2;map1[ff1][x1][y1].toy[map1[ff1][x1][y1].sum]=y2;
		map1[ff2][x2][y2].ap=1;map1[ff2][x2][y2].to1[map1[ff2][x2][y2].sum]=ff1;map1[ff2][x2][y2].tox[map1[ff2][x2][y2].sum]=x1;map1[ff2][x2][y2].toy[map1[ff2][x2][y2].sum]=y1;
	}
	for(int p=1;p<=6;p++)
	{
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n;j++){
				if(Map[p][i][j]){
					bfs(p,i,j);
				}
			}
		}
	}
	int Q;
	cin>>Q;
	for(i=1;i<=Q;++i){
		char f1,f2;
		int x1,y1,x2,y2;
		cin>>f1>>x1>>y1>>f2>>x2>>y2;
		int d=dis[sel(f1)][x1][y1][sel(f2)][x2][y2];
		if(d!=0x3f3f3f3f)
		printf("%d\n",d);
		else printf("-1\n");
	}
	return 0;
}

换面操作好麻烦啊啊啊啊啊啊啊啊啊
注:在一个点上可能有多个虫洞,虫洞可能连上自己

T3 政治

没看,不会
 
 
 
 
总结:
1.你以为这道题要考什么算法,实际上要考你打码
2.nodgdNMSL

 
 

posted @ 2019-11-14 19:34  国土战略局特工  阅读(133)  评论(0)    收藏  举报