結果

問題 No.1254 補強への架け橋
ユーザー kk
提出日時 2020-12-30 03:33:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 275 ms / 2,000 ms
コード長 1,085 bytes
コンパイル時間 2,504 ms
コンパイル使用メモリ 207,432 KB
実行使用メモリ 27,636 KB
最終ジャッジ日時 2024-04-16 01:02:03
合計ジャッジ時間 18,182 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,888 KB
testcase_01 AC 3 ms
6,016 KB
testcase_02 AC 4 ms
6,016 KB
testcase_03 AC 3 ms
5,760 KB
testcase_04 AC 4 ms
6,016 KB
testcase_05 AC 4 ms
5,888 KB
testcase_06 AC 4 ms
6,016 KB
testcase_07 AC 4 ms
6,016 KB
testcase_08 AC 4 ms
5,760 KB
testcase_09 AC 4 ms
5,888 KB
testcase_10 AC 4 ms
6,016 KB
testcase_11 AC 4 ms
5,888 KB
testcase_12 AC 4 ms
5,760 KB
testcase_13 AC 4 ms
5,888 KB
testcase_14 AC 4 ms
5,888 KB
testcase_15 AC 4 ms
5,888 KB
testcase_16 AC 4 ms
5,888 KB
testcase_17 AC 3 ms
5,888 KB
testcase_18 AC 3 ms
6,016 KB
testcase_19 AC 4 ms
5,888 KB
testcase_20 AC 4 ms
5,760 KB
testcase_21 AC 3 ms
6,016 KB
testcase_22 AC 4 ms
5,888 KB
testcase_23 AC 4 ms
5,888 KB
testcase_24 AC 4 ms
6,016 KB
testcase_25 AC 4 ms
5,760 KB
testcase_26 AC 4 ms
6,016 KB
testcase_27 AC 4 ms
5,888 KB
testcase_28 AC 4 ms
5,888 KB
testcase_29 AC 4 ms
6,016 KB
testcase_30 AC 4 ms
5,888 KB
testcase_31 AC 4 ms
5,888 KB
testcase_32 AC 4 ms
6,016 KB
testcase_33 AC 4 ms
6,016 KB
testcase_34 AC 4 ms
6,016 KB
testcase_35 AC 4 ms
5,888 KB
testcase_36 AC 4 ms
6,016 KB
testcase_37 AC 4 ms
6,016 KB
testcase_38 AC 4 ms
5,888 KB
testcase_39 AC 4 ms
6,016 KB
testcase_40 AC 5 ms
6,016 KB
testcase_41 AC 4 ms
6,016 KB
testcase_42 AC 4 ms
6,016 KB
testcase_43 AC 4 ms
6,144 KB
testcase_44 AC 4 ms
6,016 KB
testcase_45 AC 5 ms
6,016 KB
testcase_46 AC 4 ms
6,144 KB
testcase_47 AC 4 ms
6,016 KB
testcase_48 AC 5 ms
6,016 KB
testcase_49 AC 4 ms
6,016 KB
testcase_50 AC 5 ms
6,144 KB
testcase_51 AC 4 ms
6,144 KB
testcase_52 AC 5 ms
6,144 KB
testcase_53 AC 4 ms
6,016 KB
testcase_54 AC 4 ms
6,144 KB
testcase_55 AC 4 ms
6,144 KB
testcase_56 AC 4 ms
5,888 KB
testcase_57 AC 5 ms
5,888 KB
testcase_58 AC 4 ms
5,888 KB
testcase_59 AC 4 ms
5,760 KB
testcase_60 AC 4 ms
5,760 KB
testcase_61 AC 4 ms
6,016 KB
testcase_62 AC 4 ms
5,760 KB
testcase_63 AC 16 ms
7,552 KB
testcase_64 AC 7 ms
6,272 KB
testcase_65 AC 12 ms
6,912 KB
testcase_66 AC 9 ms
6,784 KB
testcase_67 AC 6 ms
6,144 KB
testcase_68 AC 10 ms
6,784 KB
testcase_69 AC 12 ms
6,912 KB
testcase_70 AC 7 ms
6,144 KB
testcase_71 AC 6 ms
6,272 KB
testcase_72 AC 12 ms
7,040 KB
testcase_73 AC 7 ms
6,272 KB
testcase_74 AC 12 ms
6,784 KB
testcase_75 AC 9 ms
6,528 KB
testcase_76 AC 5 ms
6,016 KB
testcase_77 AC 9 ms
6,656 KB
testcase_78 AC 15 ms
7,296 KB
testcase_79 AC 15 ms
7,296 KB
testcase_80 AC 14 ms
7,040 KB
testcase_81 AC 15 ms
7,296 KB
testcase_82 AC 14 ms
7,296 KB
testcase_83 AC 275 ms
20,224 KB
testcase_84 AC 256 ms
19,712 KB
testcase_85 AC 128 ms
14,592 KB
testcase_86 AC 212 ms
17,920 KB
testcase_87 AC 235 ms
19,072 KB
testcase_88 AC 22 ms
8,192 KB
testcase_89 AC 266 ms
20,224 KB
testcase_90 AC 144 ms
15,104 KB
testcase_91 AC 103 ms
13,312 KB
testcase_92 AC 44 ms
9,856 KB
testcase_93 AC 204 ms
17,280 KB
testcase_94 AC 176 ms
16,256 KB
testcase_95 AC 177 ms
16,128 KB
testcase_96 AC 254 ms
19,456 KB
testcase_97 AC 86 ms
12,160 KB
testcase_98 AC 252 ms
19,584 KB
testcase_99 AC 130 ms
14,336 KB
testcase_100 AC 273 ms
20,480 KB
testcase_101 AC 40 ms
9,344 KB
testcase_102 AC 19 ms
7,680 KB
testcase_103 AC 42 ms
9,856 KB
testcase_104 AC 65 ms
11,136 KB
testcase_105 AC 191 ms
17,408 KB
testcase_106 AC 90 ms
12,800 KB
testcase_107 AC 269 ms
20,096 KB
testcase_108 AC 265 ms
19,840 KB
testcase_109 AC 194 ms
17,024 KB
testcase_110 AC 174 ms
16,128 KB
testcase_111 AC 186 ms
16,896 KB
testcase_112 AC 68 ms
10,880 KB
testcase_113 AC 173 ms
15,872 KB
testcase_114 AC 95 ms
12,416 KB
testcase_115 AC 26 ms
8,320 KB
testcase_116 AC 116 ms
13,440 KB
testcase_117 AC 64 ms
10,880 KB
testcase_118 AC 248 ms
19,200 KB
testcase_119 AC 128 ms
14,208 KB
testcase_120 AC 245 ms
18,944 KB
testcase_121 AC 50 ms
10,112 KB
testcase_122 AC 111 ms
13,312 KB
testcase_123 AC 4 ms
6,016 KB
testcase_124 AC 179 ms
27,636 KB
testcase_125 AC 190 ms
27,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

int n;
vector<int> g[100000];
map<pair<int, int>, int> id;
int ord[100000];
int low[100000];
int used[100000];
set<int> bs;

// lowlink algorithm
void dfs(int v, int &k, int par = -1) {
  ord[v] = k++;
  low[v] = ord[v];
  used[v] = true;
  
  for (int w: g[v]) {
    if (w == par) continue;
    if (!used[w]) {
      dfs(w, k, v);
      low[v] = min(low[v], low[w]);
      if (ord[v] < low[w])
        bs.insert(id[make_pair(min(v, w), max(v, w))]);
    } else {
      low[v] = min(low[v], ord[w]);
    }
  }
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  cin >> n;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    g[b].push_back(a);
    id[make_pair(min(a, b), max(a, b))] = i;
  }

  int k = 0;
  dfs(0, k);

  vector<int> ret;
  for (int i = 1; i <= n; i++)
    if (!bs.count(i))
      ret.push_back(i);

  cout << ret.size() << endl;
  for (int x: ret)
    cout << x << " ";
  cout << endl;
  
  return 0;
}
0