`
tulunta
  • 浏览: 359114 次
文章分类
社区版块
存档分类
最新评论

SRM 549 div2 250pt

 
阅读更多

题意:在桌子上给出三个帽子和一个小球,刚开始不知道小球在那个帽子下面,然后给出交换次数每次交换只能交换相邻的两个帽子,小球和帽子一起移动(如果小球在该帽子下面),问最后小球的位置帽子编号【0,1,2】;

这次做TC再次ORZ。。。。。。。。。还是浩哥威武,题意一说一会就能搞ORZ。。。。

#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <ctime>
using namespace std;
typedef long long ll;
#define clr(x,a) memset(x,a,sizeof(x))
#define sz(x) (int)x.size()
#define see(x) cerr<<#x<<" "<<x<<endl
#define se(x) cerr<<" "<<x 
#define pb push_back
#define mp make_pair
class BallAndHats
{
        public:
        int getHat(string hats, int numSwaps)
        {
            int i,j,k;
			for(i=0;i<hats.size();i++)
			{
			  if(hats[i]=='o')
			  {
			   k=i;break;
			  }
			}
			 
			   numSwaps;
			   if(numSwaps==0)
				   return k;
			   j=numSwaps%2;
			   if(j==0)
			   {
			      if(k==1)
					  return 1;
				  return 0;
			   }else
			   {
			     if(k==1)
					 return 0;
				 return 1;
			   }
        }
        
 
// END CUT HERE

};


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics