Submission #55435
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | #include "bits/stdc++.h" // Begin {{{ using namespace std; #define all(x) x.begin(), x.end() #define rep(i, n) for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i) #define reps(i, b, e) for (i64 i = (b), i##_limit = (e); i <= i##_limit; ++i) #define repr(i, b, e) for (i64 i = (b), i##_limit = (e); i >= i##_limit; --i) #define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__) using i64 = int_fast64_t; using pii = pair<i64, i64>; template < class T> using MaxHeap = priority_queue<T>; template < class T> using MinHeap = priority_queue<T, vector<T>, greater<>>; template < class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true ); } template < class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true ); } inline i64 sigma(i64 n) { return n * (1 + n) >> 1; } inline i64 updiv(i64 n, i64 d) { return (n + d - 1) / d; } constexpr int INF = 0x3f3f3f3f; constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr int MOD = int (1e9) + 7; #ifndef DEBUG #define dump(...) #endif inline void input() {} template < class Head, class ... Tail> inline void input(Head&& head, Tail&&... tail) { cin >> head; input(forward<Tail>(tail)...); } inline void outs() { cout << "\n" ; } template < class Head, class ... Tail> inline void outs(Head&& head, Tail&&... tail) { cout << head << ( sizeof ...(tail) ? " " : "" ); outs(forward<Tail>(tail)...); } template < class T> inline void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n" [&e == &vec.back()]; } template < class T> inline void outs(vector<vector<T>> &df) { for (auto &vec : df) outs(vec); } inline void outl() { cout << "\n" ; } template < class Head, class ... Tail> inline void outl(Head&& head, Tail&&... tail) { cout << head << ( sizeof ...(tail) ? "\n" : "" ); outl(forward<Tail>(tail)...); } template < class T> inline void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n" ; } inline void outn() {} template < class Head, class ... Tail> inline void outn(Head&& head, Tail&&... tail) { cout << head; outn(forward<Tail>(tail)...); } template < class T> inline void outn(vector<T> &vec) { for (auto &e : vec) cout << e; } template < class T> inline vector<T> make_v( const T &initvalue, size_t sz) { return vector<T>(sz, initvalue); } template < class T, class ... Args> inline auto make_v( const T &initvalue, size_t sz, Args... args) { return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...)); } // }}} End signed main() { ios::sync_with_stdio( false ); cin.tie(nullptr); var( int , n, first, r); first--; vector< bool > maybe(n, false ); maybe[first] = true ; rep(i, r) { var( int , a, b); a--; b--; if (maybe[a]) { maybe[b] = true ; } else if (maybe[b]) { maybe[a] = true ; } else if (a == first) { maybe[b] = true ; } else if (b == first) { maybe[a] = true ; } } i64 ans = 0; rep(i, n) { if (maybe[i]) { ans++; dump(i); } } outl(ans); return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 1188 - マジック |
ユーザー名 | もけ |
投稿日時 | 2019-09-30 17:15:28 |
言語 | C++14 |
状態 | Accepted |
得点 | 1 |
ソースコード長 | 3220 Byte |
最大実行時間 | 28 ms |
最大メモリ使用量 | 640 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | ALL | 1 / 1 | * |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|---|---|---|---|
in01.text | AC | 28 ms | 604 KB |
1
|
in02.text | AC | 20 ms | 556 KB |
1
|
in03.text | AC | 20 ms | 640 KB |
1
|
in04.text | AC | 19 ms | 460 KB |
1
|
in05.text | AC | 19 ms | 544 KB |
1
|
in06.text | AC | 24 ms | 504 KB |
1
|
in07.text | AC | 24 ms | 592 KB |
1
|
sample1.text | AC | 19 ms | 548 KB |
1
|
sample2.text | AC | 20 ms | 636 KB |
1
|
sample3.text | AC | 20 ms | 468 KB |
1
|