【 NOIP 2014 】【 Day1 T1 】【生活大爆炸版石头剪刀布 】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/violinlove/article/details/81662128

luogu传送门

没什么好说的,题水,数据小,都提高组了,不能用 O(n) 算法写出来的,还是,,,

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

inline int wread(){
	char c(getchar ());int wans(0),flag(1);
	while (c<'0' || c>'9')	{if (c=='-') flag=-1;c=getchar ();}
	while (c>='0' && c<='9'){wans=wans*10+c-'0'; c=getchar ();}
	return wans*=flag;
}

int n,na,nb;

int A[205],B[205];

int jud(int x,int y){
	//1 x
	//2 ping
	//3 y
	if (x==y)	return 2;
	if ( (x==1 && y==0) || (x==2 && y==1) || (x==3 && y==2) || (x==4 && y==0) || (x==4 && y==1) ||( x==0 && y==2 )|| ( x==1 && y==3) || (x==0 && y==3) || (x==2 && y==4 || x==3 && y==4) )	return 1;
	return 3;	
}

int main (){
	n=wread();na=wread();nb=wread();
	for (int i(1);i<=na;++i)	A[i]=wread();
	for (int i(1);i<=nb;++i)	B[i]=wread();
	int top1(1),top2(1),cnt(1);
	int ans1(0),ans2(0);
	while (cnt<=n){
		int nx(jud(A[top1], B[top2]));
		if (nx==1) ans1++;
		else if (nx==3) ans2++;
		top1++;top2++;
		if (top1==na+1)	top1=1;
		if (top2==nb+1)	top2=1;		
		++cnt;
	}
	printf("%d %d\n",ans1,ans2);
	return 0;
}

猜你喜欢

转载自blog.csdn.net/violinlove/article/details/81662128