結果

問題 No.497 入れ子の箱
ユーザー asugen0402
提出日時 2019-04-11 17:22:47
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 3,657 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 32,512 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 01:30:22
合計ジャッジ時間 1,701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
//
#define D_BOX_MAX 1000 //
#define D_DIM_CNT 3 //
// -
typedef struct Box {
int mi1Len[D_DIM_CNT]; //
int miBCnt; //
} Box;
//
static FILE *szpFpI; //
static Box sz1Box[D_BOX_MAX]; //
static int siBCnt; //
// -
#ifdef D_TEST
static int siRes;
static FILE *szpFpA;
static int siTNo;
#endif
//
int
fOut(
char *pcpLine // <I>
)
{
char lc1Buf[1024];
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
if (strcmp(lc1Buf, pcpLine)) {
siRes = -1;
}
#else
printf("%s", pcpLine);
#endif
return 0;
}
// - int
int
fSortFncIu(
const void *pzpVal1 // <I>
, const void *pzpVal2 // <I>
)
{
int *lipVal1 = (int *)pzpVal1;
int *lipVal2 = (int *)pzpVal2;
// int
if (*lipVal1 > *lipVal2) {
return 1;
}
else if (*lipVal1 < *lipVal2) {
return -1;
}
return 0;
}
// - [0]
int
fSortFncLu(
const void *pzpVal1 // <I>
, const void *pzpVal2 // <I>
)
{
Box *lzpVal1 = (Box *)pzpVal1;
Box *lzpVal2 = (Box *)pzpVal2;
// [0]
if (lzpVal1->mi1Len[0] > lzpVal2->mi1Len[0]) {
return 1;
}
else if (lzpVal1->mi1Len[0] < lzpVal2->mi1Len[0]) {
return -1;
}
return 0;
}
//
int
fMain(
)
{
int i, j, k;
char lc1Buf[1024];
// -
fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
sscanf(lc1Buf, "%d", &siBCnt);
// -
for (i = 0; i < siBCnt; i++) {
for (j = 0; j < D_DIM_CNT; j++) {
fscanf(szpFpI, "%d", &sz1Box[i].mi1Len[j]);
}
fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
// -
qsort(sz1Box[i].mi1Len, D_DIM_CNT, sizeof(int), fSortFncIu);
}
// -
qsort(sz1Box, siBCnt, sizeof(Box), fSortFncLu);
// -
for (i = 0; i < siBCnt - 1; i++) {
for (j = 0; j < siBCnt; j++) {
//
for (k = 0; k < D_DIM_CNT; k++) {
if (sz1Box[i].mi1Len[k] >= sz1Box[j].mi1Len[k]) {
break;
}
}
if (k < D_DIM_CNT) {
continue;
}
// -
int liBCnt = sz1Box[i].miBCnt + 1;
if (sz1Box[j].miBCnt < liBCnt) {
sz1Box[j].miBCnt = liBCnt;
}
}
}
// -
int liMax = 0;
for (i = 0; i < siBCnt; i++) {
if (liMax < sz1Box[i].miBCnt) {
liMax = sz1Box[i].miBCnt;
}
}
return liMax + 1;
}
//
int
fOne(
)
{
int liRet;
char lc1Buf[1024];
// -
memset(sz1Box, 0, sizeof(sz1Box)); //
// -
#ifdef D_TEST
sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
szpFpI = fopen(lc1Buf, "r");
sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
szpFpA = fopen(lc1Buf, "r");
siRes = 0;
#else
szpFpI = stdin;
#endif
//
liRet = fMain();
//
sprintf(lc1Buf, "%d\n", liRet);
fOut(lc1Buf);
//
#ifdef D_TEST
lc1Buf[0] = '\0';
fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
if (strcmp(lc1Buf, "")) {
siRes = -1;
}
#endif
//
#ifdef D_TEST
fclose(szpFpI);
fclose(szpFpA);
#endif
//
#ifdef D_TEST
if (siRes == 0) {
printf("OK %d\n", siTNo);
}
else {
printf("NG %d\n", siTNo);
}
#endif
return 0;
}
//
int
main()
{
#ifdef D_TEST
int i;
for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
siTNo = i;
fOne();
}
#else
fOne();
#endif
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0