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

这都TLE?

Posted by wstc_asm at 2012-03-25 01:56:00 on Problem 3264
#include <stdio.h>

int p[50040];
int main() {
  int n, q;
  int i, j;
  scanf("%d%d", &n, &q);
  for (i=0; i<n; ++i)
    scanf("%d", &p[i]);
//  for (i=0; i<n; ++i)
//    printf("%d %d\n", i, p[i]);

  int min = 0;
  int max = 0;
  int *src;
  int *dest;
  while (q--) {

  scanf("%d%d", &i, &j);
  --i, --j;
//  printf ("%dx %d\n", i, j );
  min = p[i];
  max = p[i];
  src = p + i;
  dest = p + j;
//  printf ("src%d dest%d\n", int(src), int(dest));
  __asm__ __volatile__ (
    "s:"
    "cmpl (%0), %2;"
    "jle s1;"
    "movl (%0), %2;"
    "s1:"
    "cmpl (%0), %3;"
    "jge s2;"
    "movl (%0), %3;"
    "s2:"
    "addl $4, %0;"
    "cmpl %0, %1;"
    "jge s;"
    : "=r"(src), "=r"(dest), "=r"(min), "=r"(max)
    : "0"(src), "1"(dest), "2"(min), "3"(max)
    : "memory");
  /*
    for (int k =0; k<n; ++k)
      printf("%d ", p[k]);
    puts("");
    printf("xxx%d %d %d %d\n", i, j, int(src), int(dest));
    */
//    printf ("xxx%d %d\n", min, max);
    printf ("%d\n", max - min);
  }
  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