結果

問題 No.1190 Points
ユーザー 👑 kmjpkmjp
提出日時 2020-08-22 14:01:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 1,540 bytes
コンパイル時間 2,483 ms
コンパイル使用メモリ 204,120 KB
実行使用メモリ 13,360 KB
最終ジャッジ日時 2024-04-23 08:27:37
合計ジャッジ時間 6,749 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,392 KB
testcase_01 AC 4 ms
8,288 KB
testcase_02 AC 4 ms
8,408 KB
testcase_03 AC 90 ms
12,408 KB
testcase_04 AC 55 ms
12,100 KB
testcase_05 AC 106 ms
11,260 KB
testcase_06 AC 58 ms
12,612 KB
testcase_07 AC 141 ms
13,184 KB
testcase_08 AC 187 ms
13,360 KB
testcase_09 AC 175 ms
12,972 KB
testcase_10 AC 186 ms
13,352 KB
testcase_11 AC 121 ms
12,100 KB
testcase_12 AC 165 ms
13,252 KB
testcase_13 AC 107 ms
11,544 KB
testcase_14 AC 16 ms
10,516 KB
testcase_15 AC 180 ms
12,764 KB
testcase_16 AC 11 ms
9,924 KB
testcase_17 AC 158 ms
12,692 KB
testcase_18 AC 62 ms
10,436 KB
testcase_19 AC 12 ms
10,696 KB
testcase_20 AC 89 ms
11,428 KB
testcase_21 AC 20 ms
10,328 KB
testcase_22 AC 26 ms
11,584 KB
testcase_23 AC 183 ms
13,256 KB
testcase_24 AC 183 ms
12,996 KB
testcase_25 AC 64 ms
12,612 KB
testcase_26 AC 53 ms
12,676 KB
testcase_27 AC 64 ms
12,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,P;
int S,G;
vector<int> E[202020];
int D[101010][2][2];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M>>P;
	cin>>S>>G;
	S--,G--;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	FOR(i,N) D[i][0][0]=D[i][1][0]=D[i][0][1]=D[i][1][1]=(1<<30)-1;
	queue<int> Q;
	D[S][0][0]=D[G][1][0]=0;
	Q.push(S*4);
	Q.push(G*4+2);
	while(Q.size()) {
		int cur=Q.front()/4;
		int id=Q.front()/2%2;
		int odd=Q.front()%2;
		int co=D[cur][id][odd]+1;
		Q.pop();
		FORR(e,E[cur]) if(D[e][id][odd^1]>co) {
			D[e][id][odd^1]=co;
			Q.push(e*4+id*2+(odd^1));
		}
	}
	
	vector<int> V;
	FOR(i,N) {
		int ok=0;
		FOR(x,2) FOR(y,2) {
			ll co=D[i][0][x]+D[i][1][y];
			if(co<=P&&(P-co)%2==0) ok=1;
			
		}
		if(ok) V.push_back(i);
	}
	
	if(V.empty()) {
		cout<<-1<<endl;
	}
	else {
		cout<<V.size()<<endl;
		FORR(v,V) cout<<v+1<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0