結果
| 問題 | No.1254 補強への架け橋 | 
| コンテスト | |
| ユーザー |  fastmath | 
| 提出日時 | 2020-10-09 22:21:30 | 
| 言語 | C++17(clang) (17.0.6 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 83 ms / 2,000 ms | 
| コード長 | 1,557 bytes | 
| コンパイル時間 | 5,093 ms | 
| コンパイル使用メモリ | 162,840 KB | 
| 実行使用メモリ | 25,416 KB | 
| 最終ジャッジ日時 | 2024-07-20 12:22:43 | 
| 合計ジャッジ時間 | 13,095 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 123 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcountll
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
#define debug(x) std::cout << #x << ": " << x << '\n';
const int N = 1e5+7;
int par[N];
int par_ed[N];
vector <ii> g[N];
int h[N];
bool used[N];
void dfs(int u) {  
    used[u] = 1;
    for (auto e : g[u]) {
        int v = e.f;
        /*
        debug(u);
        debug(v);
        */
        if (!used[v]) {
            h[v] = h[u] + 1;
            par[v] = u;
            par_ed[v] = e.s;
            dfs(v);
        }   
        else if (h[v] < h[u] - 1) {
            vector <int> ans = {e.s};
            int cur = u;
            while (u != v) {
                ans.app(par_ed[u]);
                u = par[u];
            }   
            cout << ans.size() << endl;
            sort(all(ans));
            for (auto e : ans)
                cout << e + 1 << ' ';
            cout << endl;
            exit(0);
        }   
    }   
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20); 
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        g[u].app(mp(v, i)); g[v].app(mp(u, i));
    }   
    dfs(1);
    assert(0);
}
            
            
            
        