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

why WA

Posted by direfire at 2006-10-23 01:23:59 on Problem 3007
#include <iostream> 
#include <sstream> 
#include <string> 
#include <vector> 
#include <set> 
#include <map> 
#include <algorithm> 
#include <cstdio> 
#include <cstdlib> 
#include <cmath>
#include <math.h>
#include <string.h>
#include <stdlib.h>
using namespace std; 

#define REP(i, n) for(int i = 0; i<(n); i++) 
#define abs(a) ((a) >= 0 ? (a) : -(a)) 
#define inf 999999999 
typedef vector<int> VI; 
typedef vector<string> VS; 
typedef long long i64; 
typedef unsigned long long u64;

char buf[75];

void go()
{
	int n = strlen(buf);
	VS v;
	for (int i = 1; i < n; i++)
	{	
		int k = n - i;
		string a, a1, b, b1;
		for (int j = 0; j < i; j++)
		{
			a.push_back(buf[j]);
			a1.push_back(buf[i-1-j]);
		}
		for (int j = i; j < n; j++)
		{
			b.push_back(buf[j]);
			b1.push_back(buf[n-1-(j-i)]);	
		}
		v.push_back(a+b);
		v.push_back(b+a);
		v.push_back(b+a1);
		v.push_back(a1+b);
		v.push_back(a1+b1);
		v.push_back(a+b1);
		v.push_back(b1+a1);
		v.push_back(b1+a);
	}
	int res = 0;
	string tt;
	sort(v.begin(), v.end());
	for (int i = 1; i < v.size(); i++)
		if (v[i] != tt) { res++; tt = v[i]; }	
	printf("%d\n", res);
	
}

int main()
{
	int T;
	cin>>T;
	for (int i = 0; i < T; i++)
	{
		scanf("%s", &buf);
		go();
	};
	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