結果

問題 No.1190 Points
ユーザー kzyKTkzyKT
提出日時 2020-08-22 14:27:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 96 ms / 2,000 ms
コード長 1,791 bytes
コンパイル時間 1,560 ms
コンパイル使用メモリ 171,056 KB
実行使用メモリ 17,240 KB
最終ジャッジ日時 2024-04-23 08:48:19
合計ジャッジ時間 4,189 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
9,424 KB
testcase_01 AC 5 ms
9,436 KB
testcase_02 AC 4 ms
9,556 KB
testcase_03 AC 43 ms
13,252 KB
testcase_04 AC 34 ms
12,044 KB
testcase_05 AC 44 ms
13,984 KB
testcase_06 AC 45 ms
12,412 KB
testcase_07 AC 66 ms
15,116 KB
testcase_08 AC 93 ms
17,240 KB
testcase_09 AC 91 ms
16,316 KB
testcase_10 AC 95 ms
17,168 KB
testcase_11 AC 62 ms
14,276 KB
testcase_12 AC 84 ms
16,236 KB
testcase_13 AC 59 ms
13,372 KB
testcase_14 AC 13 ms
10,588 KB
testcase_15 AC 93 ms
15,760 KB
testcase_16 AC 9 ms
9,976 KB
testcase_17 AC 80 ms
15,276 KB
testcase_18 AC 37 ms
11,724 KB
testcase_19 AC 10 ms
10,232 KB
testcase_20 AC 50 ms
12,736 KB
testcase_21 AC 17 ms
10,636 KB
testcase_22 AC 20 ms
11,344 KB
testcase_23 AC 96 ms
15,916 KB
testcase_24 AC 90 ms
15,964 KB
testcase_25 AC 43 ms
12,744 KB
testcase_26 AC 33 ms
12,336 KB
testcase_27 AC 44 ms
12,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

ll d[2][111111][2];
vector<int> v[111111];
void bfs(int s,int k) {
  queue<P> que;
  que.push(P(s,0));
  d[k][s][0]=0;
  while(!que.empty()) {
    P p=que.front();que.pop();
    int x=p.F,c=p.S;
    rep(i,v[x].size()) {
      int y=v[x][i];
      if(d[k][y][(c+1)%2]==-1) {
        d[k][y][(c+1)%2]=d[k][x][c]+1;
        que.push(P(y,(c+1)%2));
      }
    }
  }
}

void Main() {
  ll n,m,k,s,t;
  cin >> n >> m >> k >> s >> t;
  s--,t--;
  rep(i,m) {
    int x,y;
    cin >> x >> y;
    x--,y--;
    v[x].pb(y);
    v[y].pb(x);
  }
  memset(d,-1,sizeof(d));
  bfs(s,0);
  bfs(t,1);
  set<int> se;
  rep(i,n) {
    rep(l,2) {
      rep(r,2) {
        if(d[0][i][l]!=-1&&d[1][i][r]!=-1&&d[0][i][l]+d[1][i][r]<=k&&(l+r)%2==k%2) se.in(i);
      }
    }
  }
  if(!se.size()) {
    pr(-1);
    return;
  }
  pr(se.size());
  tr(it,se) pr(*it+1);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}
0