結果

問題 No.3714 Prefix Team Name
コンテスト
ユーザー pengin_2000
提出日時 2026-09-18 22:11:25
言語 C
(gcc 15.3.0)
コンパイル:
gcc-15 -O2 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
TLE  
実行時間 -
コード長 2,505 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 465 ms
コンパイル使用メモリ 42,024 KB
実行使用メモリ 7,936 KB
最終ジャッジ日時 2026-09-18 22:12:15
合計ジャッジ時間 46,903 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 TLE * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:2:6: warning: conflicting types for built-in function 'strcpy'; expected 'char *(char *, const char *)' [-Wbuiltin-declaration-mismatch]
    2 | void strcpy(char t[], char s[])
      |      ^~~~~~
main.c:2:1: note: 'strcpy' is declared in header '<string.h>'
    1 | #include<stdio.h>
  +++ |+#include <string.h>
    2 | void strcpy(char t[], char s[])
main.c:12:5: warning: conflicting types for built-in function 'strcmp'; expected 'int(const char *, const char *)' [-Wbuiltin-declaration-mismatch]
   12 | int strcmp(int val1, int val2)
      |     ^~~~~~
main.c:12:5: note: 'strcmp' is declared in header '<string.h>'

ソースコード

diff #
raw source code

#include<stdio.h>
void strcpy(char t[], char s[])
{
	int i;
	for (i = 0; s[i] != '\0'; i++)
		t[i] = s[i];
	t[i] = '\0';
	return;
}
char x[6][3][55];
int len1[3], len2[3];
int strcmp(int val1, int val2)
{
	len1[2] = val1 % 64;
	val1 /= 64;
	len1[1] = val1 % 64;
	val1 /= 64;
	len1[0] = val1 % 64;
	val1 /= 64;
	len2[2] = val2 % 64;
	val2 /= 64;
	len2[1] = val2 % 64;
	val2 /= 64;
	len2[0] = val2 % 64;
	val2 /= 64;
	int id1, id2;
	id1 = id2 = 0;
	int i1, i2;
	i1 = i2 = 0;
	for (;;)
	{
		if (id1 == 3 && id2 == 3)
			return 0;
		if (id1 == 3)
			return -1;
		if (id2 == 3)
			return 1;
		if (x[val1][id1][i1] > x[val2][id2][i2])
			return 1;
		if (x[val1][id1][i1] < x[val2][id2][i2])
			return -1;
		i1++;
		if (i1 > len1[id1])
		{
			id1++;
			i1 = 0;
		}
		i2++;
		if (i2 > len2[id2])
		{
			id2++;
			i2 = 0;
		}
	}
}
int h[750005], l;
int val[750005];
int n;
int comp_h(int a, int b)
{
	return strcmp(val[h[a]], val[h[b]]);
}
void swap_h(int a, int b)
{
	int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
void push(int ne)
{
	h[l] = ne;
	int p = l++;
	for (; p > 0; p = (p - 1) / 2)
		if (comp_h((p - 1) / 2, p) > 0)
			swap_h((p - 1) / 2, p);
	return;
}
int pop()
{
	swap_h(0, --l);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2) > 0)
			{
				if (comp_h(p, 2 * p + 2) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return h[l];
}
int main()
{
	int i, j, k;
	for (i = 0; i < 3; i++)
		scanf("%s", x[0][i]);
	strcpy(x[1][0], x[0][0]);
	strcpy(x[1][1], x[0][2]);
	strcpy(x[1][2], x[0][1]);
	strcpy(x[2][0], x[0][1]);
	strcpy(x[2][1], x[0][0]);
	strcpy(x[2][2], x[0][2]);
	strcpy(x[3][0], x[0][1]);
	strcpy(x[3][1], x[0][2]);
	strcpy(x[3][2], x[0][0]);
	strcpy(x[4][0], x[0][2]);
	strcpy(x[4][1], x[0][0]);
	strcpy(x[4][2], x[0][1]);
	strcpy(x[5][0], x[0][2]);
	strcpy(x[5][1], x[0][1]);
	strcpy(x[5][2], x[0][0]);
	n = 0;
	for (l = 0; l < 6; l++)
		for (i = 0; x[l][0][i] != '\0'; i++)
			for (j = 0; x[l][1][j] != '\0'; j++)
				for (k = 0; x[l][2][k] != '\0'; k++)
					val[n++] = 64 * 64 * 64 * l + 64 * 64 * i + 64 * j + k;
	l = 0;
	for (i = 0; i < n; i++)
		push(i);
	int ans = 1;
	k = pop();
	while (l > 0)
	{
		i = pop();
		if (strcmp(val[i], val[k]) > 0)
			ans++;
		k = i;
	}
	printf("%d\n", ans);
	return 0;
}
0