Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

JollyJumpers/서지혜: Difference between revisions

From ZeroWiki
imported>rabierre
No edit summary
imported>rabierre
No edit summary
Line 5: Line 5:
  int count;
  int count;
  int a[3000];
  int a[3000];
  bool isJ[3000] = {false};
  bool isJ[3000];
   
   
  while(true) {
  while(true) {
Line 14: Line 14:
  scanf("%d", &a[i]);
  scanf("%d", &a[i]);
  }
  }
memset(isJ, false, 3000);
if(count == 1)
goto JOLLY;
  for(int i=1; i<count; i++){
  for(int i=1; i<count; i++){
  int index = abs(a[i]-a[i-1]);
  int index = abs(a[i]-a[i-1]);
  if(isJ[index]) {
  if(isJ[index]) {
  printf("Not jolly\n");
  goto NOT_JOLLY;
  break;
  break;
  }
  }
Line 24: Line 27:
  }
  }
   
   
  for(int i=0; i<count; i++){
  for(int i=1; i<count-1; i++){
  if(isJ[i]) continue;
  if(isJ[i]==true);
  else {
  else {
  printf("Not jolly\n");
  goto NOT_JOLLY;
break;
  }
  }
  if(i==count-1) printf("Jolly\n");
  if(i==count-2) goto JOLLY;
  }
  }
  memset(isJ, false, 3000);
  if(count==2&&isJ[1])
goto JOLLY;
NOT_JOLLY:
printf("Not jolly\n");
continue;
JOLLY:
printf("jolly\n");
continue;
  }
  }
  return 0;
  return 0;
  }
  }



Revision as of 06:59, 5 June 2011

#include <memory.h>
#include <math.h>

int main(){
	int count;
	int a[3000];
	bool isJ[3000];

	while(true) {
		if(feof(stdin))	break;
		scanf("%d", &count);
		if(feof(stdin))	break;
		for(int i=0; i<count; i++){
			scanf("%d", &a[i]);
		}
		
		memset(isJ, false, 3000);
		if(count == 1)
			goto JOLLY;
		for(int i=1; i<count; i++){
			int index = abs(a[i]-a[i-1]);
			if(isJ[index]) {
				goto NOT_JOLLY;
				break;
			}
			isJ[index] = true;
		}

		for(int i=1; i<count-1; i++){
			if(isJ[i]==true);
			else {
				goto NOT_JOLLY;
			}
			if(i==count-2) goto JOLLY;
		}
		if(count==2&&isJ[1])
			goto JOLLY;
	
NOT_JOLLY:
			printf("Not jolly\n");
			continue;
JOLLY:
			printf("jolly\n");
			continue;
	}
	return 0;
}