結果

問題 No.1254 補強への架け橋
ユーザー yuji9511yuji9511
提出日時 2020-10-09 23:49:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 1,981 bytes
コンパイル時間 4,838 ms
コンパイル使用メモリ 218,272 KB
実行使用メモリ 27,572 KB
最終ジャッジ日時 2023-09-27 20:11:08
合計ジャッジ時間 15,095 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,708 KB
testcase_01 AC 3 ms
5,788 KB
testcase_02 AC 3 ms
5,840 KB
testcase_03 AC 3 ms
5,704 KB
testcase_04 AC 3 ms
5,936 KB
testcase_05 AC 2 ms
5,712 KB
testcase_06 AC 3 ms
5,784 KB
testcase_07 AC 3 ms
5,772 KB
testcase_08 AC 3 ms
5,672 KB
testcase_09 AC 3 ms
5,704 KB
testcase_10 AC 3 ms
5,712 KB
testcase_11 AC 3 ms
5,712 KB
testcase_12 AC 2 ms
5,772 KB
testcase_13 AC 3 ms
5,684 KB
testcase_14 AC 3 ms
5,796 KB
testcase_15 AC 3 ms
5,672 KB
testcase_16 AC 3 ms
5,716 KB
testcase_17 AC 3 ms
5,788 KB
testcase_18 AC 3 ms
5,912 KB
testcase_19 AC 3 ms
5,708 KB
testcase_20 AC 3 ms
5,724 KB
testcase_21 AC 3 ms
5,768 KB
testcase_22 AC 3 ms
5,680 KB
testcase_23 AC 3 ms
5,716 KB
testcase_24 AC 3 ms
5,720 KB
testcase_25 AC 3 ms
5,772 KB
testcase_26 AC 3 ms
5,968 KB
testcase_27 AC 4 ms
5,780 KB
testcase_28 AC 4 ms
5,792 KB
testcase_29 AC 4 ms
5,788 KB
testcase_30 AC 3 ms
5,912 KB
testcase_31 AC 3 ms
5,852 KB
testcase_32 AC 4 ms
5,712 KB
testcase_33 AC 3 ms
5,728 KB
testcase_34 AC 4 ms
5,724 KB
testcase_35 AC 3 ms
5,692 KB
testcase_36 AC 3 ms
5,740 KB
testcase_37 AC 2 ms
5,676 KB
testcase_38 AC 3 ms
5,728 KB
testcase_39 AC 3 ms
5,920 KB
testcase_40 AC 3 ms
5,716 KB
testcase_41 AC 4 ms
5,844 KB
testcase_42 AC 4 ms
5,716 KB
testcase_43 AC 4 ms
5,836 KB
testcase_44 AC 4 ms
5,728 KB
testcase_45 AC 3 ms
5,776 KB
testcase_46 AC 3 ms
5,812 KB
testcase_47 AC 4 ms
5,808 KB
testcase_48 AC 4 ms
5,900 KB
testcase_49 AC 3 ms
5,808 KB
testcase_50 AC 4 ms
5,948 KB
testcase_51 AC 4 ms
5,940 KB
testcase_52 AC 4 ms
5,884 KB
testcase_53 AC 4 ms
5,860 KB
testcase_54 AC 4 ms
5,840 KB
testcase_55 AC 3 ms
5,872 KB
testcase_56 AC 4 ms
5,688 KB
testcase_57 AC 3 ms
5,936 KB
testcase_58 AC 3 ms
5,780 KB
testcase_59 AC 3 ms
5,736 KB
testcase_60 AC 3 ms
6,012 KB
testcase_61 AC 4 ms
6,012 KB
testcase_62 AC 3 ms
5,692 KB
testcase_63 AC 16 ms
7,432 KB
testcase_64 AC 6 ms
6,268 KB
testcase_65 AC 11 ms
6,924 KB
testcase_66 AC 9 ms
6,656 KB
testcase_67 AC 5 ms
6,152 KB
testcase_68 AC 10 ms
6,764 KB
testcase_69 AC 12 ms
7,156 KB
testcase_70 AC 6 ms
6,308 KB
testcase_71 AC 5 ms
6,160 KB
testcase_72 AC 12 ms
7,128 KB
testcase_73 AC 7 ms
6,404 KB
testcase_74 AC 12 ms
7,028 KB
testcase_75 AC 9 ms
6,672 KB
testcase_76 AC 4 ms
5,936 KB
testcase_77 AC 8 ms
6,760 KB
testcase_78 AC 15 ms
7,284 KB
testcase_79 AC 15 ms
7,300 KB
testcase_80 AC 13 ms
7,212 KB
testcase_81 AC 15 ms
7,300 KB
testcase_82 AC 14 ms
7,128 KB
testcase_83 AC 189 ms
23,144 KB
testcase_84 AC 185 ms
22,728 KB
testcase_85 AC 118 ms
16,352 KB
testcase_86 AC 156 ms
20,404 KB
testcase_87 AC 173 ms
21,536 KB
testcase_88 AC 23 ms
8,412 KB
testcase_89 AC 176 ms
23,024 KB
testcase_90 AC 106 ms
16,616 KB
testcase_91 AC 84 ms
14,328 KB
testcase_92 AC 41 ms
10,204 KB
testcase_93 AC 139 ms
19,648 KB
testcase_94 AC 125 ms
18,088 KB
testcase_95 AC 123 ms
18,204 KB
testcase_96 AC 167 ms
22,332 KB
testcase_97 AC 68 ms
13,256 KB
testcase_98 AC 170 ms
22,136 KB
testcase_99 AC 96 ms
15,944 KB
testcase_100 AC 186 ms
23,644 KB
testcase_101 AC 38 ms
9,652 KB
testcase_102 AC 19 ms
7,792 KB
testcase_103 AC 40 ms
10,208 KB
testcase_104 AC 56 ms
11,792 KB
testcase_105 AC 143 ms
19,688 KB
testcase_106 AC 79 ms
13,748 KB
testcase_107 AC 189 ms
22,872 KB
testcase_108 AC 191 ms
22,536 KB
testcase_109 AC 141 ms
19,272 KB
testcase_110 AC 123 ms
18,088 KB
testcase_111 AC 133 ms
18,984 KB
testcase_112 AC 54 ms
11,560 KB
testcase_113 AC 120 ms
17,828 KB
testcase_114 AC 79 ms
13,600 KB
testcase_115 AC 25 ms
8,664 KB
testcase_116 AC 87 ms
14,896 KB
testcase_117 AC 54 ms
11,776 KB
testcase_118 AC 191 ms
21,832 KB
testcase_119 AC 98 ms
15,608 KB
testcase_120 AC 172 ms
21,364 KB
testcase_121 AC 48 ms
10,872 KB
testcase_122 AC 86 ms
14,648 KB
testcase_123 AC 3 ms
5,656 KB
testcase_124 AC 138 ms
27,572 KB
testcase_125 AC 137 ms
27,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return (x<0||x>=n||y<0||y>=m)?false:true;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
typedef pair<int,int> P;

int ord[100001],low[100001];
vector<int> G[100001];
struct edge{int u,v;};
void dfs(int u, int pre, int c, vector<int> G[], vector<edge> &B){
  ord[u] = low[u] = c++;
  for(int i=0;i<G[u].size();i++){
    int v = G[u][i];
    if(v != pre){
      if(ord[v] == -1){
        dfs(v,u,c,G,B);
        low[u] = min(low[u],low[v]);
      } else low[u] = min(low[u],ord[v]);
      if(ord[u] < low[v]) B.push_back((edge){u,v});
    }
  }
}

void bridge(int n, vector<int> G[], vector<edge> &B){
  B.clear();
  int c = 0;
  fill(ord,ord+n,-1);
  for(int i=0;i<n;i++) if(ord[i]==-1) dfs(i,-1,c,G,B);
}

int main() {
  int n,m;
  cin >> n;
  m = n;
  map<P, int> mp;
  int x[100010], y[100010];
  rep(i,m) {
    cin >> x[i] >> y[i];
    x[i]--; y[i]--;
    // mp[{x[i],y[i]}] = i;
    G[x[i]].pb(y[i]);
    G[y[i]].pb(x[i]);
  }

  vector<edge> E;
  bridge(n,G,E);
  vector<P> ans;
  rep(i,E.size()) {
    if(E[i].u>E[i].v) swap(E[i].u,E[i].v);
    ans.pb(P(E[i].u,E[i].v));
  }
  sort(all(ans));
//   rep(i,ans.size()) PR(ans[i].F,ans[i].S);
  rep(i,ans.size()){
      mp[ans[i]]++;
      mp[{ans[i].S, ans[i].F}]++;
  }
  vector<int> ans2;
  rep(i,n){
      if(mp[{x[i], y[i]}] == 0){
          ans2.push_back(i+1);
      }
  }
  cout << ans2.size() << endl;
  for(auto &e: ans2) cout << e << " ";
  cout << endl;

  return 0;
}
0