結果

問題 No.177 制作進行の宮森あおいです!
ユーザー asugen0402
提出日時 2019-02-05 13:40:36
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 4,678 bytes
コンパイル時間 854 ms
コンパイル使用メモリ 29,304 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2025-01-02 23:38:33
合計ジャッジ時間 1,780 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘fMain’:
main.c:135:9: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  135 |         fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:140:9: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  140 |         fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:146:17: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  146 |                 fscanf(szpFpI, "%d", &liGVal[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:151:9: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  151 |         fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:155:9: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  155 |         fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:171:17: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  171 |                 fscanf(szpFpI, "%d", &liMVal);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:176:9: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  176 |         fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:181:17: warning: ignoring return value of ‘fscanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  181 |                 fscanf(szpFpI, "%d", &liNCnt);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:186:25: warning: ignoring return value of ‘fscanf’ decla

ソースコード

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

#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
//
#define D_ON 1 // - ON
#define D_OFF 0 // - OFF
#define D_VTX_MAX 105 //
// -
typedef struct Vtx {
int mi1Cap[D_VTX_MAX]; // []
int miDone; //
} Vtx;
//
static FILE *szpFpI; //
static Vtx sz1Vtx[D_VTX_MAX]; // [0]: [1GCnt]: [GCnt+1GCnt+MCnt]: [GCnt+MCnt+1]:
static int siVCnt; //
// -
#ifdef D_TEST
static int siRes;
static FILE *szpFpA;
#endif
// - -
int
fGetMaxFlowOne(
int piVSNo // <I>
, int piVENo // <I>
, int piFlow // <I>
)
{
int i;
//
if (sz1Vtx[piVSNo].miDone != D_OFF) {
return 0;
}
sz1Vtx[piVSNo].miDone = D_ON;
//
if (piVSNo == piVENo) {
return piFlow;
}
//
for (i = 0; i < siVCnt; i++) {
//
int liFlow = sz1Vtx[piVSNo].mi1Cap[i];
if (liFlow < 1) { //
continue;
}
if (liFlow > piFlow) {
liFlow = piFlow;
}
//
liFlow = fGetMaxFlowOne(i, piVENo, liFlow);
if (liFlow < 1) { //
continue;
}
// -
sz1Vtx[piVSNo].mi1Cap[i] -= liFlow;
sz1Vtx[i].mi1Cap[piVSNo] += liFlow;
return liFlow;
}
return 0;
}
// -
int
fGetMaxFlow(
int piVSNo // <I>
, int piVENo // <I>
)
{
int i;
int liSum = 0;
while (1) {
// -
for (i = 0; i < siVCnt; i++) {
sz1Vtx[i].miDone = D_OFF;
}
// -
int liFlow = fGetMaxFlowOne(piVSNo, piVENo, INT_MAX);
if (liFlow < 1) { //
break;
}
// -
liSum += liFlow;
}
return liSum;
}
//
int
fMain(
int piTNo // <I> 1
)
{
int i, j;
char lc1Buf[1024], lc1Out[1024];
// -
memset(sz1Vtx, 0, sizeof(sz1Vtx)); //
// -
#ifdef D_TEST
sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
szpFpI = fopen(lc1Buf, "r");
sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
szpFpA = fopen(lc1Buf, "r");
siRes = 0;
#else
szpFpI = stdin;
#endif
// -
int liCCnt;
fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
sscanf(lc1Buf, "%d", &liCCnt);
// -
int liGCnt;
fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
sscanf(lc1Buf, "%d", &liGCnt);
// -
int liGVal[D_VTX_MAX];
for (i = 0; i < liGCnt; i++) {
fscanf(szpFpI, "%d", &liGVal[i]);
// ->
sz1Vtx[0].mi1Cap[i + 1] = liGVal[i];
}
fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
// -
int liMCnt;
fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
sscanf(lc1Buf, "%d", &liMCnt);
//
siVCnt = liGCnt + liMCnt + 2;
// ->
for (i = 0; i < liGCnt; i++) {
for (j = 0; j < liMCnt; j++) {
sz1Vtx[i + 1].mi1Cap[liGCnt + j + 1] = liGVal[i];
}
}
// -
for (i = 0; i < liMCnt; i++) {
int liMVal;
fscanf(szpFpI, "%d", &liMVal);
// ->
sz1Vtx[liGCnt + i + 1].mi1Cap[siVCnt - 1] = liMVal;
}
fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
// -
for (i = 0; i < liMCnt; i++) {
int liNCnt;
fscanf(szpFpI, "%d", &liNCnt);
// -
for (j = 0; j < liNCnt; j++) {
int liNVal;
fscanf(szpFpI, "%d", &liNVal);
// -> -
sz1Vtx[liNVal].mi1Cap[liGCnt + i + 1] = 0;
}
fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
}
// -
int liMax = fGetMaxFlow(0, siVCnt - 1);
// -
if (liMax >= liCCnt) {
sprintf(lc1Out, "SHIROBAKO\n");
}
else {
sprintf(lc1Out, "BANSAKUTSUKITA\n");
}
// -
#ifdef D_TEST
fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
if (strcmp(lc1Buf, lc1Out)) {
siRes = -1;
}
#else
printf("%s", lc1Out);
#endif
//
#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", piTNo);
}
else {
printf("NG %d\n", piTNo);
}
#endif
return 0;
}
int
main()
{
#ifdef D_TEST
int i;
for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
fMain(i);
}
#else
fMain(0);
#endif
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0