SRM 513 div2

2316 단어 div
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;

}

좋은 웹페이지 즐겨찾기