NOIP2017金秋衝刺訓練營杯聯賽模擬大獎賽第二輪Day1

蒟蒻打的跟狗屎一樣,

第一題玄學亂打,真的超討厭這種題,打得我完全沒耐心想其它題了。

然後。。。其它兩個題就打暴力了,

紀念一下,被我調到不成樣子的第一題。

聽說明天很難QAQ

AC代碼:

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=100100;
int n,m,y,x,z;
int pi2[4][2]={1,-1,-1,-1,-1,1,1,1};
struct node{
	int x,y;
};
node s1[N],s2[N],s3[N],s4[N];
int main()
{
	freopen("calc.in","r",stdin);
	freopen("calc.out","w",stdout);
	scanf("%d%d%d%d%d",&m,&n,&y,&x,&z);//n,m,x,y
	m--;n--;
	s1[1].x=0;s1[1].y=m;
	s2[1].x=n;s2[1].y=m;
	s3[1].x=n;s3[1].y=0;
	s4[1].x=1;s4[1].y=0;
	int fang=-1;
	if(x==0){int yu=m-y;if(yu>=z) {printf("%d %d",y+z,x);return 0;}else y=m,z-=yu,fang=1;}
	if(s1[1].y==y){fang=1;}
	if(s2[1].x==x){fang=2;}
	if(s3[1].y==y){fang=3;}
	if(s4[1].x==x){fang=4;}
	int tot=1;
	//xia zuo shang you
	while(fang==-1)
	{
		s1[tot+1].x=s1[tot].x+pi2[0][0];s1[tot+1].y=s1[tot].y+pi2[0][1];
		s2[tot+1].x=s2[tot].x+pi2[1][0];s2[tot+1].y=s2[tot].y+pi2[1][1];
		s3[tot+1].x=s3[tot].x+pi2[2][0];s3[tot+1].y=s3[tot].y+pi2[2][1];
		s4[tot+1].x=s4[tot].x+pi2[3][0];s4[tot+1].y=s4[tot].y+pi2[3][1];
		tot++;
		if(s1[tot].y==y){fang=1;break;}
		if(s2[tot].x==x){fang=2;break;}
		if(s3[tot].y==y){fang=3;break;}
		if(s4[tot].x==x){fang=4;break;}
	}
	//printf("%d\n",fang);
	while(z>=0)
	{
	//	printf("%d\n",fang);
		bool flag=0;
		if(fang==1){int yu=s2[tot].x-x;if(z<=yu){printf("%d %d",y,x+z);return 0;}else x+=yu,z-=yu,fang=2,flag=1;}
		if(fang==2){int yu=y-s3[tot].y;if(z<=yu){printf("%d %d",y-z,x);return 0;}else y-=yu,z-=yu,fang=3,flag=1;}
		if(fang==3){int yu=x-s4[tot].x;if(z<=yu){printf("%d %d",y,x-z);return 0;}else x=s4[tot].x,z-=yu,fang=4,flag=1;}
		s1[tot+1].x=s1[tot].x+pi2[0][0];s1[tot+1].y=s1[tot].y+pi2[0][1];
		if(fang==4){int yu=s1[tot+1].y-y;if(z<=yu){printf("%d %d",y+z,x);return 0;}else y+=yu,z-=yu,fang=1;}
		//printf("!%d %d\n",y,x);
	
		s2[tot+1].x=s2[tot].x+pi2[1][0];s2[tot+1].y=s2[tot].y+pi2[1][1];
		s3[tot+1].x=s3[tot].x+pi2[2][0];s3[tot+1].y=s3[tot].y+pi2[2][1];
		s4[tot+1].x=s4[tot].x+pi2[3][0];s4[tot+1].y=s4[tot].y+pi2[3][1];
		
		tot++;
	}
}
/*
38 27 
7 22 24*/


發佈了159 篇原創文章 · 獲贊 3 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章