結果

問題 No.1190 Points
ユーザー kzyKTkzyKT
提出日時 2020-08-22 14:27:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,791 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 156,292 KB
実行使用メモリ 17,432 KB
最終ジャッジ日時 2023-08-05 11:38:10
合計ジャッジ時間 5,870 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,704 KB
testcase_01 AC 5 ms
9,500 KB
testcase_02 AC 6 ms
9,676 KB
testcase_03 AC 55 ms
13,252 KB
testcase_04 AC 39 ms
11,968 KB
testcase_05 AC 50 ms
13,900 KB
testcase_06 AC 52 ms
12,444 KB
testcase_07 AC 80 ms
15,148 KB
testcase_08 AC 100 ms
17,180 KB
testcase_09 AC 99 ms
16,304 KB
testcase_10 AC 102 ms
17,432 KB
testcase_11 AC 69 ms
14,256 KB
testcase_12 AC 94 ms
16,284 KB
testcase_13 AC 64 ms
13,480 KB
testcase_14 AC 16 ms
10,612 KB
testcase_15 AC 110 ms
15,864 KB
testcase_16 AC 12 ms
10,200 KB
testcase_17 AC 99 ms
15,552 KB
testcase_18 AC 42 ms
11,740 KB
testcase_19 AC 13 ms
10,368 KB
testcase_20 AC 57 ms
12,752 KB
testcase_21 AC 22 ms
10,792 KB
testcase_22 AC 28 ms
11,328 KB
testcase_23 AC 114 ms
15,944 KB
testcase_24 AC 115 ms
16,136 KB
testcase_25 AC 66 ms
12,760 KB
testcase_26 AC 52 ms
12,288 KB
testcase_27 AC 66 ms
12,920 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