U E D R , A S I H C RSS

Jolly Jumpers/서지혜

Difference between r1.2 and the current

@@ -1,3 +1,4 @@
* 왜 Accept가 안되나 했더니 검사하는 부분에서 count-1이어서......
{{{#include <stdio.h>
#include <memory.h>
#include <math.h>
@@ -5,6 +6,58 @@
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; i++){
if(isJ[i]==true);
else {
goto NOT_JOLLY;
}
if(i==count-1) goto JOLLY;
}
if(count==2&&isJ[1])
goto JOLLY;
NOT_JOLLY:
printf("Not jolly\n");
continue;
JOLLY:
printf("jolly\n");
continue;
}
return 0;
}
}}}
 
---
{{{
#include <stdio.h>
#include <memory.h>
#include <math.h>
 
int main(){
int count;
int a[3000];
bool isJ[3000] = {false};

while(true) {
@@ -15,23 +68,25 @@
scanf("%d", &a[i]);
}

bool F=1;
for(int i=1; i<count; i++){
int index = abs(a[i]-a[i-1]);
if(isJ[index]) {
printf("Not jolly\n");
F=0;
break;
}
isJ[index] = true;
}

for(int i=0; i<count; i++){
for(int i=1; i<count; i++){
if(isJ[i]) continue;
else {
printf("Not jolly\n");
F=0;
break;
}
if(i==count-1) printf("Jolly\n");
}
puts(F?"Jolly":"Not jolly");
memset(isJ, false, 3000);
}
return 0;


* 왜 Accept가 안되나 했더니 검사하는 부분에서 count-1이어서......
#include <stdio.h>
#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; i++){
			if(isJ[i]==true);
			else {
				goto NOT_JOLLY;
			}
			if(i==count-1) goto JOLLY;
		}
		if(count==2&&isJ[1])
			goto JOLLY;
	
NOT_JOLLY:
			printf("Not jolly\n");
			continue;
JOLLY:
			printf("jolly\n");
			continue;
	}
	return 0;
}

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

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

	while(true) {
		if(feof(stdin))	break;
		scanf("%d", &count);
		if(feof(stdin))	break;
		for(int i=0; i<count; i++){
			scanf("%d", &a[i]);
		}

		bool F=1;
		for(int i=1; i<count; i++){
			int index = abs(a[i]-a[i-1]);
			if(isJ[index]) {
				F=0;
				break;
			}
			isJ[index] = true;
		}

		for(int i=1; i<count; i++){
			if(isJ[i]) continue;
			else {
				F=0;
				break;
			}

		}
		puts(F?"Jolly":"Not jolly");
		memset(isJ, false, 3000);
	}
	return 0;
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:34
Processing time 0.0250 sec