結果

問題 No.360 増加門松列
ユーザー notetonousnotetonous
提出日時 2016-04-18 00:21:00
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 733 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 21,760 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 02:54:29
合計ジャッジ時間 665 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 0 ms
6,944 KB
testcase_12 WA -
testcase_13 AC 0 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 0 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:27:19: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |   for(i=0;i<7;i++)scanf("%d",&d[i]);
      |                   ^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>
int next_perm(int *p, int n)
{
  int i, j, k, tmp;
  for(i = n - 1; i > 0 && p[i-1] >= p[i]; i--);
  if(i == 0) return 0;
  for(j = n - 1; j > i && p[i-1] >= p[j]; j--);
  tmp = p[i-1], p[i-1] = p[j], p[j] = tmp;
  for(k = 0; k <= ((n-1)-i)/2; k++)
    tmp = p[i+k], p[i+k] = p[(n-1)-k], p[(n-1)-k] = tmp;
  return 1;
}

int check(int a[7]){
  int i;
 for(i=0;i<5;i++){
    if(a[i]<a[i+2]){
      if( ( a[i] < a[i+1] && a[i+1] > a[i+2] ) || ( a[i] > a[i+1] ||  a[i+1] < a[i+2] ) ) return 0;
    }
 }
 return 1;  
}

int main(){
  int i,j;
  int d[7];
  for(i=0;i<7;i++)scanf("%d",&d[i]);

  while(next_perm(d, 7)){
    if(check(d)==1){
    printf("YES\n");
    return 0;
    }
  }
  printf("NO\n");
  return 0;
}

0