結果
| 問題 | No.3714 Prefix Team Name |
| コンテスト | |
| ユーザー |
pengin_2000
|
| 提出日時 | 2026-09-18 22:28:43 |
| 言語 | C (gcc 15.3.0) |
| 結果 |
TLE
不安定
|
| 実行時間 | - |
| コード長 | 2,667 bytes |
| 記録 | |
| コンパイル時間 | 1,147 ms |
| コンパイル使用メモリ | 39,424 KB |
| 実行使用メモリ | 13,568 KB |
| 最終ジャッジ日時 | 2026-09-18 22:29:33 |
| 合計ジャッジ時間 | 48,188 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 13 -- * 9 |
コンパイルメッセージ
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>'
ソースコード
#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 l1 = len1[0] + len1[1] + len1[2];
int l2 = len2[0] + len2[1] + len2[2];
if (l1 > l2)
return 1;
if (l1 < l2)
return -1;
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[3000006], l;
int comp_h(int a, int b)
{
return strcmp(h[a], 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]);
l = 0;
for (i = 0; i < 6; i++)
push(64 * 64 * 64 * i);
int ans = 1, id;
int pre = pop();
push(pre);
while (l > 0)
{
i = pop();
if (strcmp(i, pre) > 0)
ans++;
pre = i;
id = pre;
k = id % 64;
id /= 64;
j = id % 64;
id /= 64;
i = id % 64;
id /= 64;
if (x[id][0][i + 1] != '\0')
push(pre + 64 * 64);
if (x[id][1][j + 1] != '\0')
push(pre + 64);
if (x[id][2][k + 1] != '\0')
push(pre + 1);
}
printf("%d\n", ans);
return 0;
}
pengin_2000