結果
問題 | No.2888 Mamehinata |
ユーザー | nono00 |
提出日時 | 2024-09-13 21:35:40 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 147 ms / 2,000 ms |
コード長 | 2,881 bytes |
コンパイル時間 | 3,313 ms |
コンパイル使用メモリ | 254,880 KB |
実行使用メモリ | 16,752 KB |
最終ジャッジ日時 | 2024-09-13 21:35:51 |
合計ジャッジ時間 | 9,297 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 3 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 3 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 21 ms
5,376 KB |
testcase_14 | AC | 21 ms
7,296 KB |
testcase_15 | AC | 94 ms
10,112 KB |
testcase_16 | AC | 97 ms
13,184 KB |
testcase_17 | AC | 20 ms
8,064 KB |
testcase_18 | AC | 40 ms
5,888 KB |
testcase_19 | AC | 112 ms
12,928 KB |
testcase_20 | AC | 88 ms
11,392 KB |
testcase_21 | AC | 84 ms
11,136 KB |
testcase_22 | AC | 43 ms
9,984 KB |
testcase_23 | AC | 56 ms
12,160 KB |
testcase_24 | AC | 96 ms
14,336 KB |
testcase_25 | AC | 84 ms
13,952 KB |
testcase_26 | AC | 83 ms
13,568 KB |
testcase_27 | AC | 39 ms
11,648 KB |
testcase_28 | AC | 14 ms
5,376 KB |
testcase_29 | AC | 37 ms
7,680 KB |
testcase_30 | AC | 119 ms
14,208 KB |
testcase_31 | AC | 97 ms
12,416 KB |
testcase_32 | AC | 60 ms
9,728 KB |
testcase_33 | AC | 85 ms
11,776 KB |
testcase_34 | AC | 70 ms
10,496 KB |
testcase_35 | AC | 55 ms
9,472 KB |
testcase_36 | AC | 138 ms
15,232 KB |
testcase_37 | AC | 142 ms
15,616 KB |
testcase_38 | AC | 27 ms
6,656 KB |
testcase_39 | AC | 120 ms
13,056 KB |
testcase_40 | AC | 147 ms
15,360 KB |
testcase_41 | AC | 17 ms
5,376 KB |
testcase_42 | AC | 119 ms
13,568 KB |
testcase_43 | AC | 74 ms
13,896 KB |
testcase_44 | AC | 83 ms
15,216 KB |
testcase_45 | AC | 99 ms
16,752 KB |
testcase_46 | AC | 12 ms
5,376 KB |
testcase_47 | AC | 80 ms
14,852 KB |
testcase_48 | AC | 72 ms
10,588 KB |
testcase_49 | AC | 10 ms
5,376 KB |
testcase_50 | AC | 29 ms
5,888 KB |
testcase_51 | AC | 3 ms
5,376 KB |
testcase_52 | AC | 3 ms
5,376 KB |
testcase_53 | AC | 6 ms
5,376 KB |
testcase_54 | AC | 2 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; template <class T> using max_heap = priority_queue<T>; template <class T> using min_heap = priority_queue<T, vector<T>, greater<T>>; #define rep(i, l, r) for (ll i = (l); i < (r); i++) #define rrep(i, r, l) for (ll i = (r); i-- > (l);) #define all(x) begin(x), end(x) template <class T> bool chmin(T& lhs, T rhs) { return lhs > rhs ? (lhs = rhs, true) : false; } template <class T> bool chmax(T& lhs, T rhs) { return lhs < rhs ? (lhs = rhs, true) : false; } struct IOIO { IOIO() { cin.tie(0)->sync_with_stdio(0); } } ioio; template <class S, class T> ostream& operator<<(ostream& os, const pair<S, T>& p) { os << '(' << p.first << ", " << p.second << ')'; return os; } template <class T> ostream& operator<<(ostream& os, const vector<T>& vs) { os << '{'; rep(i, 0, (int)vs.size()) os << vs[i] << (i + 1 == (int)vs.size() ? "" : ", "); os << '}'; return os; } template <class T> ostream& operator<<(ostream& os, const set<T>& vs) { os << '{'; for (auto it = vs.begin(); it != vs.end(); it++) { if (it != vs.begin()) { os << ", "; } os << *it; } os << '}'; return os; } template <class T, class U> ostream& operator<<(ostream& os, const map<T, U>& vs) { os << '{'; for (auto it = vs.begin(); it != vs.end(); it++) { if (it != vs.begin()) { os << ", "; } os << *it; } os << '}'; return os; } #ifdef DEBUG void dump_func() { cerr << endl; } template <class Head, class... Tail> void dump_func(Head&& head, Tail&&... tail) { cerr << head; if (sizeof...(Tail) > 0) { cerr << ", "; } dump_func(std::move(tail)...); } #define dump(...) cerr << "[" + string(#__VA_ARGS__) + "] ", dump_func(__VA_ARGS__) #else #define dump(...) static_cast<int>(0) #endif int main() { int n, m; cin >> n >> m; vector graph(n, vector<int>()); rep(i, 0, m) { int u, v; cin >> u >> v; u--; v--; graph[u].push_back(v); graph[v].push_back(u); } vector<int> dist(n, -1); dist[0] = 0; queue<int> que; que.push(0); while (!que.empty()) { int u = que.front(); que.pop(); for (auto v: graph[u]) { if (dist[v] == -1) { dist[v] = dist[u] + 1; que.push(v); } } } if (count(all(dist), -1) == n - 1) { rep(i, 0, n) cout << 0 << '\n'; return 0; } int odd = 0; int even = 1; vector<int> freq(n + 1); rep(i, 0, n) if (dist[i] != -1) freq[dist[i]]++; rep(i, 0, n) { if (i % 2 == 0) { odd += freq[i + 1]; cout << odd << '\n'; } else { even += freq[i + 1]; cout << even << '\n'; } } }