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

Re:你有病哪!现在都啥时候了!还卖代码!

Posted by zjufan at 2012-08-05 17:20:43 on Problem 1002
In Reply To:你有病哪!现在都啥时候了!还卖代码! Posted by:BAD_GUY at 2012-08-05 16:30:28
为了100ms,整整搞了我2个月呢!

骂别人有病,你有种也给我整个出来?

1秒的代码谁要,我白送好了

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

char pn[100000][8];

int main ()
{
  int i, j, n, c;
  int none = 1;

  scanf ("%d", &n);
  for (i = 0; i < n; i++)
    {
      j = 0;
      while (j < 7)
	{
	  if (!isalnum (c = getchar ())) continue;
	  if (c == 'A' || c == 'B' || c == 'C') c = '2';
	  if (c == 'D' || c == 'E' || c == 'F') c = '3';
	  if (c == 'G' || c == 'H' || c == 'I') c = '4';
	  if (c == 'J' || c == 'K' || c == 'L') c = '5';
	  if (c == 'M' || c == 'N' || c == 'O') c = '6';
	  if (c == 'P' || c == 'R' || c == 'S') c = '7';
	  if (c == 'T' || c == 'U' || c == 'V') c = '8';
	  if (c == 'W' || c == 'X' || c == 'Y') c = '9';
	  pn[i][j++] = c;
	}
      pn[i][7] = '\0';
    }

  qsort (pn, n, 8, (int (*) (const void *, const void *)) strcmp);

  j = 0;
  for (i = 1; i < n; i++)
  {
    if (strcmp (pn[i], pn[j]) != 0)
      {
	if (i - j > 1)
	  {
	    printf (
	      "%c%c%c-%s %d\n", pn[j][0], pn[j][1], pn[j][2], pn[j] + 3, i - j
	    );
	    none = 0;
	  }
	j = i;
      }
  }
  if (i - j > 1)
    {
      printf (
	"%c%c%c-%s %d\n", pn[j][0], pn[j][1], pn[j][2], pn[j] + 3, i - j
      );
      none = 0;
    }
  if (none)
    printf ("No duplicates.\n");
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