Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

不是吧,没用那么多哦

Posted by dawei007 at 2010-05-05 11:21:56 on Problem 1318
In Reply To:这是我见过使用STL最充分的题 Posted by:blablabla at 2006-12-16 16:50:51
//by David
#include "cstdlib"
#include "cctype"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "algorithm"
#include "vector"
#include "string"
#include "iostream"
#include "sstream"
#include "set"
#include "queue"
#include "stack"
#include "fstream"
#include "strstream"
using namespace std;

typedef __int64 LL;		//scanf("%I64d", &x);
typedef vector<int> VI;
typedef pair<int,int> PII;
#define MP				make_pair
#define FOR(i,a)			for( int i = 0 ; i < a ; i ++ )
#define LL(a)				a<<1		//a=a*2   LL和RR主要用于线段树
#define RR(a)				a<<1|1		//a=a*2+1
const double Pi = acos(-1.0);
template<class T> inline void checkmmin(T &a,T b)	{if(a < 0 || a > b)a = b;}
template<class T> inline void checkmax(T &a,T b)	{if(a < b)	a = b;}
int dx[] = {-1,0,1,0,1,1,-1,-1};//up Right down Left
int dy[] = {0,1,0,-1,1,-1,1,-1};//复制strcpy和strncpy  //strstr查找子串;strrev对字符串反序 //strncpy后加'\0' 
//-----------------------------------------------------------------

string str[100];
unsigned char a[100][27];
int main()
{
	int i,j,n;
	memset(a,0,sizeof a);
	i=0;
	while(cin>>str[i])
	{
		if(str[i]=="XXXXXX")	break;
		i++;
	}
	n=i;
	sort(str,str+n);
	for(i=0;i<n;i++)
		for(j=0;j<str[i].length();j++)
			a[i][ str[i][j]-'a' ]++;
	
	string s;
	while(cin>>s)
	{
		if(s=="XXXXXX")	break;
		unsigned char b[27];
		memset(b,0,sizeof b);
		for(j=0;j<s.length();j++)
			b[s[j]-'a']++;

		bool f=1;
		for(i=0;i<n;i++)
		{
			if(s.length()==str[i].length())
			{
				for(j=0;j<27;j++)
					if(a[i][j]!=b[j])
						break;
				if(j==27)
				{	
					f=0;
					cout<<str[i]<<endl;
				}
			}
		}
		if(f)
		{
			cout<<"NOT A VALID WORD"<<endl;
		}	
		cout<<"******"<<endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator