Submission #67652483


Source Code Expand

Copy
#include <stdio.h>
#include <stdlib.h>
int cmp(const void* x, const void* y) {
int a = *(const int*)x, b = *(const int*)y;
return a < b ? -1 : a > b;
}
int cmpk(const void* x, const void* y) {
return cmp(y, x);
}
int N;
int A[212345];
int buf1s, buf2s;
int buf1[212345], buf2[212345];
int sort(void) {
qsort(A, N, sizeof(*A), cmp);
return 1;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <stdio.h>
#include <stdlib.h>

int cmp(const void* x, const void* y) {
	int a = *(const int*)x, b = *(const int*)y;
	return a < b ? -1 : a > b;
}

int cmpk(const void* x, const void* y) {
	return cmp(y, x);
}

int N;
int A[212345];

int buf1s, buf2s;
int buf1[212345], buf2[212345];

int sort(void) {
	qsort(A, N, sizeof(*A), cmp);
	return 1;
}

void foo(void) {
	int i;
	buf1s = 0;
	buf2s = 0;
	for (i = 0; i < N; i++) {
		if (A[i] >= 0) buf1[buf1s++] = A[i]; else buf2[buf2s++] = A[i];
	}
	if (buf1s > 0) qsort(buf1, buf1s, sizeof(*buf1), cmp);
	if (buf2s > 0) qsort(buf2, buf2s, sizeof(*buf2), cmpk);
}

/* プラスとマイナスを交互に、プラスから */
int hoge(void) {
	int i;
	foo();
	if (buf1s != buf2s && buf1s != buf2s + 1) return 0;
	for (i = 0; i < buf2s; i++) {
		A[i * 2] = buf1[i];
		A[i * 2 + 1] = buf2[i];
	}
	if (buf1s > buf2s) A[buf2s * 2] = buf1[buf2s];
	return 1;
}

/* プラスとマイナスを交互に、マイナスから */
int fuga(void) {
	int i;
	foo();
	if (buf1s != buf2s && buf1s + 1!= buf2s) return 0;
	for (i = 0; i < buf2s; i++) {
		A[i * 2] = buf2[i];
		A[i * 2 + 1] = buf1[i];
	}
	if (buf1s < buf2s) A[buf1s * 2] = buf2[buf1s];
	return 1;
}

int judge(int (*func)(void)) {
	int i;
	int ok = 1;
	if (!func()) return 0;
	for (i = 2; ok && i < N; i++) {
		/* A[i - 1] / A[i - 2] == A[i] / A[i - 1] */
		ok = (long long)A[i - 1] * A[i - 1] == (long long)A[i] * A[i - 2];
	}
	return ok;
}

int main(void) {
	int T, tc;
	if (scanf("%d", &T) != 1) return 1;
	for (tc = 0; tc < T; tc++) {
		int i;
		if (scanf("%d", &N) != 1) return 1;
		for (i = 0; i < N; i++) {
			if (scanf("%d", &A[i]) != 1) return 1;
		}
		puts(judge(sort) || judge(hoge) || judge(fuga) ? "Yes" : "No");
	}
	return 0;
}

Submission Info

Submission Time
Task D - Make Geometric Sequence
User mikecat
Language C (gcc 12.2.0)
Score 425
Code Size 1826 Byte
Status AC
Exec Time 53 ms
Memory 3504 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 1
AC × 32
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 02_handmade_31.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 1632 KiB
01_random_01.txt AC 17 ms 1612 KiB
01_random_02.txt AC 48 ms 2804 KiB
01_random_03.txt AC 52 ms 3252 KiB
01_random_04.txt AC 36 ms 1628 KiB
01_random_05.txt AC 40 ms 2296 KiB
01_random_06.txt AC 9 ms 1588 KiB
01_random_07.txt AC 21 ms 2580 KiB
01_random_08.txt AC 35 ms 1508 KiB
01_random_09.txt AC 36 ms 1656 KiB
01_random_10.txt AC 20 ms 1532 KiB
01_random_11.txt AC 46 ms 2660 KiB
01_random_12.txt AC 35 ms 1632 KiB
01_random_13.txt AC 35 ms 1632 KiB
01_random_14.txt AC 35 ms 1628 KiB
01_random_15.txt AC 38 ms 1896 KiB
01_random_16.txt AC 35 ms 1508 KiB
01_random_17.txt AC 36 ms 1632 KiB
01_random_18.txt AC 27 ms 1612 KiB
01_random_19.txt AC 34 ms 3504 KiB
01_random_20.txt AC 16 ms 1624 KiB
01_random_21.txt AC 47 ms 2772 KiB
01_random_22.txt AC 36 ms 1680 KiB
01_random_23.txt AC 22 ms 1628 KiB
01_random_24.txt AC 53 ms 3404 KiB
01_random_25.txt AC 36 ms 1620 KiB
01_random_26.txt AC 36 ms 1628 KiB
01_random_27.txt AC 32 ms 1908 KiB
01_random_28.txt AC 47 ms 2848 KiB
01_random_29.txt AC 35 ms 1652 KiB
01_random_30.txt AC 20 ms 1848 KiB
02_handmade_31.txt AC 1 ms 1664 KiB


2025-07-17 (Thu)
07:29:53 +09:00