結果
| 問題 | No.182 新規性の虜 |
| コンテスト | |
| ユーザー |
angel_p_57
|
| 提出日時 | 2016-01-17 14:59:40 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 30 ms / 5,000 ms |
| コード長 | 761 bytes |
| 記録 | |
| コンパイル時間 | 1,233 ms |
| コンパイル使用メモリ | 56,272 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 20:16:42 |
| 合計ジャッジ時間 | 1,914 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <iostream>
#pragma GCC optimize("O3")
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)
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
int i=-1,j=n;
while ( i+1<j )
{
int x;
cin>>x;
a[x&1?--j:++i]=x;
}
int c=count(0,i,2);
c+=count(j,n-1,2);
cout<<c;
}
angel_p_57