結果

問題 No.2888 Mamehinata
ユーザー 👑 kmjpkmjp
提出日時 2024-09-13 22:56:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 402 ms / 2,000 ms
コード長 1,348 bytes
コンパイル時間 2,339 ms
コンパイル使用メモリ 209,536 KB
実行使用メモリ 16,936 KB
最終ジャッジ日時 2024-09-13 22:56:33
合計ジャッジ時間 13,732 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,388 KB
testcase_01 AC 4 ms
8,248 KB
testcase_02 AC 4 ms
8,124 KB
testcase_03 AC 4 ms
8,644 KB
testcase_04 AC 4 ms
8,160 KB
testcase_05 AC 4 ms
8,260 KB
testcase_06 AC 4 ms
8,900 KB
testcase_07 AC 4 ms
8,644 KB
testcase_08 AC 3 ms
8,248 KB
testcase_09 AC 4 ms
8,112 KB
testcase_10 AC 4 ms
9,668 KB
testcase_11 AC 4 ms
8,244 KB
testcase_12 AC 4 ms
8,300 KB
testcase_13 AC 29 ms
9,796 KB
testcase_14 AC 124 ms
10,172 KB
testcase_15 AC 202 ms
13,508 KB
testcase_16 AC 316 ms
14,276 KB
testcase_17 AC 180 ms
9,416 KB
testcase_18 AC 65 ms
11,076 KB
testcase_19 AC 299 ms
14,176 KB
testcase_20 AC 245 ms
13,340 KB
testcase_21 AC 234 ms
13,256 KB
testcase_22 AC 223 ms
10,636 KB
testcase_23 AC 293 ms
12,868 KB
testcase_24 AC 340 ms
14,404 KB
testcase_25 AC 311 ms
14,148 KB
testcase_26 AC 313 ms
13,896 KB
testcase_27 AC 275 ms
11,844 KB
testcase_28 AC 50 ms
9,332 KB
testcase_29 AC 120 ms
11,028 KB
testcase_30 AC 332 ms
15,300 KB
testcase_31 AC 263 ms
14,052 KB
testcase_32 AC 183 ms
12,616 KB
testcase_33 AC 270 ms
13,596 KB
testcase_34 AC 203 ms
12,648 KB
testcase_35 AC 174 ms
12,740 KB
testcase_36 AC 359 ms
15,684 KB
testcase_37 AC 366 ms
15,816 KB
testcase_38 AC 97 ms
10,472 KB
testcase_39 AC 301 ms
14,532 KB
testcase_40 AC 402 ms
15,684 KB
testcase_41 AC 62 ms
9,456 KB
testcase_42 AC 309 ms
14,660 KB
testcase_43 AC 254 ms
15,088 KB
testcase_44 AC 287 ms
16,104 KB
testcase_45 AC 328 ms
16,936 KB
testcase_46 AC 43 ms
9,416 KB
testcase_47 AC 280 ms
15,940 KB
testcase_48 AC 195 ms
12,984 KB
testcase_49 AC 12 ms
8,648 KB
testcase_50 AC 32 ms
10,944 KB
testcase_51 AC 5 ms
8,244 KB
testcase_52 AC 5 ms
9,412 KB
testcase_53 AC 8 ms
8,544 KB
testcase_54 AC 4 ms
8,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#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 FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M;
vector<int> E[202020];
int dp[202020];
int S[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	if(E[0].empty()) {
		FOR(i,N) cout<<0<<endl;
		return;
	}
	
	
	FOR(i,N) dp[i]=1<<20;
	dp[0]=0;
	queue<int> Q;
	Q.push(0);
	while(Q.size()) {
		int cur=Q.front();
		S[dp[cur]]++;
		Q.pop();
		FORR(e,E[cur]) if(dp[e]==1<<20) {
			dp[e]=dp[cur]+1;
			Q.push(e);
		}
	}
	
	for(i=1;i<=N;i++) {
		if(i>=2) S[i]+=S[i-2];
		cout<<S[i]<<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