結果
問題 | No.1254 補強への架け橋 |
ユーザー | SHIJOU |
提出日時 | 2020-10-16 22:12:46 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 92 ms / 2,000 ms |
コード長 | 2,878 bytes |
コンパイル時間 | 2,495 ms |
コンパイル使用メモリ | 213,980 KB |
実行使用メモリ | 25,472 KB |
最終ジャッジ日時 | 2024-07-20 21:59:29 |
合計ジャッジ時間 | 13,147 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 2 ms
5,376 KB |
testcase_24 | AC | 2 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 2 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 2 ms
5,376 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 2 ms
5,376 KB |
testcase_33 | AC | 2 ms
5,376 KB |
testcase_34 | AC | 2 ms
5,376 KB |
testcase_35 | AC | 2 ms
5,376 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 3 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | AC | 2 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 2 ms
5,376 KB |
testcase_43 | AC | 2 ms
5,376 KB |
testcase_44 | AC | 2 ms
5,376 KB |
testcase_45 | AC | 2 ms
5,376 KB |
testcase_46 | AC | 2 ms
5,376 KB |
testcase_47 | AC | 2 ms
5,376 KB |
testcase_48 | AC | 2 ms
5,376 KB |
testcase_49 | AC | 2 ms
5,376 KB |
testcase_50 | AC | 2 ms
5,376 KB |
testcase_51 | AC | 3 ms
5,376 KB |
testcase_52 | AC | 2 ms
5,376 KB |
testcase_53 | AC | 2 ms
5,376 KB |
testcase_54 | AC | 3 ms
5,376 KB |
testcase_55 | AC | 2 ms
5,376 KB |
testcase_56 | AC | 2 ms
5,376 KB |
testcase_57 | AC | 2 ms
5,376 KB |
testcase_58 | AC | 3 ms
5,376 KB |
testcase_59 | AC | 2 ms
5,376 KB |
testcase_60 | AC | 2 ms
5,376 KB |
testcase_61 | AC | 2 ms
5,376 KB |
testcase_62 | AC | 2 ms
5,376 KB |
testcase_63 | AC | 6 ms
5,376 KB |
testcase_64 | AC | 3 ms
5,376 KB |
testcase_65 | AC | 5 ms
5,376 KB |
testcase_66 | AC | 4 ms
5,376 KB |
testcase_67 | AC | 2 ms
5,376 KB |
testcase_68 | AC | 4 ms
5,376 KB |
testcase_69 | AC | 5 ms
5,376 KB |
testcase_70 | AC | 3 ms
5,376 KB |
testcase_71 | AC | 3 ms
5,376 KB |
testcase_72 | AC | 5 ms
5,376 KB |
testcase_73 | AC | 3 ms
5,376 KB |
testcase_74 | AC | 4 ms
5,376 KB |
testcase_75 | AC | 4 ms
5,376 KB |
testcase_76 | AC | 2 ms
5,376 KB |
testcase_77 | AC | 4 ms
5,376 KB |
testcase_78 | AC | 6 ms
5,376 KB |
testcase_79 | AC | 5 ms
5,376 KB |
testcase_80 | AC | 5 ms
5,376 KB |
testcase_81 | AC | 6 ms
5,376 KB |
testcase_82 | AC | 5 ms
5,376 KB |
testcase_83 | AC | 59 ms
11,008 KB |
testcase_84 | AC | 51 ms
10,880 KB |
testcase_85 | AC | 30 ms
7,936 KB |
testcase_86 | AC | 43 ms
9,856 KB |
testcase_87 | AC | 48 ms
10,496 KB |
testcase_88 | AC | 8 ms
5,376 KB |
testcase_89 | AC | 50 ms
11,008 KB |
testcase_90 | AC | 31 ms
8,320 KB |
testcase_91 | AC | 26 ms
7,296 KB |
testcase_92 | AC | 13 ms
5,504 KB |
testcase_93 | AC | 41 ms
9,472 KB |
testcase_94 | AC | 37 ms
8,832 KB |
testcase_95 | AC | 38 ms
8,832 KB |
testcase_96 | AC | 47 ms
10,624 KB |
testcase_97 | AC | 21 ms
6,656 KB |
testcase_98 | AC | 48 ms
10,752 KB |
testcase_99 | AC | 31 ms
7,936 KB |
testcase_100 | AC | 62 ms
11,264 KB |
testcase_101 | AC | 12 ms
5,376 KB |
testcase_102 | AC | 7 ms
5,376 KB |
testcase_103 | AC | 13 ms
5,376 KB |
testcase_104 | AC | 17 ms
6,016 KB |
testcase_105 | AC | 43 ms
9,600 KB |
testcase_106 | AC | 23 ms
7,040 KB |
testcase_107 | AC | 53 ms
11,136 KB |
testcase_108 | AC | 58 ms
10,880 KB |
testcase_109 | AC | 38 ms
9,472 KB |
testcase_110 | AC | 35 ms
8,832 KB |
testcase_111 | AC | 37 ms
9,216 KB |
testcase_112 | AC | 16 ms
5,888 KB |
testcase_113 | AC | 37 ms
8,576 KB |
testcase_114 | AC | 22 ms
6,912 KB |
testcase_115 | AC | 9 ms
5,376 KB |
testcase_116 | AC | 26 ms
7,424 KB |
testcase_117 | AC | 16 ms
6,016 KB |
testcase_118 | AC | 48 ms
10,624 KB |
testcase_119 | AC | 28 ms
7,680 KB |
testcase_120 | AC | 47 ms
10,368 KB |
testcase_121 | AC | 15 ms
5,632 KB |
testcase_122 | AC | 25 ms
7,296 KB |
testcase_123 | AC | 2 ms
5,376 KB |
testcase_124 | AC | 92 ms
25,472 KB |
testcase_125 | AC | 89 ms
25,344 KB |
ソースコード
//#define _GLIBCXX_DEBUG #include <bits/stdc++.h> #define rep(i, n) for(int i=0; i<n; ++i) #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using namespace std; using ll = int64_t; using ld = long double; using P = pair<int, int>; using vs = vector<string>; using vi = vector<int>; using vvi = vector<vi>; template<class T> using PQ = priority_queue<T>; template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >; const int INF = 0xccccccc; const ll LINF = 0xcccccccccccccccLL; template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;} template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;} struct TECC { struct Edge { int to, rev; Edge() {} Edge(int t, int r):to(t), rev(r) {} }; int n; vector<vector<Edge>> G; TECC(int n_) : n(n_), G(n_) {} void add(int u, int v) { G[u].emplace_back(v, int(G[v].size())); G[v].emplace_back(u, int(G[u].size())-1); } pair<int, vector<int>> tecc_ids() { int now_ord = 0, group_num = 0; vector<int> used, low(n), ord(n, -1), ids(n); used.reserve(n); auto dfs = [&](auto self, int v)->void { low[v] = ord[v] = now_ord++; used.push_back(v); for(Edge &e:G[v]) if(e.rev != -1) { int to = e.to; G[to][e.rev].rev = -1; e.rev = -1; if(ord[to] == -1) { self(self, to); low[v] = min(low[v], low[to]); } else { low[v] = min(low[v], ord[to]); } } if(low[v] == ord[v]) { int u; do { u = used.back(); used.pop_back(); ord[u] = n; ids[u] = group_num; } while(u != v); group_num++; } }; for(int i = 0; i < n; i++) { if(ord[i] == -1) dfs(dfs, i); } for(int &x:ids) { x = group_num - 1 - x; } return {group_num, ids}; } vector<vector<int>> tecc() { pair<int, vector<int>> ids = tecc_ids(); int group_num = ids.first; vector<int> counts(group_num); for(int x:ids.second) counts[x]++; vector<vector<int>> groups(group_num); for(int i = 0; i < group_num; i++) { groups[i].reserve(counts[i]); } for(int i = 0; i < n; i++) { groups[ids.second[i]].push_back(i); } return groups; } }; //head int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; TECC tecc(n); vector<P> edges(n); rep(i, n) { int a, b; cin >> a >> b; edges[i] = {--a, --b}; tecc.add(a, b); } vi ans; ans.reserve(n); vi info = tecc.tecc_ids().second; rep(i, n) { auto [u, v] = edges[i]; if(info[u] == info[v]) ans.push_back(i+1); } cout << size(ans) << endl; for(int x:ans) cout << x << ' '; cout << endl; }