Submission #523887


Source Code Expand

Copy
#include <bits/stdc++.h>
#define GET_MACRO(a, b, c, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define rep2(i, a) rep3 (i, 0, a)
#define rep3(i, a, b) for (int i = (a); i < (b); i++)
#define repr(...) GET_MACRO(__VA_ARGS__, repr3, repr2)(__VA_ARGS__)
#define repr2(i, a) repr3 (i, 0, a)
#define repr3(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define chmin(a, b) ((b) < a && (a = (b), true))
#define chmax(a, b) (a < (b) && (a = (b), true))
using namespace std;
typedef long long ll;

map<ll, ll> c;
vector<pair<ll, ll>> G[101010];
ll dp[101010];

void dfs(int curr, int prev) {
	c[dp[curr]]++;
	for (auto e : G[curr]) if (e.first != prev) {
		int next = e.first;
		dp[next] = dp[curr] ^ e.second;
		dfs(next, curr);
	}
}

int main() {
	ll N, X;
	cin >> N >> X;	
	rep (i, N - 1) {
		ll x, y, c;
		cin >> x >> y >> c;
		x--; y--;
		G[x].emplace_back(y, c);
		G[y].emplace_back(x, c);
	}
	dfs(0, -1);
	ll ans = 0;
	rep (i, N) {
		ans += c[X ^ dp[i]];
	}
	ans /= 2;
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task C - エックスオア多橋君
User xumpei
Language C++11 (GCC 4.9.2)
Score 0
Code Size 1085 Byte
Status WA
Exec Time 407 ms
Memory 21544 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 3
AC × 25
WA × 2
Set Name Test Cases
Sample subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt
All subtask0_sample_01.txt, subtask0_sample_02.txt, subtask0_sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask1_14.txt, subtask1_15.txt, subtask1_16.txt, subtask1_17.txt, subtask1_18.txt, subtask1_19.txt, subtask1_20.txt, subtask1_21.txt, subtask1_22.txt, subtask1_23.txt, subtask1_24.txt
Case Name Status Exec Time Memory
subtask0_sample_01.txt AC 31 ms 3108 KB
subtask0_sample_02.txt AC 29 ms 3100 KB
subtask0_sample_03.txt AC 29 ms 3108 KB
subtask1_01.txt AC 30 ms 3104 KB
subtask1_02.txt WA 30 ms 3352 KB
subtask1_03.txt AC 407 ms 21544 KB
subtask1_04.txt AC 395 ms 21420 KB
subtask1_05.txt AC 404 ms 21408 KB
subtask1_06.txt WA 196 ms 13216 KB
subtask1_07.txt AC 210 ms 9000 KB
subtask1_08.txt AC 214 ms 9000 KB
subtask1_09.txt AC 282 ms 10064 KB
subtask1_10.txt AC 278 ms 10020 KB
subtask1_11.txt AC 32 ms 3232 KB
subtask1_12.txt AC 32 ms 3356 KB
subtask1_13.txt AC 238 ms 8996 KB
subtask1_14.txt AC 240 ms 9084 KB
subtask1_15.txt AC 54 ms 4452 KB
subtask1_16.txt AC 55 ms 4392 KB
subtask1_17.txt AC 54 ms 4380 KB
subtask1_18.txt AC 56 ms 4380 KB
subtask1_19.txt AC 55 ms 4380 KB
subtask1_20.txt AC 56 ms 4388 KB
subtask1_21.txt AC 57 ms 4384 KB
subtask1_22.txt AC 57 ms 4384 KB
subtask1_23.txt AC 55 ms 4388 KB
subtask1_24.txt AC 54 ms 4384 KB