結果

問題 No.182 新規性の虜
ユーザー angel_p_57angel_p_57
提出日時 2016-01-17 14:53:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 700 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 26,500 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 07:43:43
合計ジャッジ時間 1,625 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 14 ms
4,376 KB
testcase_09 AC 24 ms
4,380 KB
testcase_10 AC 20 ms
4,376 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 8 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 15 ms
4,376 KB
testcase_19 AC 11 ms
4,376 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 16 ms
4,376 KB
testcase_22 AC 9 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 19 ms
4,376 KB
testcase_25 AC 9 ms
4,380 KB
testcase_26 AC 4 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
evil01.txt AC 25 ms
4,376 KB
evil02.txt AC 24 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>

using namespace std;

int a[100000];

int count(int s,int e,int b)
{
  int u1=0,u2=0,m=~(b*2-1);
  int i=s,j=e;
  while ( i<=j )
  {
    while ( i<=j&&!(a[i]&b) )
      u1|=a[i++]&m;
    while ( i<=j&& (a[j]&b) )
      u2|=a[j--]&m;
    if ( i<j )
    {
      int t=a[i];
      a[i]=a[j];
      a[j]=t;
    }
  }
  int c;
  c= j<s  ? 0 :
     j==s ? 1 :
     u1   ? count(s,j,b*2) :
            0;
  c+=i>e  ? 0 :
     i==e ? 1 :
     u2   ? count(i,e,b*2) :
            0;
  return c;
}
int main(void)
{
  int n;
  scanf("%d",&n);
  int x,i=-1,j=n;
  while ( i+1<j )
  {
    scanf("%d",&x);
    a[x&1?--j:++i]=x;
  }
  int c=count(0,i,2);
  c+=count(j,n-1,2);
  printf("%d",c);
}
0