提出 #35100009


ソースコード 拡げる

#include <bits/stdc++.h>



using namespace std;


// #pragma gcc optimize("ofast")
// #pragma gcc target("avx,avx2,fma")


#define int long long

#define all(x) (x).begin(), (x).end()


#define pb push_back
#define endl '\n'
#define fi first
#define se second

// const int mod = 1e9 + 7;

const int mod=998'244'353;


const long long INF = 2e18 + 10;
// const int INF=4e9+10;

#define readv(x, n)   \
    vector<int> x(n); \
    for (auto &i : x) \
        cin >> i;



template <typename t>
    using v = vector<t>;

template <typename t>
    using vv = vector<vector<t>>;

template <typename t>
    using vvv = vector<vector<vector<t>>>;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<vector<vector<vector<int>>>> vvvvi;
typedef vector<vector<double>> vvd;

typedef pair<int, int> pii;



int multiply(int a, int b, int in_mod) { return (int)(1ll * a * b % in_mod); }
int mult_identity(int a) { return 1; }



const double pi = acosl(-1);



auto power(auto a, auto b, const int in_mod)
{

    auto prod = mult_identity(a);
    auto mult = a % in_mod;
    while (b != 0)
    {
        if (b % 2)
        {
            prod = multiply(prod, mult, in_mod);
        }
        if(b/2)
        mult = multiply(mult, mult, in_mod);
        b /= 2;
    }
}
auto mod_inv(auto q, const int in_mod)
{
    return power(q, in_mod - 2, in_mod);
}


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



#define stp cout << fixed << setprecision(20);

void solv()
{
   int n , x, y;
   cin>>n>>x>>y;


   vvi adj(n + 1);
   for(int i = 0;i<n-1;i++){
    int a, b;
    cin>>a>>b;
    adj[a].pb(b);
    adj[b].pb(a);
   }


   function<void(int , int, vi &)> dfs = [&](int root, int parent,vi& path){
    path.push_back(root);
    if(root == y){
        for(auto j:path)
            cout<<j<<" ";
        exit(0);

    }

    for(auto i:adj[root]){
        if(i == parent)
            continue;

        dfs(i, root, path);
    }

    path.pop_back();
   };
   vi tmp;
   dfs(x, x, tmp);

}

void solve()
{

    int t = 1;
    // cin>>t;
    for(int T=1;T<=t;T++)
    {
        // cout<<"Case #"<<T<<": ";
        solv();
    }
}




signed main()
{

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cerr.tie(NULL);

    auto clk = clock();
    // -------------------------------------Code starts here---------------------------------------------------------------------

    signed t = 1;
    // cin >> t;

    for (signed test = 1; test <= t; test++)
    {
        // cout<<"Case #"<<test<<": ";

        solve();
    }

    // -------------------------------------Code ends here------------------------------------------------------------------

    clk = clock() - clk;

    #ifndef ONLINE_JUDGE
    cerr << fixed << setprecision(6) << "\nTime: " << ((float)clk) / CLOCKS_PER_SEC << "\n";
    #endif
    return 0;
}

/*
000100

1000100

1 0 -1 -2 -1 -2 -3
*/

提出情報

提出日時
問題 C - Simple path
ユーザ Wernier
言語 C++ (GCC 9.2.1)
得点 300
コード長 3249 Byte
結果 AC
実行時間 114 ms
メモリ 34956 KiB

コンパイルエラー

./Main.cpp: In function ‘long long int mult_identity(long long int)’:
./Main.cpp:58:23: warning: unused parameter ‘a’ [-Wunused-parameter]
   58 | int mult_identity(int a) { return 1; }
      |                       ^
./Main.cpp: At global scope:
./Main.cpp:66:12: warning: use of ‘auto’ in parameter declaration only available with ‘-fconcepts’
   66 | auto power(auto a, auto b, const int in_mod)
      |            ^~~~
./Main.cpp:66:20: warning: use of ‘auto’ in parameter declaration only available with ‘-fconcepts’
   66 | auto power(auto a, auto b, const int in_mod)
      |                    ^~~~
./Main.cpp:82:14: warning: use of ‘auto’ in parameter declaration only available with ‘-fconcepts’
   82 | auto mod_inv(auto q, const int in_mod)
      |              ^~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 2
AC × 27
セット名 テストケース
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 7 ms 3680 KiB
example_01.txt AC 2 ms 3524 KiB
hand_00.txt AC 2 ms 3564 KiB
hand_01.txt AC 114 ms 34908 KiB
hand_02.txt AC 58 ms 15996 KiB
hand_03.txt AC 114 ms 34860 KiB
hand_04.txt AC 108 ms 34956 KiB
random_00.txt AC 81 ms 15704 KiB
random_01.txt AC 84 ms 15724 KiB
random_02.txt AC 76 ms 15784 KiB
random_03.txt AC 81 ms 15600 KiB
random_04.txt AC 86 ms 15712 KiB
random_05.txt AC 72 ms 15664 KiB
random_06.txt AC 69 ms 15768 KiB
random_07.txt AC 77 ms 15656 KiB
random_08.txt AC 78 ms 15732 KiB
random_09.txt AC 60 ms 16712 KiB
random_10.txt AC 63 ms 16428 KiB
random_11.txt AC 66 ms 16632 KiB
random_12.txt AC 98 ms 30892 KiB
random_13.txt AC 98 ms 29144 KiB
random_14.txt AC 99 ms 30012 KiB
random_15.txt AC 100 ms 31632 KiB
random_16.txt AC 104 ms 29140 KiB
random_17.txt AC 74 ms 17696 KiB
random_18.txt AC 92 ms 23564 KiB
random_19.txt AC 77 ms 17972 KiB