Submission #63538449
Source Code Expand
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<iostream>
#include<iomanip>
#include<cmath>
#include<climits>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<numeric>
#include<queue>
#include<bitset>
#include<unordered_map>
#include<unordered_set>
#include<limits>
#include<cassert>
#include<ranges>
#include<list>
using namespace std;
#define MOD 998244353
long long ans=LLONG_MAX;
void saiki(int pos,long long xori,vector<bool>& arr,const vector<vector< pair<int,long long> >>& edge,const int& n){
if(pos==n-1){
ans=min(ans,xori);
return;
}
arr[pos]=true;
for(auto [e,w]: edge[pos]){
if(arr[e]) continue;
saiki(e,(xori ^ w),arr,edge,n);
}
arr[pos]=false;
}
int main(){
int n,m;
cin>>n>>m;
vector<int> u(m),v(m);
vector<long long> w(m);
vector<vector< pair<int,long long> >> edge(n,vector<pair<int,long long>>());
for(int i=0;i<m;++i){
cin>>u[i]>>v[i]>>w[i];
u[i]--;v[i]--;
edge[u[i]].push_back( {v[i],w[i]} );
edge[v[i]].push_back( {u[i],w[i]} );
}
vector<bool> arr(n,false);
saiki(0,0,arr,edge,n);
cout<<ans<<endl;
//cout<<min(mini[n-1],mini[n+n-1])<<endl;
//cout<<tmpp.size()<<endl;
//cout<<*tmpp.begin()<<endl;
//if(flag)cout<<"Yes"<<endl;
//else cout<<"No"<<endl;
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Minimum XOR Path |
User |
oblivimint |
Language |
C++ 20 (gcc 12.2) |
Score |
400 |
Code Size |
1356 Byte |
Status |
AC |
Exec Time |
4 ms |
Memory |
3684 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
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 |
3492 KB |
00_sample_01.txt |
AC |
1 ms |
3528 KB |
00_sample_02.txt |
AC |
1 ms |
3548 KB |
01_test_00.txt |
AC |
1 ms |
3472 KB |
01_test_01.txt |
AC |
1 ms |
3684 KB |
01_test_02.txt |
AC |
1 ms |
3528 KB |
01_test_03.txt |
AC |
1 ms |
3488 KB |
01_test_04.txt |
AC |
1 ms |
3404 KB |
01_test_05.txt |
AC |
1 ms |
3592 KB |
01_test_06.txt |
AC |
1 ms |
3460 KB |
01_test_07.txt |
AC |
1 ms |
3404 KB |
01_test_08.txt |
AC |
1 ms |
3528 KB |
01_test_09.txt |
AC |
1 ms |
3556 KB |
01_test_10.txt |
AC |
1 ms |
3532 KB |
01_test_11.txt |
AC |
1 ms |
3552 KB |
01_test_12.txt |
AC |
1 ms |
3620 KB |
01_test_13.txt |
AC |
1 ms |
3476 KB |
01_test_14.txt |
AC |
1 ms |
3492 KB |
01_test_15.txt |
AC |
2 ms |
3488 KB |
01_test_16.txt |
AC |
1 ms |
3684 KB |
01_test_17.txt |
AC |
2 ms |
3400 KB |
01_test_18.txt |
AC |
1 ms |
3528 KB |
01_test_19.txt |
AC |
4 ms |
3412 KB |
01_test_20.txt |
AC |
3 ms |
3684 KB |
01_test_21.txt |
AC |
3 ms |
3408 KB |
01_test_22.txt |
AC |
3 ms |
3684 KB |
01_test_23.txt |
AC |
3 ms |
3492 KB |
01_test_24.txt |
AC |
1 ms |
3624 KB |
01_test_25.txt |
AC |
1 ms |
3524 KB |
01_test_26.txt |
AC |
1 ms |
3680 KB |
01_test_27.txt |
AC |
1 ms |
3472 KB |
01_test_28.txt |
AC |
1 ms |
3528 KB |