結果
問題 | No.182 新規性の虜 |
ユーザー |
![]() |
提出日時 | 2016-01-17 14:53:20 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 28 ms / 5,000 ms |
コード長 | 700 bytes |
コンパイル時間 | 1,072 ms |
コンパイル使用メモリ | 23,680 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 20:11:39 |
合計ジャッジ時間 | 2,053 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:38:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 38 | scanf("%d",&n); | ~~~~~^~~~~~~~~ main.cpp:42:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d",&x); | ~~~~~^~~~~~~~~
ソースコード
#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); }