結果

問題 No.1190 Points
ユーザー 👑 kmjpkmjp
提出日時 2020-08-22 13:58:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,539 bytes
コンパイル時間 2,273 ms
コンパイル使用メモリ 203,404 KB
実行使用メモリ 13,384 KB
最終ジャッジ日時 2024-04-23 08:24:00
合計ジャッジ時間 6,630 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,644 KB
testcase_01 WA -
testcase_02 AC 4 ms
8,172 KB
testcase_03 AC 87 ms
12,152 KB
testcase_04 AC 49 ms
11,972 KB
testcase_05 WA -
testcase_06 AC 54 ms
12,740 KB
testcase_07 WA -
testcase_08 AC 184 ms
13,128 KB
testcase_09 AC 171 ms
12,992 KB
testcase_10 AC 188 ms
13,324 KB
testcase_11 AC 121 ms
12,020 KB
testcase_12 AC 170 ms
13,184 KB
testcase_13 AC 103 ms
11,128 KB
testcase_14 WA -
testcase_15 AC 173 ms
12,868 KB
testcase_16 WA -
testcase_17 AC 160 ms
12,720 KB
testcase_18 AC 62 ms
10,204 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

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;
	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<<0<<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