Submission #63545035


Source Code Expand

Copy
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
#define pcnt __builtin_popcountll
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
const ld eps = 1e-10;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rrep(i,n) for(ll i=n-1; i>=0; i--)
#define fi first
#define se second
#define pcnt __builtin_popcountll
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
string zero_padding(int val, int nf){ ostringstream sout;sout << setfill('0') << setw(nf) << val; return sout.str();};
const ld eps = 1e-10;
const ll INF = 1e18; 
ull mo = 1000000007;
ld PI=asin(1)*2;
//using namespace atcoder;

template<typename F>
void all_permutations(ll n,F f){
  vector<ll> vs(n);
  iota(vs.begin(),vs.end(),0);
  do f(vs); while(next_permutation(vs.begin(),vs.end()));
}
// https://atcoder.jp/contests/abc326/submissions/47026496 abc326_d

int main(){
    ll N,M;
    cin >> N >> M;
    vector<vector<ll>> G(N, vector<ll>(N, -1));
    rep(i,M){
        ll u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        G[u][v] = w;
        G[v][u] = w;
    }
    ll ans = 2e18;
    auto f = [&](vector<ll>& vs){
        if(vs[0] != 0) return;
        ll t = 0;
        rep(i,N-1){
            ll pr = vs[i];
            ll nx = vs[i+1];
            if(G[pr][nx] == -1) return;
            t ^= G[pr][nx];
            if(nx == N-1) break;
        }
        cmin(ans, t);
        return;
    };
    all_permutations(N,f);
    cout << ans << endl;
}

Submission Info

Submission Time
Task D - Minimum XOR Path
User zssa
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1861 Byte
Status AC
Exec Time 12 ms
Memory 3728 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 32
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3496 KB
00_sample_01.txt AC 1 ms 3584 KB
00_sample_02.txt AC 1 ms 3528 KB
01_test_00.txt AC 1 ms 3580 KB
01_test_01.txt AC 11 ms 3540 KB
01_test_02.txt AC 1 ms 3536 KB
01_test_03.txt AC 11 ms 3580 KB
01_test_04.txt AC 1 ms 3592 KB
01_test_05.txt AC 11 ms 3520 KB
01_test_06.txt AC 1 ms 3528 KB
01_test_07.txt AC 11 ms 3728 KB
01_test_08.txt AC 2 ms 3540 KB
01_test_09.txt AC 12 ms 3548 KB
01_test_10.txt AC 1 ms 3724 KB
01_test_11.txt AC 11 ms 3588 KB
01_test_12.txt AC 1 ms 3728 KB
01_test_13.txt AC 11 ms 3424 KB
01_test_14.txt AC 2 ms 3656 KB
01_test_15.txt AC 11 ms 3684 KB
01_test_16.txt AC 1 ms 3528 KB
01_test_17.txt AC 12 ms 3580 KB
01_test_18.txt AC 1 ms 3532 KB
01_test_19.txt AC 12 ms 3684 KB
01_test_20.txt AC 12 ms 3540 KB
01_test_21.txt AC 12 ms 3660 KB
01_test_22.txt AC 12 ms 3596 KB
01_test_23.txt AC 12 ms 3684 KB
01_test_24.txt AC 11 ms 3540 KB
01_test_25.txt AC 2 ms 3592 KB
01_test_26.txt AC 11 ms 3588 KB
01_test_27.txt AC 1 ms 3588 KB
01_test_28.txt AC 1 ms 3536 KB


2025-04-15 (Tue)
13:15:04 +00:00