結果
| 問題 |
No.99 ジャンピング駒
|
| コンテスト | |
| ユーザー |
NEEHATOV
|
| 提出日時 | 2020-06-06 05:54:38 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,064 bytes |
| コンパイル時間 | 1,387 ms |
| コンパイル使用メモリ | 30,336 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-21 16:12:45 |
| 合計ジャッジ時間 | 3,811 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 6 |
コンパイルメッセージ
main.c: In function 'Array_Collect':
main.c:9:21: warning: comparison between pointer and integer
9 | if ((tmp[i] != NULL)) {
| ^~
main.c: In function 'Array_Jump':
main.c:22:20: warning: assignment to 'int' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
22 | tmp[i] = NULL; tmp[i + 1] = NULL;
| ^
main.c:22:39: warning: assignment to 'int' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
22 | tmp[i] = NULL; tmp[i + 1] = NULL;
| ^
main.c: In function 'main':
main.c:30:25: warning: initialization of 'int' from 'void *' makes integer from pointer without a cast [-Wint-conversion]
30 | int tmp[20][100] = {NULL};
| ^~~~
main.c:30:25: note: (near initialization for 'tmp[0][0]')
ソースコード
#include <stdio.h>
#include <stdlib.h>
int Array_Collect(const int N, int tmp[], int tmp2[])
{
// 残っている数字をtmp配列にまとめる
int j = 0,cnt = 0;
for (int i = 0; i < N ; i++) {
if ((tmp[i] != NULL)) {
tmp2[j++] = tmp[i];
cnt++;
}
}
return cnt;
}
void Array_Jump(const int N, int tmp[])
{
for (int i = 0; i < N; i++) {
// 奇数偶数で隣り合うものを消去
if ((tmp[i] % 2 == 0 && tmp[i + 1] % 2 != 0) ||
(tmp[i] % 2 != 0 && tmp[i + 1] % 2 == 0)) {
tmp[i] = NULL; tmp[i + 1] = NULL;
i++;
}
}
}
int main() {
int i = 0, j = 0, N;
int tmp[20][100] = {NULL};
scanf("%d", &N);
int cnt = N - 1;
for (i = 0; i < N ; i++) {
scanf("%d", &tmp[0][i]);
}
i = 0;
while (j++ < 10)
{
if (cnt > 1) {
Array_Jump(cnt-1, tmp[i]);
cnt = Array_Collect(N, tmp[i], tmp[i+1]);
i++;
}
}
printf("%d\n", cnt);
return 0;
}
NEEHATOV