SRM 513 div2

250pt,大水题一道,按照题目意思模拟一下就行了。

#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

class TrainingCamp
{
   public:
       vector<string> determineSolvers(vector<string> attendance, vector<string> problemTopics);
};
vector<string> TrainingCamp::determineSolvers(vector<string>a,vector<string>p)
{
	int n = a.size();
	int m = a[0].size();
	int k = p.size();
	vector<string>b;
	b.clear();
	string ant;
	ant.clear();
	int i=0,j=0,t=0;
	for(i=0;i<n;i++)
	{
	   ant.clear();
       for(j=0;j<k;j++)
	   {
		   for(t=0;t<m;t++)
		   {
			   if(p[j][t]=='-' || (p[j][t]=='X' && a[i][t]=='X'))
				   continue;
			   if(p[j][t]=='X' && a[i][t]=='-')
				   break;
		   }
		   if(t<m)
			   ant.push_back('-');
		   else
	           ant.push_back('X');
	   }
	   b.push_back(ant);
	}
	return b;
}

500pt,果断暴力,复杂度O(40000*50) .

系统测试又挂了漏了个判断左顶点的条件。

   while(l<=r-L[i] && l>B[pur])
             pur = pur+1;

==!

#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

class YetAnotherIncredibleMachine
{
   public:
       int countWays(vector<int> platformMount, vector<int> platformLength, vector<int> balls);
};

int YetAnotherIncredibleMachine::countWays(vector<int> M, vector<int> L, vector<int> B)
{
     int lenm = M.size();

     B.push_back(1000000);

	 long long ant = 1;
	 long long mod = 1000000009;
     sort(B.begin(),B.end());

	 int pur = 0;
	 for(int i=0;i<lenm;i++)
	 {
		 int l = M[i]-L[i];
		 int r = M[i]+L[i];
		 pur = 0;
		 long long sum = 0;

		 while(l<=r-L[i] && l>B[pur])
             pur = pur+1;
		 for(int j=l;j<=r-L[i];j++)
		 {
			 if(j==B[pur])
				 pur = pur+1;
			 else if(j+L[i]<B[pur])
               sum+=1;
		 }
		 ant =(ant*sum)%mod;
	 }
	 int ans = (int)ant;
	 return ans;
}

posted on 2011-07-26 21:21  lwbaptx  阅读(181)  评论(0编辑  收藏  举报

导航