結果
問題 |
No.1576 織姫と彦星
|
ユーザー |
|
提出日時 | 2021-06-30 09:14:37 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 444 bytes |
コンパイル時間 | 632 ms |
コンパイル使用メモリ | 75,772 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 11:16:07 |
合計ジャッジ時間 | 2,440 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 54 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<queue> using namespace std; int N; int A[1002],d[1002]; main() { cin>>N>>A[0]; cin>>A[N+1]; for(int i=1;i<=N;i++)cin>>A[i]; queue<int>P; P.push(0); for(int i=1;i<=N+1;i++)d[i]=1e9; while(!P.empty()) { int u=P.front();P.pop(); for(int j=0;j<=N+1;j++)if(d[j]>d[u]+1&&__builtin_popcount(A[j]^A[u])<=1) { d[j]=d[u]+1; P.push(j); } } int ans=d[N+1]; if(ans==(int)1e9)ans=0; cout<<ans-1<<endl; }