Submission #63522471


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef double db;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;

#include  <ext/pb_ds/assoc_container.hpp>
#include  <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<db, db> pdd;
typedef pair<ll, ll> pll;

const ll INF = 1ll << 60;

int solve()
{
	int n, m;
	if (!(cin >> n >> m))
		return 1;
	
	vector<vector<ll>> g(n, vector<ll>(n, -1));
	FOR (i, 0, m)
	{
		int a, b;
		ll w;
		cin >> a >> b >> w;
		--a;--b;
		g[a][b] = g[b][a] = w;
	}
	
	ll ans = INF;
	vector<int> ord(n - 1);
	iota(all(ord), 1);
	while (1)
	{
		ll cur = 0;
		int pr = 0;
		FOR (i, 0, n - 1)
		{
			int j = ord[i];
			if (g[pr][j] != -1)
				cur ^= g[pr][j];
			else
			{
				cur = INF;
				break;
			}
			pr = j;
			if (j == n - 1)
				break;
		}
		ans = min(ans, cur);
		
		if (!next_permutation(all(ord)))
			break;
	}
	cout << ans << '\n';
	
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	//cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
		{
			break;
		}
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

Submission Info

Submission Time
Task D - Minimum XOR Path
User WeaRD276
Language C++ 20 (gcc 12.2)
Score 400
Code Size 1751 Byte
Status AC
Exec Time 3 ms
Memory 3600 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 3416 KB
00_sample_01.txt AC 1 ms 3388 KB
00_sample_02.txt AC 1 ms 3460 KB
01_test_00.txt AC 1 ms 3468 KB
01_test_01.txt AC 2 ms 3476 KB
01_test_02.txt AC 1 ms 3416 KB
01_test_03.txt AC 2 ms 3468 KB
01_test_04.txt AC 1 ms 3376 KB
01_test_05.txt AC 2 ms 3420 KB
01_test_06.txt AC 1 ms 3324 KB
01_test_07.txt AC 2 ms 3332 KB
01_test_08.txt AC 1 ms 3476 KB
01_test_09.txt AC 2 ms 3520 KB
01_test_10.txt AC 1 ms 3484 KB
01_test_11.txt AC 2 ms 3420 KB
01_test_12.txt AC 1 ms 3468 KB
01_test_13.txt AC 2 ms 3424 KB
01_test_14.txt AC 1 ms 3388 KB
01_test_15.txt AC 2 ms 3460 KB
01_test_16.txt AC 1 ms 3472 KB
01_test_17.txt AC 3 ms 3600 KB
01_test_18.txt AC 1 ms 3476 KB
01_test_19.txt AC 3 ms 3404 KB
01_test_20.txt AC 3 ms 3464 KB
01_test_21.txt AC 3 ms 3428 KB
01_test_22.txt AC 3 ms 3416 KB
01_test_23.txt AC 3 ms 3480 KB
01_test_24.txt AC 2 ms 3464 KB
01_test_25.txt AC 1 ms 3452 KB
01_test_26.txt AC 2 ms 3476 KB
01_test_27.txt AC 1 ms 3444 KB
01_test_28.txt AC 1 ms 3464 KB


2025-04-01 (Tue)
19:25:37 +00:00