結果
| 問題 | No.182 新規性の虜 |
| コンテスト | |
| ユーザー |
angel_p_57
|
| 提出日時 | 2016-01-17 14:53:20 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 5,000 ms |
| コード長 | 700 bytes |
| 記録 | |
| コンパイル時間 | 270 ms |
| コンパイル使用メモリ | 40,064 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-01 16:06:40 |
| 合計ジャッジ時間 | 1,679 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#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);
}
angel_p_57