problem_id stringlengths 6 6 | buggy_code stringlengths 8 526k โ | fixed_code stringlengths 12 526k โ | labels listlengths 0 15 โ | buggy_submission_id int64 1 1.54M โ | fixed_submission_id int64 2 1.54M โ | user_id stringlengths 10 10 โ | language stringclasses 9 values |
|---|---|---|---|---|---|---|---|
p03043 | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define ll long long
#define rep2(i, a, b) for (ll i = a; i <= b; i++)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep3(i, a, b) for (ll i = a; i >= b; i--)
#define REP(e, v) for (auto e : v)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pq priority_queue<int>
#define pqg priority_queue<int, vector<int>, greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(), (c).end()
#define mp make_pair
using namespace std;
int in() {
int x;
scanf("%d", &x);
return x;
}
string stin() {
string s;
cin >> s;
return s;
}
ll lin() {
ll x;
scanf("%lld", &x);
return x;
}
int main() {
int n = in(), k = in();
double ans = 0;
vec c(21);
rep2(i, 1, n) {
int x = k / i, cnt = 0;
while (x > 0) {
cnt++;
x /= 2;
}
ans += pow(2.0, 19 - cnt) / n;
}
ans /= pow(2.0, 19);
cout << setprecision(15) << ans << endl;
} | #include <algorithm>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define ll long long
#define rep2(i, a, b) for (ll i = a; i <= b; i++)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep3(i, a, b) for (ll i = a; i >= b; i--)
#define REP(e, v) for (auto e : v)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pq priority_queue<int>
#define pqg priority_queue<int, vector<int>, greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(), (c).end()
#define mp make_pair
using namespace std;
int in() {
int x;
scanf("%d", &x);
return x;
}
string stin() {
string s;
cin >> s;
return s;
}
ll lin() {
ll x;
scanf("%lld", &x);
return x;
}
int main() {
int n = in(), k = in();
double ans = 0;
vec c(21);
rep2(i, 1, n) {
int x = (k - 1) / i, cnt = 0;
while (x >= 1) {
cnt++;
x /= 2;
}
ans += pow(2.0, 19 - cnt) / n;
}
ans /= pow(2.0, 19);
cout << setprecision(15) << ans << endl;
} | [] | 861,617 | 861,618 | u434662823 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sperase(v, n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807
int n, k;
long double ans;
signed main() {
cin >> n >> k;
rep1(i, n) {
int hoge = i;
long double tmp = 1.0 / n;
while (hoge < k)
hoge *= 2, tmp *= 1.0 / 2.0;
ans += tmp;
}
cout << fixed << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define sperase(v, n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807
int n, k;
long double ans;
signed main() {
cin >> n >> k;
rep1(i, n) {
int hoge = i;
long double tmp = 1.0 / n;
while (hoge < k)
hoge *= 2, tmp *= 1.0 / 2.0;
ans += tmp;
}
cout << setprecision(20) << ans << endl;
}
| [
"io.output.change",
"call.arguments.add"
] | 861,628 | 861,629 | u721367699 | cpp |
p03043 | // Author:- Yatin Patel
// Mail:- yatinpatel.gt@gmail.com
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FILEIN \
ifstream fin; \
fin.open("input.txt");
#define FILEOUT \
ofstream fout; \
fout.open("output.txt");
using namespace std;
using namespace __gnu_pbds;
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << " ";
err(++it, args...);
}
#define FAST \
ios::sync_with_stdio(false); \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define precision(x, d) cout << fixed << setprecision(d) << x
#define minQueue priority_queue<ll, vector<ll>, greater<ll>>
#define maxQueue priority_queue<ll, vector<ll>, less<ll>>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define RFOR(i, a, b) for (ll i = a; i > b; i--)
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update>
indexed_set;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
ll power(ll x, unsigned ll y) {
if (y == 0)
return 1;
else if (y % 2 == 0)
return power(x, y / 2) * power(x, y / 2);
else
return x * power(x, y / 2) * power(x, y / 2);
}
//#define fin cin
//#define fout cout
int main() {
FAST;
ll n, k;
cin >> n >> k;
vector<ll> v;
for (ll i = 1; i <= n; i++) {
ll temp = i;
ll cnt = 0;
while (temp <= k) {
cnt++;
temp *= 2;
}
v.push_back(cnt);
}
double ans = 0;
for (ll i = 0; i < v.size(); i++) {
if (v[i] == 0)
ans++;
else {
ll t = (pow(2, v[i]) + 0.4);
ans += (double)((double)1 / (double)t);
}
}
ans = (double)((double)ans / (double)n);
cout << fixed << setprecision(12);
cout << ans;
return 0;
} | // Author:- Yatin Patel
// Mail:- yatinpatel.gt@gmail.com
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FILEIN \
ifstream fin; \
fin.open("input.txt");
#define FILEOUT \
ofstream fout; \
fout.open("output.txt");
using namespace std;
using namespace __gnu_pbds;
#define error(args...) \
{ \
string _s = #args; \
replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); \
istream_iterator<string> _it(_ss); \
err(_it, args); \
}
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << " ";
err(++it, args...);
}
#define FAST \
ios::sync_with_stdio(false); \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define precision(x, d) cout << fixed << setprecision(d) << x
#define minQueue priority_queue<ll, vector<ll>, greater<ll>>
#define maxQueue priority_queue<ll, vector<ll>, less<ll>>
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define RFOR(i, a, b) for (ll i = a; i > b; i--)
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update>
indexed_set;
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
ll power(ll x, unsigned ll y) {
if (y == 0)
return 1;
else if (y % 2 == 0)
return power(x, y / 2) * power(x, y / 2);
else
return x * power(x, y / 2) * power(x, y / 2);
}
//#define fin cin
//#define fout cout
int main() {
FAST;
ll n, k;
cin >> n >> k;
vector<ll> v;
for (ll i = 1; i <= n; i++) {
ll temp = i;
ll cnt = 0;
while (temp < k) {
cnt++;
temp *= 2;
}
v.push_back(cnt);
}
double ans = 0;
for (ll i = 0; i < v.size(); i++) {
if (v[i] == 0)
ans++;
else {
ll t = (pow(2, v[i]) + 0.4);
ans += (double)((double)1 / (double)t);
}
}
ans = (double)((double)ans / (double)n);
cout << fixed << setprecision(12);
cout << ans;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,640 | 861,641 | u646513066 | cpp |
p03043 | #include "bits/stdc++.h"
using namespace std;
int main(void) {
int N, K, j;
double a, count, ans = 0.0;
cin >> N >> K;
a = (1.0 / N);
for (int i = 1; i <= N; i++) {
if (i >= K) {
ans += a;
} else {
j = i;
count = 1.0;
while (j <= K) {
j *= 2.0;
count *= 0.5;
}
ans += a * count;
}
}
printf("%.12f\n", ans);
return 0;
} | #include "bits/stdc++.h"
using namespace std;
int main(void) {
int N, K, j;
double a, count, ans = 0.0;
cin >> N >> K;
a = (1.0 / N);
for (int i = 1; i <= N; i++) {
if (i >= K) {
ans += a;
} else {
j = i;
count = 1.0;
while (j < K) {
j *= 2.0;
count *= 0.5;
}
ans += a * count;
}
}
printf("%.12f\n", ans);
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,655 | 861,656 | u780684946 | cpp |
p03043 | #include "bits/stdc++.h"
using namespace std;
int main(void) {
int N, K, j;
double a, count, ans = 0.0;
cin >> N >> K;
a = (100.0 / N);
for (int i = 1; i <= N; i++) {
if (i >= K) {
ans += a;
} else {
j = i;
count = 1.0;
while (j <= K) {
j *= 2.0;
count *= 0.5;
}
ans += a * count;
}
}
printf("%.12f\n", ans);
return 0;
} | #include "bits/stdc++.h"
using namespace std;
int main(void) {
int N, K, j;
double a, count, ans = 0.0;
cin >> N >> K;
a = (1.0 / N);
for (int i = 1; i <= N; i++) {
if (i >= K) {
ans += a;
} else {
j = i;
count = 1.0;
while (j < K) {
j *= 2.0;
count *= 0.5;
}
ans += a * count;
}
}
printf("%.12f\n", ans);
return 0;
} | [
"literal.number.change",
"assignment.value.change",
"expression.operation.binary.change",
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,657 | 861,656 | u780684946 | cpp |
p03043 | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ll hituyou = 0;
ll N, K;
double kakuritu1, kakuritu_sum = 0;
cin >> N >> K;
for (ll i = 1; i <= N; i++) {
while (i * (int)pow(2.0, hituyou * 1.0) <= K)
hituyou++;
// cout<<hituyou<<endl;
kakuritu_sum += (1.0 / (double)N) * pow((1.0 / 2.0), hituyou * 1.0);
hituyou = 0;
}
printf("%.20f\n", kakuritu_sum);
} | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
ll hituyou = 0;
ll N, K;
double kakuritu1, kakuritu_sum = 0;
cin >> N >> K;
for (ll i = 1; i <= N; i++) {
while (i * (int)pow(2.0, hituyou * 1.0) < K)
hituyou++;
// cout<<hituyou<<endl;
kakuritu_sum += (1.0 / (double)N) * pow((1.0 / 2.0), hituyou * 1.0);
hituyou = 0;
}
printf("%.12f\n", kakuritu_sum);
} | [
"expression.operator.compare.change",
"control_flow.loop.condition.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 861,670 | 861,671 | u530497183 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int main() {
int nn, k;
cin >> nn >> k;
long double ans = 0, a1 = 0;
ll n = 0, d = 1;
for (int i = 1; i <= nn; i++) {
int p = i, cc = 0, kk = 1;
while (p <= k) {
p = p * 2;
cc++;
kk = kk * 2;
}
kk = kk * nn;
ll tk = __gcd(d, 1LL * kk);
tk = 1LL * kk * d / tk;
ll a1 = tk / d;
n = a1 * n + (tk / kk);
d = tk;
}
ans = 1.0 * n / d;
cout << fixed << setprecision(10) << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;
int main() {
int nn, k;
cin >> nn >> k;
double ans = 0, a1 = 0;
ll n = 0, d = 1;
for (int i = 1; i <= nn; i++) {
int p = i, cc = 0, kk = 1;
while (p < k) {
p = p * 2;
cc++;
kk = kk * 2;
}
kk = kk * nn;
ll tk = __gcd(d, 1LL * kk);
tk = 1LL * kk * d / tk;
ll a1 = tk / d;
n = a1 * n + (tk / kk);
d = tk;
}
ans = 1.0 * n / d;
cout << fixed << setprecision(10) << ans << endl;
}
| [
"variable_declaration.type.narrow.change",
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,672 | 861,673 | u090794688 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define REP(i, a, n) for (int i = a; i < n; ++i)
#define RUP(a, b) ((a + b - 1) / (b))
#define SORTG(v) sort(v.begin(), v.end(), greater<>())
#define SORT(v) sort(v.begin(), v.end())
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX / 3
typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;
template <class T> void chmax(T &a, T b) {
if (a < b) {
a = b;
}
}
template <class T> void chmin(T &a, T b) {
if (a > b) {
a = b;
}
}
void YesNo(int a) {
if (a) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
void YESNO(int a) {
if (a) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
void AorB(int a, string b, string c) {
if (a) {
cout << b << endl;
} else {
cout << c << endl;
}
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void start() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
}
double coin(double s, double g) {
double ret = 0;
while (s < g) {
s *= 2;
ret++;
}
return ret;
}
signed main() {
start();
double n, k, ans = 0;
cin >> n >> k;
REP(i, 1, n + 1) { ans += pow(0.5, coin(i, k)); }
cout << fixed << setprecision(10) << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define REP(i, a, n) for (int i = a; i < n; ++i)
#define RUP(a, b) ((a + b - 1) / (b))
#define SORTG(v) sort(v.begin(), v.end(), greater<>())
#define SORT(v) sort(v.begin(), v.end())
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX / 3
typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;
template <class T> void chmax(T &a, T b) {
if (a < b) {
a = b;
}
}
template <class T> void chmin(T &a, T b) {
if (a > b) {
a = b;
}
}
void YesNo(int a) {
if (a) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
void YESNO(int a) {
if (a) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
void AorB(int a, string b, string c) {
if (a) {
cout << b << endl;
} else {
cout << c << endl;
}
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void start() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
}
double coin(double s, double g) {
double ret = 0;
while (s < g) {
s *= 2;
ret++;
}
return ret;
}
signed main() {
start();
double n, k, ans = 0;
cin >> n >> k;
REP(i, 1, n + 1) { ans += pow(0.5, coin(i, k)); }
cout << fixed << setprecision(10) << ans / n << endl;
}
| [
"expression.operation.binary.add"
] | 861,678 | 861,679 | u635484372 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
scanf("%d%d", &n, &k);
double ans = 0;
for (int i = 1; i <= n; ++i) {
int tmp = i;
int flag = 0;
for (int j = 0; j < 20; ++j) {
if (tmp >= k) {
flag = j;
break;
}
tmp *= 2;
}
ans += 1.0 / (1.0 * pow(2, flag));
}
ans = ans / (1.0 * n);
printf("%f", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
scanf("%d%d", &n, &k);
double ans = 0;
for (int i = 1; i <= n; ++i) {
int tmp = i;
int flag = 0;
for (int j = 0; j < 20; ++j) {
if (tmp >= k) {
flag = j;
break;
}
tmp *= 2;
}
ans += 1.0 / (1.0 * pow(2, flag));
}
ans = ans / (1.0 * n);
printf("%.10f", ans);
return 0;
}
| [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 861,688 | 861,689 | u963610246 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
double ans = 0.0;
for (int i = 1; i <= n; ++i) {
if (i >= k) {
ans += (1.000000000 / n);
} else {
double j = log2(k / i);
ans += (1.000000000 / n) * (pow((0.500000000), ceil(j)));
}
}
printf("%.9f", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
double ans = 0.0;
for (int i = 1; i <= n; ++i) {
if (i >= k) {
ans += (1.000000000 / n);
} else {
double j = log2(k) - log2(i);
ans += (1.000000000 / n) * (pow((0.500000000), ceil(j)));
}
}
printf("%.9f", ans);
return 0;
} | [
"call.arguments.change",
"expression.operation.binary.change"
] | 861,690 | 861,691 | u221811114 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
int main() {
double n, k;
cin >> n >> k;
double ans = 0;
for (ll in = 1; in <= n; in++) {
double tmp = 1.0 / n;
if (in < k) {
for (ll i = 1; i <= log2(k / in) + 1; i++)
tmp /= 2;
}
ans += tmp;
}
cout.precision(20);
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template <typename T1, typename T2> inline void chmin(T1 &a, T2 b) {
if (a > b)
a = b;
}
template <typename T1, typename T2> inline void chmax(T1 &a, T2 b) {
if (a < b)
a = b;
}
int main() {
double n, k;
cin >> n >> k;
double ans = 0;
for (ll in = 1; in <= n; in++) {
double tmp = 1.0 / n;
if (in < k) {
for (ll i = 1; i < log2(k / in) + 1; i++)
tmp /= 2;
}
ans += tmp;
}
cout.precision(20);
cout << ans << endl;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 861,694 | 861,695 | u318785595 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main() {
ll N, K;
cin >> N >> K;
long double ans = 0;
for (ll i = 1; i <= N; i++) {
long double tmp = 1;
ll score = i;
while (score < K) {
score *= 2;
tmp /= 2;
}
ans += tmp;
}
ans /= N;
cout << ans << "\n";
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
int main() {
ll N, K;
cin >> N >> K;
long double ans = 0;
for (ll i = 1; i <= N; i++) {
long double tmp = 1;
ll score = i;
while (score < K) {
score *= 2;
tmp /= 2;
}
ans += tmp;
}
ans /= N;
cout << setprecision(10) << ans << "\n";
return 0;
}
| [
"io.output.change"
] | 861,696 | 861,697 | u872581897 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
long double N, K;
cin >> N >> K;
long double ans = 0;
for (int i = 1; i <= N; i++) {
long double t = 1;
int j = i;
while (j < K) {
j = j * 2;
t = t / 2;
}
ans += t / N;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long double N, K;
cin >> N >> K;
long double ans = 0;
for (int i = 1; i <= N; i++) {
long double t = 1;
int j = i;
while (j < K) {
j = j * 2;
t = t / 2;
}
ans += t / N;
}
cout << setprecision(10) << ans << endl;
return 0;
}
| [
"io.output.change"
] | 861,706 | 861,707 | u077536797 | cpp |
p03043 | #include <cmath>
#include <cstdint>
#include <cstdio>
int main(void) {
int n, k;
std::scanf("%d %d", &n, &k);
double prob = 0.0;
for (int i = 1; i <= n; i++) {
int point = i;
double prob_1 = 1.0 / n;
while (point < k) {
point *= 2;
prob_1 /= 2.0;
}
prob += prob_1;
}
printf("%e", prob);
return 0;
}
| #include <cmath>
#include <cstdint>
#include <cstdio>
int main(void) {
int n, k;
std::scanf("%d %d", &n, &k);
double prob = 0.0;
for (int i = 1; i <= n; i++) {
int point = i;
double prob_1 = 1.0 / n;
while (point < k) {
point *= 2;
prob_1 /= 2.0;
}
prob += prob_1;
}
printf("%.15f", prob);
return 0;
}
| [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 861,725 | 861,726 | u012646025 | cpp |
p03043 | #include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
//#define sz(x) int((x).size())
// lcm = a*(b/gcd) least common multiple
// gcd: greatest common divisor
//
int gcd(int a, int b) {
if (a < b)
gcd(b, a);
int r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
int main() {
int N, K;
cin >> N >> K;
long long p = 0.;
int m[N + 1];
m[0] = 0;
for (int i = 1; i <= N; i++) {
if (i >= K) {
m[i] = 0.;
} else {
int rb = 17;
int lb = 0;
int tmp = 0;
while (rb - lb > 1) {
tmp = (rb + lb) / 2;
if (pow(2, tmp) <= (((double)K) / ((double)i))) {
lb = tmp;
} else {
rb = tmp;
}
}
m[i] = rb;
// cout << lb << " " << rb << endl;
// p = p + 1./((long long) pow(2,rb));
// cout << p << endl;
}
}
sort(m, m + N + 1);
long long bunbo = 0;
for (int i = 1; i <= N; i++) {
bunbo += pow(2., m[N] - m[i]);
}
long long bunshi = pow(2, m[N]);
// cout << bunbo << " " << bunshi << " " << endl;
cout << setprecision(12) << ((double)bunbo) / ((double)bunshi) / ((double)N)
<< endl;
}
| #include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
//#define sz(x) int((x).size())
// lcm = a*(b/gcd) least common multiple
// gcd: greatest common divisor
//
int gcd(int a, int b) {
if (a < b)
gcd(b, a);
int r;
while ((r = a % b)) {
a = b;
b = r;
}
return b;
}
int main() {
int N, K;
cin >> N >> K;
long long p = 0.;
int m[N + 1];
m[0] = 0;
for (int i = 1; i <= N; i++) {
if (i >= K) {
m[i] = 0.;
} else {
int rb = 17;
int lb = 0;
int tmp = 0;
while (rb - lb > 1) {
tmp = (rb + lb) / 2;
if (pow(2, tmp) < (((double)K) / ((double)i))) {
lb = tmp;
} else {
rb = tmp;
}
}
m[i] = rb;
// cout << lb << " " << rb << endl;
// p = p + 1./((long long) pow(2,rb));
// cout << p << endl;
}
}
sort(m, m + N + 1);
long long bunbo = 0;
for (int i = 1; i <= N; i++) {
bunbo += pow(2., m[N] - m[i]);
}
long long bunshi = pow(2, m[N]);
// cout << bunbo << " " << bunshi << " " << endl;
cout << setprecision(12) << ((double)bunbo) / ((double)bunshi) / ((double)N)
<< endl;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 861,737 | 861,738 | u949755084 | cpp |
p03043 | #include <math.h>
#include <stdio.h>
int main() {
int i, j, N, K, count;
long double kakuritu = 0.0;
scanf("%d", &N);
scanf("%d", &K);
for (i = 1; i <= N; i++) {
count = 0;
j = i;
while (j < K) {
j *= 2;
count++;
}
kakuritu += 1.0 / ((double)N * pow(2, count));
}
printf("%f\n", kakuritu);
return 0;
} | #include <math.h>
#include <stdio.h>
int main() {
int i, j, N, K, count;
double kakuritu = 0.0;
scanf("%d", &N);
scanf("%d", &K);
for (i = 1; i <= N; i++) {
count = 0;
j = i;
while (j < K) {
j *= 2;
count++;
}
kakuritu += 1.0 / ((double)N * pow(2, count));
}
printf("%.10lf\n", kakuritu);
return 0;
} | [
"variable_declaration.type.narrow.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 861,739 | 861,740 | u539916870 | cpp |
p03043 | #include <math.h>
#include <stdio.h>
int main() {
int i, j, N, K, count;
double kakuritu = 0.0;
scanf("%d", &N);
scanf("%d", &K);
for (i = 1; i <= N; i++) {
count = 0;
j = i;
while (j < K) {
j *= 2;
count++;
}
kakuritu += 1.0 / ((double)N * pow(2, count));
}
printf("%f\n", kakuritu);
return 0;
} | #include <math.h>
#include <stdio.h>
int main() {
int i, j, N, K, count;
double kakuritu = 0.0;
scanf("%d", &N);
scanf("%d", &K);
for (i = 1; i <= N; i++) {
count = 0;
j = i;
while (j < K) {
j *= 2;
count++;
}
kakuritu += 1.0 / ((double)N * pow(2, count));
}
printf("%.10lf\n", kakuritu);
return 0;
} | [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 861,741 | 861,740 | u539916870 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
double sum = 0, p, tmp;
for (int i = 1; i <= n; i++) {
if (i > m) {
sum += 1;
} else {
tmp = ceil(log2((float)m / i));
sum += pow(2, (-1) * tmp);
}
}
cout << (sum / n);
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
double sum = 0, p, tmp;
for (int i = 1; i <= n; i++) {
if (i > m) {
sum += 1;
} else {
tmp = ceil(log2((float)m / i));
sum += pow(2, (-1) * tmp);
}
}
cout << setprecision(10) << (sum / n);
}
| [
"io.output.change"
] | 861,742 | 861,743 | u576740505 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
float l = 0;
double ans = 0;
cin >> n >> k;
cout << setprecision(60);
for (int i = 1; i <= n; i++) {
double h = k / i;
double m = ceil(log2(h));
if (m <= 0) {
m = 1;
}
double j = 1 / pow(2, m);
if (k <= i) {
j = 1;
}
// cout<<j<<endl;
ans += j;
}
cout << ans / n;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
float n, k;
float l = 0;
double ans = 0;
cin >> n >> k;
cout << setprecision(60);
for (int i = 1; i <= n; i++) {
double h = k / i;
double m = ceil(log2(h));
if (m <= 0) {
m = 1;
}
// cout<<h<<" "<<m<<endl;
double j = 1 / pow(2, m);
if (k <= i) {
j = 1;
}
// cout<<j<<endl;
ans += j;
}
cout << ans / n;
}
| [
"variable_declaration.type.primitive.change"
] | 861,747 | 861,748 | u449417320 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
float l = 0;
double ans = 0;
cin >> n >> k;
cout << setprecision(60);
for (int i = 1; i <= n; i++) {
double h = k / i;
double m = ceil(log2(h));
if (m <= 0) {
m = 1;
}
double j = 1 / pow(2, m);
if (k <= i) {
j = 0.5;
}
// cout<<j<<endl;
ans += j;
}
cout << ans / n;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
float n, k;
float l = 0;
double ans = 0;
cin >> n >> k;
cout << setprecision(60);
for (int i = 1; i <= n; i++) {
double h = k / i;
double m = ceil(log2(h));
if (m <= 0) {
m = 1;
}
// cout<<h<<" "<<m<<endl;
double j = 1 / pow(2, m);
if (k <= i) {
j = 1;
}
// cout<<j<<endl;
ans += j;
}
cout << ans / n;
}
| [
"variable_declaration.type.primitive.change",
"literal.number.change",
"assignment.value.change"
] | 861,749 | 861,748 | u449417320 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define IOS \
std::ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
const int N = 1e6 + 20;
const ll Mod = 1e5;
const int INF = 0x3f3f3f3f;
int main() {
int n, k;
cin >> n >> k;
double a = (double)1.0 / n;
double rst = 0;
for (int i = 1; i <= n; i++) {
ll t = 0;
ll tmp = i;
while (tmp < k) {
tmp <<= 1;
t++;
}
// cout<<t<<endl;
rst += (double)a * pow(1.0 / 2, (double)t);
}
printf("%.12llf\n", rst);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define IOS \
std::ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
const int N = 1e6 + 20;
const ll Mod = 1e5;
const int INF = 0x3f3f3f3f;
int main() {
int n, k;
cin >> n >> k;
double a = (double)1.0 / n;
double rst = 0;
for (int i = 1; i <= n; i++) {
ll t = 0;
ll tmp = i;
while (tmp < k) {
tmp <<= 1;
t++;
}
// cout<<t<<endl;
rst += (double)a * pow(1.0 / 2, (double)t);
}
printf("%.12lf\n", rst);
return 0;
}
| [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 861,767 | 861,768 | u624688258 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
typedef long long lld;
int main() {
std::ios::sync_with_stdio(false);
lld t = 1;
// cin >> t;
while (t--) {
lld n, k;
cin >> n >> k;
lld ans = -1;
vector<lld> deno;
for (lld i = 1; i <= n; i++) {
lld sc = i;
lld turn = 0;
while (sc <= k) {
sc = 2 * sc;
turn++;
}
lld val = (1 << turn) * 1LL;
deno.push_back(val);
ans = max(ans, val);
}
lld num = 0;
for (lld i = 0; i < deno.size(); i++) {
num += (ans / deno[i]);
}
cout << fixed << setprecision(10) << (num * 1.0 / (ans * n)) << "\n";
}
} | #include <bits/stdc++.h>
using namespace std;
typedef long long lld;
int main() {
std::ios::sync_with_stdio(false);
lld t = 1;
// cin >> t;
while (t--) {
lld n, k;
cin >> n >> k;
lld ans = -1;
vector<lld> deno;
for (lld i = 1; i <= n; i++) {
lld sc = i;
lld turn = 0;
while (sc < k) {
sc = 2 * sc;
turn++;
}
lld val = (1 << turn) * 1LL;
deno.push_back(val);
ans = max(ans, val);
}
lld num = 0;
for (lld i = 0; i < deno.size(); i++) {
num += (ans / deno[i]);
}
// cout << num << " " << ans * n << "\n";
cout << fixed << setprecision(10) << (num * 1.0 / (ans * n)) << "\n";
}
} | [
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,774 | 861,775 | u915533570 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
double n, k;
scanf("%lf %lf", &n, &k);
double ans = 0, i = 1;
for (i = 1; i <= n; i++) {
if (i >= k) {
ans += 1;
continue;
}
int len = log2(k / i) + 1;
ans += 1 / pow(2, len);
}
ans /= n;
printf("%1.12lf", ans);
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
double n, k;
scanf("%lf %lf", &n, &k);
double ans = 0, i = 1;
for (i = 1; i <= n; i++) {
if (i >= k) {
ans += 1;
continue;
}
int len = log2((k - 1) / i) + 1;
ans += 1 / pow(2, len);
}
ans /= n;
printf("%1.12lf", ans);
}
| [
"call.arguments.change"
] | 861,780 | 861,781 | u790553153 | cpp |
p03043 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
double ans = 0;
for (size_t i = 1; i <= a; i++) {
int counter = 0;
int j = i;
while (j <= b) {
j *= 2;
counter++;
}
ans += 1.0 / a * pow(0.5, counter);
}
printf("%.12f", ans);
return 0;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
int main() {
double a, b;
cin >> a >> b;
double ans = 0;
for (size_t i = 1; i <= a; i++) {
int counter = 0;
int j = i;
while (j < b) {
j *= 2;
counter++;
}
ans += 1.0 / a * pow(0.5, counter);
}
printf("%.12f", ans);
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,786 | 861,787 | u315685304 | cpp |
p03043 | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
int main() {
long double N, K;
cin >> N;
cin >> K;
long double sum = 0;
for (long double i = 1; i <= N; i++) {
long double count = 0;
while (i * pow(2, count) <= K - 1)
count++;
sum += ((long double)1.0 / N) * ((long double)1.0 / pow(2, count));
}
printf("%.12f", sum);
return 0;
} | #include <algorithm>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <string>
#include <vector>
using namespace std;
int main() {
double N, K;
cin >> N;
cin >> K;
double sum = 0;
for (double i = 1; i <= N; i++) {
double count = 0;
while (i * pow(2, count) <= K - 1)
count++;
sum += ((double)1.0 / N) * ((double)1.0 / pow(2, count));
}
printf("%.12f", sum);
return 0;
} | [
"variable_declaration.type.narrow.change"
] | 861,807 | 861,808 | u998203751 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, i, j, b;
long double p = 0.0;
cin >> n >> k;
for (i = 1; i <= n; i++) {
b = i;
for (j = 0; b <= k; j++)
b *= 2;
p += ((long double)1 / (long double)n) *
((long double)1 / (long double)pow(2, j));
}
cout << setprecision(10) << p;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, i, j, b;
long double p = 0.0;
cin >> n >> k;
for (i = 1; i <= n; i++) {
b = i;
for (j = 0; b < k; j++)
b *= 2;
p += ((long double)1 / (long double)n) *
((long double)1 / (long double)pow(2, j));
}
cout << setprecision(10) << p;
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.for.condition.change",
"expression.off_by_one",
"expression.operation.binary.change"
] | 861,812 | 861,813 | u408650734 | cpp |
p03043 | #include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++)
#define rrange(i, n, m) for (ll i = n - 1; i = > m; i--)
#define MOD 1000000007
//#define MOD 998244353
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, K;
cin >> N >> K;
double out = 0;
double kaku = 1.0 / N;
double coin = 0.5;
rep(i, N) {
if (i + 1 >= K) {
out += kaku;
} else {
ll count = (ll)((log(K) / log(2))) - (log((i + 1)) / log(2)) + 1;
out += kaku * pow(coin, count);
}
}
cout << setprecision(16) << out << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++)
#define rrange(i, n, m) for (ll i = n - 1; i = > m; i--)
#define MOD 1000000007
//#define MOD 998244353
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, K;
cin >> N >> K;
double out = 0;
double kaku = 1.0 / N;
double coin = 0.5;
rep(i, N) {
if (i + 1 >= K) {
out += kaku;
} else {
ll count = ((log(K) / log(2))) - (log((i + 1)) / log(2)) + 0.99999;
out += kaku * pow(coin, count);
}
}
cout << setprecision(16) << out << endl;
return 0;
}
| [
"literal.number.change",
"expression.operation.binary.change"
] | 861,823 | 861,824 | u991974907 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) \
if (cond) \
break
#define ctif(cond) \
if (cond) \
continue
#define retif(cond) \
if (cond) \
return
void canhazfast() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T extgcd(T a, T b, T &x, T &y) {
T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
while (b) {
T q = a / b;
a %= b;
swap(a, b);
x0 -= q * x1;
swap(x0, x1);
y0 -= q * y1;
swap(y0, y1);
}
x = x0;
y = y0;
return a;
}
int ctz(uint x) { return __builtin_ctz(x); }
int ctzll(ull x) { return __builtin_ctzll(x); }
int clz(uint x) { return __builtin_clz(x); }
int clzll(ull x) { return __builtin_clzll(x); }
int popcnt(uint x) { return __builtin_popcount(x); }
int popcntll(ull x) { return __builtin_popcountll(x); }
int bsr(uint x) { return 31 ^ clz(x); }
int bsrll(ull x) { return 63 ^ clzll(x); }
#define MX 100016
double dp[MX];
int main() {
// canhazfast();
int n, k;
double ans = 0.0;
scanf("%d%d", &n, &k);
for (int i = k; i <= max(2 * k, n); ++i)
dp[i] = 1.0;
for (int i = k - 1; i > 0; --i)
dp[i] = 0.5 * dp[2 * i];
for (int i = 1; i <= n; ++i)
ans += dp[i];
ans /= n;
printf("%.10lf\n", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) \
if (cond) \
break
#define ctif(cond) \
if (cond) \
continue
#define retif(cond) \
if (cond) \
return
void canhazfast() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T extgcd(T a, T b, T &x, T &y) {
T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
while (b) {
T q = a / b;
a %= b;
swap(a, b);
x0 -= q * x1;
swap(x0, x1);
y0 -= q * y1;
swap(y0, y1);
}
x = x0;
y = y0;
return a;
}
int ctz(uint x) { return __builtin_ctz(x); }
int ctzll(ull x) { return __builtin_ctzll(x); }
int clz(uint x) { return __builtin_clz(x); }
int clzll(ull x) { return __builtin_clzll(x); }
int popcnt(uint x) { return __builtin_popcount(x); }
int popcntll(ull x) { return __builtin_popcountll(x); }
int bsr(uint x) { return 31 ^ clz(x); }
int bsrll(ull x) { return 63 ^ clzll(x); }
#define MX 100016
double dp[2 * MX];
int main() {
// canhazfast();
int n, k;
double ans = 0.0;
scanf("%d%d", &n, &k);
for (int i = k; i <= max(2 * k, n); ++i)
dp[i] = 1.0;
for (int i = k - 1; i > 0; --i)
dp[i] = 0.5 * dp[2 * i];
for (int i = 1; i <= n; ++i)
ans += dp[i];
ans /= n;
printf("%.10lf\n", ans);
return 0;
}
| [
"variable_declaration.array_dimensions.change",
"expression.operation.binary.add"
] | 861,825 | 861,826 | u840905163 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
double N, K;
cin >> N >> K;
double temp, count, sum = 0;
for (int i = 1; i <= N; i++) {
temp = i;
count = 1;
while (temp < K) {
temp *= 2;
count *= 2;
}
sum += 1 / count;
// cout<<count<<endl;
}
cout << sum / N << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
double N, K;
cin >> N >> K;
double temp, count, sum = 0;
for (int i = 1; i <= N; i++) {
temp = i;
count = 1;
while (temp < K) {
temp *= 2;
count *= 2;
}
sum += 1 / count;
// cout<<count<<endl;
}
cout << setprecision(20) << sum / N << endl;
} | [
"io.output.change"
] | 861,827 | 861,828 | u977554186 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
int n, k;
cin >> n >> k;
double a[n + 1];
a[0] = 0;
for (int i = 1; i <= n; i++) {
if (i >= k) {
a[i] = 1.0 / n;
continue;
}
int x = (int)log2(k / i) + 1;
a[i] = pow(0.5, x) / n;
}
double ans = 0.0;
for (int i = 1; i <= n; i++) {
ans += a[i];
}
printf("%.16f", ans);
} | #include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int main() {
int n, k;
cin >> n >> k;
double a[n + 1];
a[0] = 0;
for (int i = 1; i <= n; i++) {
if (i >= k) {
a[i] = 1.0 / n;
continue;
}
int x = (int)log2((k - 1) / i) + 1;
a[i] = pow(0.5, x) / n;
}
double ans = 0.0;
for (int i = 1; i <= n; i++) {
ans += a[i];
}
printf("%.16f", ans);
} | [
"call.arguments.change"
] | 861,833 | 861,834 | u313766957 | cpp |
p03043 | #include <cstdio>
using namespace std;
int n, k;
double expo(double a, int b) {
if (b == 0)
return 1;
if (b == 1)
return a;
double half = expo(a, b / 2);
half = (half * half);
if (b & 1)
half = half * a;
return half;
}
int main() {
scanf("%d%d", &n, &k);
double ans = 0;
for (int i = 1; i <= n; i++) {
int dice = i;
int cnt = 0;
while (dice < k) {
dice *= 2;
cnt++;
}
ans += (1.0 / (1.0 * i)) * expo(0.5, cnt);
}
printf("%.10lf\n", ans);
return 0;
} | #include <cstdio>
#include <iostream>
using namespace std;
int n, k;
double expo(double a, int b) {
if (b == 0)
return 1;
if (b == 1)
return a;
double half = expo(a, b / 2);
half = (half * half);
if (b & 1)
half = half * a;
return half;
}
int main() {
scanf("%d%d", &n, &k);
double ans = 0;
for (int i = 1; i <= n; i++) {
int dice = i;
int cnt = 0;
while (dice < k) {
dice *= 2;
cnt++;
}
ans += (1.0 / (1.0 * n)) * expo(0.5, cnt);
}
printf("%.10lf\n", ans);
return 0;
} | [
"import.add",
"assignment.value.change",
"identifier.change",
"expression.operation.binary.change"
] | 861,835 | 861,836 | u853418842 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
double n, k, ans = 0;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int now = i;
double temp = 1 / n;
while (now < k) {
now *= 2;
temp /= 2;
}
ans += temp;
}
printf("%f\n", ans);
return (0);
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
double n, k, ans = 0;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int now = i;
double temp = 1 / n;
while (now < k) {
now *= 2;
temp /= 2;
}
ans += temp;
}
printf("%.10f\n", ans);
return (0);
}
| [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 861,841 | 861,842 | u912752743 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define ppi pair<pii, int>
#define pip pair<int, pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i, l, r) for (int i = l; i <= r; i++)
#define LOR(i, l, r) for (ll i = l; i <= r; i++)
#define FORD(i, r, l) for (int i = r; i >= l; i--)
#define LORD(i, r, l) for (ll i = r; i >= l; i--)
#define INF 1000000000
#define CL(x) memset(x, 0, sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x - 'A')
#define LI(x) (int)(x - 'a')
typedef long long ll;
int N, K;
double ans;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> K;
FOR(i, 1, N) {
double p = 1 / (double)N;
int n = i;
while (n < K) {
p /= 2;
n *= 2;
}
ans += p;
}
cout << fixed << setprecision(7) << ans << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define ppi pair<pii, int>
#define pip pair<int, pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i, l, r) for (int i = l; i <= r; i++)
#define LOR(i, l, r) for (ll i = l; i <= r; i++)
#define FORD(i, r, l) for (int i = r; i >= l; i--)
#define LORD(i, r, l) for (ll i = r; i >= l; i--)
#define INF 1000000000
#define CL(x) memset(x, 0, sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x - 'A')
#define LI(x) (int)(x - 'a')
typedef long long ll;
int N, K;
double ans;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> N >> K;
FOR(i, 1, N) {
double p = 1 / (double)N;
int n = i;
while (n < K) {
p /= 2;
n *= 2;
}
ans += p;
}
cout << fixed << setprecision(10) << ans << '\n';
return 0;
}
| [
"literal.number.change",
"io.output.change"
] | 861,843 | 861,844 | u146724119 | cpp |
p03043 |
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define M_PI 3.14159265358979323846
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define FILL(a, x) memset(a, x, sizeof(a))
// repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
int main() {
int n, k;
cin >> n >> k;
double s = 0;
REP(i, n) {
double p = 1.0;
int x = i + 1;
while (x <= k) {
p *= 0.5;
x *= 2;
}
s += p;
}
printf("%.12f\n", s / n);
return 0;
} | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define M_PI 3.14159265358979323846
using namespace std;
// conversion
//------------------------------------------
inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T> inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
}
// typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
// container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i, c) \
for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define FILL(a, x) memset(a, x, sizeof(a))
// repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007
int main() {
int n, k;
cin >> n >> k;
double s = 0;
REP(i, n) {
double p = 1.0;
int x = i + 1;
while (x < k) {
p *= 0.5;
x *= 2;
}
s += p;
}
printf("%.12f\n", s / n);
return 0;
} | [
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,845 | 861,846 | u614497125 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
ll inv(ll a, ll b) { return (a > 1 ? b - inv(b % a, a) * b / a : 1); }
#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL << 62);
const int iinf = (1 << 30);
ld ans;
int n, k;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
if (i >= k)
ans += 1.0 / n;
else {
ld cur = 1.0 / n;
int score = i;
while (score <= k)
cur *= 0.5, score *= 2;
ans += cur;
}
}
cout << fixed << setprecision(10) << ans;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
ll inv(ll a, ll b) { return (a > 1 ? b - inv(b % a, a) * b / a : 1); }
#define rc(s) return cout << s, 0
#define fi first
#define se second
#define L (nod << 1)
#define R (L | 1)
#define smax(X, Y) ((X) > (Y) ? (X) : (Y))
#define smin(X, Y) ((X) < (Y) ? (X) : (Y))
const ld e = 2.71828182845904523536028747;
const ld PI = 3.14159265359;
const ll inf = (1LL << 62);
const int iinf = (1 << 30);
ld ans;
int n, k;
int main() {
cin >> n >> k;
for (int i = 1; i <= n; i++) {
if (i >= k)
ans += 1.0 / n;
else {
ld cur = 1.0 / n;
int score = i;
while (score < k)
cur *= 0.5, score *= 2;
ans += cur;
}
}
cout << fixed << setprecision(10) << ans;
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,847 | 861,848 | u360501542 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
double p = 0;
int x = 1;
for (int i = N; i > 0; i--) {
while (x < 1.0 * K / i) {
x *= 2;
}
p += 1.0 / x;
}
cout << 1.0 * p / N << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
double p = 0;
int x = 1;
for (int i = N; i > 0; i--) {
while (x < 1.0 * K / i) {
x *= 2;
}
p += 1.0 / x;
}
cout << setprecision(15) << 1.0 * p / N << endl;
return 0;
}
| [
"io.output.change"
] | 861,882 | 861,883 | u269804060 | cpp |
p03043 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
using ll = __int64_t;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};
void solve() {
double n, k;
double res = 0.0;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int current = i;
if (current < k) {
int temp = 0;
while (current < k) {
current *= 2;
temp++;
}
res += (1.0 / n) * pow(0.5, temp);
} else {
res += (1.0 / n);
}
}
cout << res << endl;
}
int main() {
solve();
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define mod 1000000007
#define INF2 9999999999
#define INF (1 << 30)
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
using ll = __int64_t;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};
void solve() {
double n, k;
double res = 0.0;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int current = i;
if (current < k) {
int temp = 0;
while (current < k) {
current *= 2;
temp++;
}
res += (1.0 / n) * pow(0.5, temp);
} else {
res += (1.0 / n);
}
}
cout << setprecision(12) << res << endl;
}
int main() {
solve();
return 0;
} | [
"io.output.change"
] | 861,886 | 861,887 | u679071005 | cpp |
p03043 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define lol long long
int main() {
double N, K;
cin >> N >> K;
double ans = 0.0;
for (int i = 1; i <= N; i++) {
int count = 0;
if (i >= K) {
ans += 1 / N;
} else {
for (int j = i; j <= K; j *= 2) {
count++;
}
ans += (1 / N) * pow(0.5, count);
}
}
cout << fixed << setprecision(15) << ans << endl;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <math.h>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define lol long long
int main() {
double N, K;
cin >> N >> K;
double ans = 0.0;
for (int i = 1; i <= N; i++) {
int count = 0;
if (i >= K) {
ans += 1 / N;
} else {
for (int j = i; j < K; j *= 2) {
count++;
}
ans += (1 / N) * pow(0.5, count);
}
}
cout << fixed << setprecision(15) << ans << endl;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 861,890 | 861,891 | u086366728 | cpp |
p03043 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
//ๅฎ็พฉๅ ดๆ//
int i, j, k, l, m, n;
double W, N, K;
////////////
int main() {
cin >> N >> K;
double ans = 0;
for (i = 1; i <= N; i++) {
double A = 1 / N;
int score = i;
while (score < K) {
score *= 2;
double b = 2.000000000;
A = A / b;
}
ans += A;
}
cout << ans;
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
//ๅฎ็พฉๅ ดๆ//
int i, j, k, l, m, n;
double W, N, K;
////////////
int main() {
cin >> N >> K;
double ans = 0;
for (i = 1; i <= N; i++) {
double A = 1 / N;
int score = i;
while (score < K) {
score *= 2;
double b = 2.000000000;
A = A / b;
}
ans += A;
}
cout << setprecision(12) << ans;
} | [
"io.output.change"
] | 861,892 | 861,893 | u916974091 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
typedef long long int lli;
typedef pair<int, int> P;
int main() {
lli n, k;
cin >> n >> k;
lli num;
lli bunbo;
double ans = 0;
for (lli i = 1; i < n + 1; i++) {
// i ใๅบใใจใ
num = i;
bunbo = 1;
while (true) {
if (num >= k)
break;
bunbo *= 2;
num *= 2;
}
ans += 1.0 / bunbo;
}
cout << ans / n << endl;
}
| #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
typedef long long int lli;
typedef pair<int, int> P;
int main() {
lli n, k;
cin >> n >> k;
lli num;
lli bunbo;
double ans = 0;
for (lli i = 1; i < n + 1; i++) {
// i ใๅบใใจใ
num = i;
bunbo = 1;
while (true) {
if (num >= k)
break;
bunbo *= 2;
num *= 2;
}
ans += 1.0 / bunbo;
}
cout << setprecision(13) << ans / n << endl;
}
| [
"io.output.change"
] | 861,894 | 861,895 | u058297300 | cpp |
p03043 | #include <algorithm>
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int n, k;
cin >> n >> k;
double sum = 0;
for (int i = 1; i < n + 1; i++) {
int i2 = i;
for (int j = 0; j < 20; j++) {
if (k <= i) {
sum += pow(2, 20 - j);
j += 114514;
}
i = i * 2;
}
i = i2;
}
double ans = sum / (1048576 * n);
printf("%45Lf\n", ans);
} | #include <algorithm>
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
signed main() {
int n, k;
cin >> n >> k;
double sum = 0;
for (int i = 1; i < n + 1; i++) {
int i2 = i;
for (int j = 0; j < 20; j++) {
if (k <= i) {
sum += pow(2, 20 - j);
j += 114514;
}
i = i * 2;
}
i = i2;
}
double ans = sum / (1048576 * n);
printf("%.45Lf\n", ans);
}
| [
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 861,902 | 861,903 | u942393279 | cpp |
p03043 | #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
double n, k, m, cnt;
cin >> n >> k;
double ans;
for (int i = 1; i <= n; i++) {
m = i;
cnt = 0;
if (i >= k) {
ans += 1 / n;
continue;
}
while (m * 2 <= k) {
m *= 2;
cnt++;
}
cnt++;
ans += 1 / (n * pow(2, cnt));
}
printf("%.12lf\n", ans);
return 0;
}
| #include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main() {
double n, k, m, cnt;
cin >> n >> k;
double ans;
for (int i = 1; i <= n; i++) {
m = i;
cnt = 0;
if (i >= k) {
ans += 1 / n;
continue;
}
while (m * 2 < k) {
m *= 2;
cnt++;
}
cnt++;
ans += 1 / (n * pow(2, cnt));
}
printf("%.12lf\n", ans);
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,906 | 861,907 | u620735210 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
int main() {
int N, K;
cin >> N >> K;
double res = 0;
for (int i = 1; i <= N; ++i) {
for (int j = 0; j <= 20; ++j) {
int temp = i * int(pow(2, j));
if (temp >= K) {
res += 1.0 / double(N * pow(2, j));
break;
}
}
}
print(res);
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
int main() {
int N, K;
cin >> N >> K;
double res = 0;
for (int i = 1; i <= N; ++i) {
for (int j = 0; j <= 20; ++j) {
int temp = i * int(pow(2, j));
if (temp >= K) {
res += 1.0 / double(N * pow(2, j));
break;
}
}
}
print(setprecision(10) << res);
} | [
"expression.operation.binary.add"
] | 861,910 | 861,911 | u319234342 | cpp |
p03043 | #include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
int N, K;
int u, d;
void solve() {
int t[20] = {1};
for (int i = 1; i < 20; i++) {
t[i] = 2 * t[i - 1];
}
int w = 0;
for (int i = 1; i < K; i *= 2) {
w++;
}
d = N * t[w];
for (int i = 1; i <= N; i++) {
for (int j = 0; j < 20; j++) {
if (t[j] * i > K) {
u += t[w - j];
break;
}
}
}
cout << fixed << setprecision(13) << (double)u / (double)d << endl;
}
signed main() {
cin >> N >> K;
solve();
return 0;
}
| #include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
int N, K;
int u, d;
void solve() {
int t[20] = {1};
for (int i = 1; i < 20; i++) {
t[i] = 2 * t[i - 1];
}
int w = 0;
for (int i = 1; i < K; i *= 2) {
w++;
}
d = N * t[w];
for (int i = 1; i <= N; i++) {
for (int j = 0; j < 20; j++) {
if (t[j] * i >= K) {
u += t[w - j];
break;
}
}
}
cout << fixed << setprecision(13) << u / (double)d << endl;
}
signed main() {
cin >> N >> K;
solve();
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 861,914 | 861,915 | u070600790 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
// __builtin_popcount
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
double n, k;
cin >> n >> k;
double ans = 0;
for (int i = 1; i <= n; i++) {
if (i > k) {
ans += 1.0 / n;
continue;
}
ans += (1.0 / n) *
(1.0 /
(long double)(1 << (int)(ceil(log2(ceil((k + 1) / (double)(i)))))));
}
// cout << (1.0 / n) * (1.0 / (long double)(1 << (int)(ceil(log2(ceil((k + 1)
// / (double)(5))))))) << endl;
cout << setprecision(10) << ans;
} | #include <bits/stdc++.h>
using namespace std;
// __builtin_popcount
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long double n, k;
cin >> n >> k;
long double ans = 0;
for (int i = 1; i <= n; i++) {
if (i >= k) {
ans += 1.0 / n;
continue;
}
ans +=
(1.0 / n) *
(1.0 / (long double)(1 << (int)(ceil(log2(ceil((k) / (double)(i)))))));
// if (i <= 10){
// cout << i << ' ' << ans << '\n';
// }
}
// cout << (1.0 / n) * (1.0 / (long double)(1 << (int)(ceil(log2(ceil((k + 1)
// / (double)(5))))))) << endl;
cout << setprecision(20) << ans;
} | [
"variable_declaration.type.widen.change",
"expression.operator.compare.change",
"control_flow.branch.if.condition.change",
"expression.operation.binary.remove",
"literal.number.change",
"io.output.change"
] | 861,916 | 861,917 | u170407818 | cpp |
p03043 | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
double res = 0;
for (int i = 1; i <= n; ++i) {
if (i >= k)
res += 1;
else {
res += pow(0.5, __lg(2 * (k + i - 1) / i - 1));
}
}
res /= n;
cout << fixed << setprecision(15) << res << '\n';
} | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
template <class T = int> using V = vector<T>;
template <class T = int> using VV = V<V<T>>;
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, k;
cin >> n >> k;
double res = 0;
for (int i = 1; i <= n; ++i) {
if (i >= k)
res += 1;
else {
res += pow(0.5, __lg(2 * ((k + i - 1) / i) - 1));
}
}
res /= n;
cout << fixed << setprecision(15) << res << '\n';
} | [
"call.arguments.change"
] | 861,920 | 861,921 | u536580583 | cpp |
p03043 | /*
*/
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#include <assert.h>
#include <memory.h>
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery
#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300
#define ldouble long double
using namespace std;
#define bs 1000000007
const int N = 1100031;
int n, k;
long double ans;
int solver(int x) {
int res = 0;
while (x <= k)
x *= 2, res++;
return res;
}
int main() {
// freopen("apache.in","r",stdin);
// freopen("apache.out","w",stdout);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
// cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int here = solver(i);
double t = pow(1.0 / 2.0, here);
ans += t * 1.0 / n;
}
cout.precision(12);
cout << fixed << ans << endl;
// cin.get(); cin.get();
return 0;
}
| /*
*/
#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#include <assert.h>
#include <memory.h>
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh
#define hash asdgasdgasdgdfrywewery
#define eps 1e-9
#define M_PI 3.141592653589793
#define bsize 300
#define ldouble long double
using namespace std;
#define bs 1000000007
const int N = 1100031;
int n, k;
long double ans;
int solver(int x) {
int res = 0;
while (x < k)
x *= 2, res++;
return res;
}
int main() {
// freopen("apache.in","r",stdin);
// freopen("apache.out","w",stdout);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0);
// cin.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
int here = solver(i);
double t = pow(1.0 / 2.0, here);
ans += t * 1.0 / n;
}
cout.precision(12);
cout << fixed << ans << endl;
// cin.get(); cin.get();
return 0;
}
| [
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,922 | 861,923 | u806695213 | cpp |
p03043 | /*
____________________________________________________________
| |
| Author: ay2306 |
|____________________________________________________________|
*/
#include <bits/stdc++.h>
// For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test \
int t; \
cin >> t; \
while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(); \
cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define ord_set \
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
const ll maxn = 1e5;
double ans = 0;
ll n, k;
double next(ll s, double c) {
if (s > k)
return c;
return next(2 * s, c / 2);
}
int main() {
cin >> n >> k;
loop(i, 1, n + 1) { ans += (next(i, 1.0) / n); }
printf("%.10f", ans);
return 0;
} | /*
____________________________________________________________
| |
| Author: ay2306 |
|____________________________________________________________|
*/
#include <bits/stdc++.h>
// For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test \
int t; \
cin >> t; \
while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST \
ios_base::sync_with_stdio(false); \
cin.tie(); \
cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define ord_set \
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
const ll maxn = 1e5;
double ans = 0;
ll n, k;
double next(ll s, double c) {
if (s >= k)
return c;
return next(2 * s, c / 2);
}
int main() {
cin >> n >> k;
loop(i, 1, n + 1) { ans += (next(i, 1.0) / n); }
printf("%.10f", ans);
return 0;
} | [
"expression.operator.compare.change",
"control_flow.branch.if.condition.change"
] | 861,924 | 861,925 | u669067427 | cpp |
p03043 | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cassert>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i, n) for (long long i = 0; i < n; ++i)
int main() {
int n, k;
cin >> n >> k;
cout << fixed << setprecision(20);
double ans = 0;
for (int i = 1; i <= n; ++i) {
double percent = 1;
int now = i;
while (now <= k) {
percent /= 2.00000;
now *= 2;
}
ans += percent / (double)n;
}
cout << ans << endl;
} | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cassert>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i, n) for (long long i = 0; i < n; ++i)
int main() {
int n, k;
cin >> n >> k;
cout << fixed << setprecision(20);
long double ans = 0;
for (int i = 1; i <= n; ++i) {
long double percent = 1;
int now = i;
while (now < k) {
percent /= 2.00000;
now *= 2;
}
ans += percent / (long double)n;
}
cout << ans << endl;
} | [
"variable_declaration.type.widen.change",
"expression.operator.compare.change",
"control_flow.loop.condition.change"
] | 861,926 | 861,927 | u545022164 | cpp |
p03044 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
vector<vector<pair<int, int>>> g;
vector<int> res;
void dfs(int v, int p, int c) {
res[v] = c;
for (auto e : g[v]) {
if (e.first == p)
continue;
if (e.second % 2 == 0)
dfs(e.first, v, c);
else
dfs(e.first, v, c + 1);
}
}
int main() {
int n;
cin >> n;
g.resize(n);
rep(i, n - 1) {
int v, u, w;
cin >> v >> u >> w;
v--;
u--;
g[v].push_back({u, w});
g[u].push_back({v, w});
}
res.resize(n);
dfs(0, -1, 0);
rep(i, n) { cout << res[i] << endl; }
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
vector<vector<pair<int, int>>> g;
vector<int> res;
void dfs(int v, int p, int c) {
res[v] = c;
for (auto e : g[v]) {
if (e.first == p)
continue;
if (e.second % 2 == 0)
dfs(e.first, v, c % 2);
else
dfs(e.first, v, (c + 1) % 2);
}
}
int main() {
int n;
cin >> n;
g.resize(n);
rep(i, n - 1) {
int v, u, w;
cin >> v >> u >> w;
v--;
u--;
g[v].push_back({u, w});
g[u].push_back({v, w});
}
res.resize(n);
dfs(0, -1, 0);
rep(i, n) { cout << res[i] << endl; }
} | [
"call.arguments.change",
"call.arguments.add"
] | 861,933 | 861,934 | u489823438 | cpp |
p03044 | #include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
class EdgeInfo {
public:
EdgeInfo(int cap) : cap_(cap), orig_cap_(cap) {}
int cap_;
int orig_cap_;
};
class Edge {
public:
Edge(unsigned int s, unsigned int t, EdgeInfo ei) : s_(s), t_(t), ei_(ei) {}
unsigned int s_, t_;
EdgeInfo ei_;
};
// unordered graph
class Graph {
public:
// key: to
using Edges = std::map<unsigned int, EdgeInfo>;
// n_v: number of verteces
Graph(unsigned int n_v);
// add edge
// return true: success, false: failed
bool add_edge(unsigned int from, unsigned int to, EdgeInfo ei);
void show() const {
for (auto it = edges_.begin(); it != edges_.end(); it++) {
auto idx = std::distance(edges_.begin(), it);
std::for_each(it->begin(), it->end(), [idx](auto &item) -> void {
std::cout << idx << "," << item.first << "," << item.second.cap_
<< std::endl;
});
}
}
// number of vertexes
unsigned int n_v_;
// edge information
// Be arere edges_[i][j] results in compile error
// because EdgeInfo default constructor is not defined.
// Access it edges[i].at[j].
// ([] with missing key allocate default instance).
std::vector<Edges> edges_;
};
Graph::Graph(unsigned int n_v) : n_v_(n_v) { edges_.resize(n_v); }
bool Graph::add_edge(unsigned int from, unsigned int to, EdgeInfo ei) {
if (from >= n_v_ || to >= n_v_ ||
edges_[from].find(to) != edges_[from].end()) {
std::cout << "add_edge failed: " << from << ", " << to << std::endl;
return false;
}
edges_[from].insert(std::make_pair(to, ei));
return true;
}
int reverse(int i) { return i == 0 ? 1 : 0; }
/**
* color -1: undef, 0 or 1
*/
void set_color_dfs(unsigned int s, const Graph &g, std::vector<bool> &seen,
std::vector<int> &color) {
Graph::Edges edges = g.edges_[s];
seen[s] = true;
for (const auto &e : edges) {
auto to = e.first;
auto ei = e.second;
if (seen[to])
continue;
seen[to] = true;
color[to] = ei.cap_ % 2 == 0 ? color[s] : reverse(color[s]);
set_color_dfs(to, g, seen, color);
}
}
int main() {
int N;
std::cin >> N;
Graph g(N);
for (int i = 0; i < N; i++) {
unsigned int u, v, w;
std::cin >> u >> v >> w;
u--;
v--; // 0-origin
g.add_edge(u, v, w);
g.add_edge(v, u, w);
}
std::vector<bool> seen(N);
std::vector<int> color;
color.assign(N, -1);
color[0] = 0;
set_color_dfs(0, g, seen, color);
for (auto c : color) {
std::cout << c << std::endl;
}
return 0;
}
| #include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
class EdgeInfo {
public:
EdgeInfo(int cap) : cap_(cap), orig_cap_(cap) {}
int cap_;
int orig_cap_;
};
class Edge {
public:
Edge(unsigned int s, unsigned int t, EdgeInfo ei) : s_(s), t_(t), ei_(ei) {}
unsigned int s_, t_;
EdgeInfo ei_;
};
// unordered graph
class Graph {
public:
// key: to
using Edges = std::map<unsigned int, EdgeInfo>;
// n_v: number of verteces
Graph(unsigned int n_v);
// add edge
// return true: success, false: failed
bool add_edge(unsigned int from, unsigned int to, EdgeInfo ei);
void show() const {
for (auto it = edges_.begin(); it != edges_.end(); it++) {
auto idx = std::distance(edges_.begin(), it);
std::for_each(it->begin(), it->end(), [idx](auto &item) -> void {
std::cout << idx << "," << item.first << "," << item.second.cap_
<< std::endl;
});
}
}
// number of vertexes
unsigned int n_v_;
// edge information
// Be arere edges_[i][j] results in compile error
// because EdgeInfo default constructor is not defined.
// Access it edges[i].at[j].
// ([] with missing key allocate default instance).
std::vector<Edges> edges_;
};
Graph::Graph(unsigned int n_v) : n_v_(n_v) { edges_.resize(n_v); }
bool Graph::add_edge(unsigned int from, unsigned int to, EdgeInfo ei) {
if (from >= n_v_ || to >= n_v_ ||
edges_[from].find(to) != edges_[from].end()) {
std::cout << "add_edge failed: " << from << ", " << to << std::endl;
return false;
}
edges_[from].insert(std::make_pair(to, ei));
return true;
}
int reverse(int i) { return i == 0 ? 1 : 0; }
/**
* color -1: undef, 0 or 1
*/
void set_color_dfs(unsigned int s, const Graph &g, std::vector<bool> &seen,
std::vector<int> &color) {
Graph::Edges edges = g.edges_[s];
seen[s] = true;
for (const auto &e : edges) {
auto to = e.first;
auto ei = e.second;
if (seen[to])
continue;
seen[to] = true;
color[to] = ei.cap_ % 2 == 0 ? color[s] : reverse(color[s]);
set_color_dfs(to, g, seen, color);
}
}
int main() {
int N;
std::cin >> N;
Graph g(N);
for (int i = 0; i < N - 1; i++) {
unsigned int u, v, w;
std::cin >> u >> v >> w;
u--;
v--; // 0-origin
g.add_edge(u, v, w);
g.add_edge(v, u, w);
// std::cout << "inserted " << i << "-th edges"
// << " u = " << u
// << " v = " << v
// << std::endl;
// g.show();
}
std::vector<bool> seen(N);
std::vector<int> color;
color.assign(N, -1);
color[0] = 0;
set_color_dfs(0, g, seen, color);
for (auto c : color) {
std::cout << c << std::endl;
}
return 0;
}
| [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 861,943 | 861,944 | u306805217 | cpp |
p03044 | // Even Relation
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i, x, y) for (ll i = x; i < y; i++)
#define nvarep(n, a) \
ll n; \
cin >> n; \
vector<ll> a(n); \
rep(i, 0, n) cin >> a[i]
#define vecrep(n, a, type) \
vector<type> a(n); \
rep(i, 0, n) cin >> a[i]
#define lcm(a, b) (a / __gcd(a, b) * b)
#define range(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll, ll>;
using graph = vector<vector<P>>;
const int inf = 2147483647; // 2*10^9
const ll INF = 9223372036854775807; // 9*10^18
graph g;
vector<int> ans;
//็พๅจใปไธๅๅใป่ฒ
void dfs(int v, int p, int c) {
ans[v] = c;
for (auto i : g[v]) {
if (i.first == p)
continue;
else if (1 & (i.second + c))
dfs(i.first, v, c ^ 1);
else
dfs(i.first, v, c);
}
}
signed main() {
int n;
cin >> n;
g.resize(n);
ans.resize(n, 0);
rep(i, 0, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
g[a].pb(mp(b, c));
g[b].pb(mp(a, c));
}
dfs(0, -1, 0);
rep(i, 0, n) cout << ans[i] << nnn;
return 0;
} | // Even Relation
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i, x, y) for (ll i = x; i < y; i++)
#define nvarep(n, a) \
ll n; \
cin >> n; \
vector<ll> a(n); \
rep(i, 0, n) cin >> a[i]
#define vecrep(n, a, type) \
vector<type> a(n); \
rep(i, 0, n) cin >> a[i]
#define lcm(a, b) (a / __gcd(a, b) * b)
#define range(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using P = pair<ll, ll>;
using graph = vector<vector<P>>;
const int inf = 2147483647; // 2*10^9
const ll INF = 9223372036854775807; // 9*10^18
graph g;
vector<int> ans;
//็พๅจใปไธๅๅใป่ฒ
void dfs(int v, int p, int c) {
ans[v] = c;
for (auto i : g[v]) {
if (i.first == p)
continue;
else if (1 & i.second)
dfs(i.first, v, c ^ 1);
else
dfs(i.first, v, c);
}
}
signed main() {
int n;
cin >> n;
g.resize(n);
ans.resize(n, 0);
rep(i, 0, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
g[a].pb(mp(b, c));
g[b].pb(mp(a, c));
}
dfs(0, -1, 0);
rep(i, 0, n) cout << ans[i] << nnn;
return 0;
} | [
"control_flow.branch.if.condition.change"
] | 861,945 | 861,946 | u663842230 | cpp |
p03044 | #include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge {
int to;
int weight;
Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};
void dfs(Graph &G, vector<int> &res, int v, int color, int p = -1) {
res[v] = color;
for (auto u : G[v]) {
if (u.to == p)
continue;
if (u.weight % 2 == 0) {
dfs(G, res, u.to, res[v], v);
} else {
if (color == 0) {
dfs(G, res, u.to, 1, v);
} else {
dfs(G, res, u.to, 1, v);
}
}
}
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
Graph G(N);
for (int i = 0; i < N - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--, v--;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
vector<int> res(N, -1);
dfs(G, res, 0, 0);
for (auto it : res) {
cout << it << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge {
int to;
int weight;
Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};
void dfs(Graph &G, vector<int> &res, int v, int color, int p = -1) {
res[v] = color;
for (auto u : G[v]) {
if (u.to == p)
continue;
if (u.weight % 2 == 0) {
dfs(G, res, u.to, res[v], v);
} else {
if (color == 0) {
dfs(G, res, u.to, 1, v);
} else {
dfs(G, res, u.to, 0, v);
}
}
}
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
Graph G(N);
for (int i = 0; i < N - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--, v--;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
vector<int> res(N, -1);
dfs(G, res, 0, 0);
for (auto it : res) {
cout << it << endl;
}
return 0;
}
| [
"literal.number.change",
"call.arguments.change"
] | 861,977 | 861,978 | u665871498 | cpp |
p03044 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-10)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
vector<long long> enum_divisors(long long N) {
vector<long long> res;
for (long long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
res.push_back(i);
if (N / i != i)
res.push_back(N / i);
}
}
sort(res.begin(), res.end());
return res;
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
using Graph = vector<VE>;
class UnionFind {
public:
vector<ll> par; // ๅๅ
ใฎ่ฆชใ่กจใ้
ๅ
vector<ll> siz; // ็ด ้ๅใฎใตใคใบใ่กจใ้
ๅ(1 ใงๅๆๅ)
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i; // ๅๆใงใฏ่ฆชใฏ่ชๅ่ช่บซ
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i; // ๅๆใงใฏ่ฆชใฏ่ชๅ่ช่บซ
}
// Member Function
// Find
ll root(ll x) { // ๆ นใฎๆค็ดข
while (par[x] != x) {
x = par[x] = par[par[x]]; // x ใฎ่ฆชใฎ่ฆชใ x ใฎ่ฆชใจใใ
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
// merge technique๏ผใใผใฟๆง้ ใใใผใธใใใใฏ๏ผๅฐใๅคงใซใใฃใคใใ๏ผ
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { // ้ฃ็ตๅคๅฎ
return root(x) == root(y);
}
ll size(ll x) { // ็ด ้ๅใฎใตใคใบ
return siz[root(x)];
}
};
VE depth;
void dfs(const vector<vector<edge>> &G, int v, int p, int d) {
depth[v] = d;
for (auto u : G[v]) {
if (u.to == p)
continue;
dfs(G, u.to, v, d + u.cost);
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(20);
// combination com(200010);
int n;
cin >> n;
depth.resize(n);
vector<vector<edge>> G(n);
rep(i, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
G[a].push_back({b, c});
G[b].push_back({a, b});
}
dfs(G, 0, -1, 0);
rep(i, n) {
if (depth[i] % 2)
cout << 1 << endl;
else
cout << 0 << endl;
}
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define P pair<ll, ll>
#define sz(x) (ll) x.size()
#define ALL(x) (x).begin(), (x).end()
#define ALLR(x) (x).rbegin(), (x).rend()
#define VE vector<ll>
#define COUT(x) cout << (x) << endl
#define MA map<ll, ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll, VE, greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define EPS (1e-10)
#define pb push_back
long long MOD = 1000000007;
// const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a) {
if ((x += a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((x += MOD - a.x) >= MOD)
x -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime MOD
mint inv() const { return pow(MOD - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct Sieve {
int n;
vector<int> f, primes;
Sieve(int n = 1) : n(n), f(n + 1) {
f[0] = f[1] = -1;
for (ll i = 2; i <= n; ++i) {
if (f[i])
continue;
primes.push_back(i);
f[i] = i;
for (ll j = i * i; j <= n; j += i) {
if (!f[j])
f[j] = i;
}
}
}
bool isPrime(int x) { return f[x] == x; }
vector<int> factorList(int x) {
vector<int> res;
while (x != 1) {
res.push_back(f[x]);
x /= f[x];
}
return res;
}
vector<P> factor(int x) {
vector<int> fl = factorList(x);
if (fl.size() == 0)
return {};
vector<P> res(1, P(fl[0], 0));
for (int p : fl) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
};
template <class t> t gcd(t a, t b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
bool prime(ll n) {
for (ll i = 2; i <= sqrt(n); i++) {
if (n % i == 0)
return false;
}
return n != 1;
}
map<ll, ll> prime_factor(ll n) {
map<ll, ll> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
ll modinv(ll a, ll m) {
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
vector<pair<char, int>> RunLength(string s) {
if (s.size() == 0)
return {};
vector<pair<char, int>> res(1, pair<char, int>(s[0], 0));
for (char p : s) {
if (res.back().first == p) {
res.back().second++;
} else {
res.emplace_back(p, 1);
}
}
return res;
}
// Digit Count
int GetDigit(int num) { return log10(num) + 1; }
// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
int cnt = 0;
while (n > 0) {
if (n % 2 == 1)
cnt++;
n /= 2;
}
return cnt;
}
vector<long long> enum_divisors(long long N) {
vector<long long> res;
for (long long i = 1; i * i <= N; ++i) {
if (N % i == 0) {
res.push_back(i);
if (N / i != i)
res.push_back(N / i);
}
}
sort(res.begin(), res.end());
return res;
}
const ll dx[4] = {1, 0, -1, 0};
const ll dy[4] = {0, 1, 0, -1};
struct edge {
ll to, cost;
};
typedef long double ld;
using Graph = vector<VE>;
class UnionFind {
public:
vector<ll> par; // ๅๅ
ใฎ่ฆชใ่กจใ้
ๅ
vector<ll> siz; // ็ด ้ๅใฎใตใคใบใ่กจใ้
ๅ(1 ใงๅๆๅ)
// Constructor
UnionFind(ll sz_) : par(sz_), siz(sz_, 1) {
for (ll i = 0; i < sz_; ++i)
par[i] = i; // ๅๆใงใฏ่ฆชใฏ่ชๅ่ช่บซ
}
void init(ll sz_) {
par.resize(sz_);
siz.resize(sz_, 1);
for (ll i = 0; i < sz_; ++i)
par[i] = i; // ๅๆใงใฏ่ฆชใฏ่ชๅ่ช่บซ
}
// Member Function
// Find
ll root(ll x) { // ๆ นใฎๆค็ดข
while (par[x] != x) {
x = par[x] = par[par[x]]; // x ใฎ่ฆชใฎ่ฆชใ x ใฎ่ฆชใจใใ
}
return x;
}
// Union(Unite, Merge)
bool merge(ll x, ll y) {
x = root(x);
y = root(y);
if (x == y)
return false;
// merge technique๏ผใใผใฟๆง้ ใใใผใธใใใใฏ๏ผๅฐใๅคงใซใใฃใคใใ๏ผ
if (siz[x] < siz[y])
swap(x, y);
siz[x] += siz[y];
par[y] = x;
return true;
}
bool issame(ll x, ll y) { // ้ฃ็ตๅคๅฎ
return root(x) == root(y);
}
ll size(ll x) { // ็ด ้ๅใฎใตใคใบ
return siz[root(x)];
}
};
VE depth;
void dfs(const vector<vector<edge>> &G, int v, int p, int d) {
depth[v] = d;
for (auto u : G[v]) {
if (u.to == p)
continue;
dfs(G, u.to, v, d + u.cost);
}
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// cout << fixed << setprecision(20);
// combination com(200010);
int n;
cin >> n;
depth.resize(n);
vector<vector<edge>> G(n);
rep(i, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
G[a].push_back({b, c});
G[b].push_back({a, c});
}
dfs(G, 0, -1, 0);
rep(i, n) {
if (depth[i] % 2)
cout << 1 << endl;
else
cout << 0 << endl;
}
return 0;
} | [
"identifier.change",
"call.arguments.change"
] | 861,981 | 861,982 | u809967037 | cpp |
p03044 | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
struct edge {
int to, cost;
};
vector<edge> G[100005];
bool used[100005];
int ans[100005];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; ++i) {
int u, v, w;
cin >> u >> v >> w;
--u;
--v;
if (w % 2 == 0)
w = 0;
else
w = 1;
G[u].push_back((edge){v, w});
G[v].push_back((edge){u, w});
}
queue<int> que;
ans[0] = 0;
used[0] = true;
que.push(0);
while (!que.empty()) {
int u = que.front();
que.pop();
for (int i = 0; i < G[u].size(); ++i) {
edge e = G[u][i];
if (used[e.to])
continue;
ans[e.to] = (ans[u] + e.cost) % 2;
used[e.to] = true;
que.push(e.to);
}
}
for (int i = 0; i < n; ++i) {
cout << ans[i] << "\n";
}
} | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, ll> P;
struct edge {
int to, cost;
};
vector<edge> G[100005];
bool used[100005];
int ans[100005];
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n - 1; ++i) {
int u, v, w;
cin >> u >> v >> w;
--u;
--v;
if (w % 2 == 0)
w = 0;
else
w = 1;
G[u].push_back((edge){v, w});
G[v].push_back((edge){u, w});
}
queue<int> que;
ans[0] = 0;
used[0] = true;
que.push(0);
while (!que.empty()) {
int u = que.front();
que.pop();
for (int i = 0; i < G[u].size(); ++i) {
edge e = G[u][i];
if (used[e.to])
continue;
ans[e.to] = (ans[u] + e.cost) % 2;
used[e.to] = true;
que.push(e.to);
}
}
for (int i = 0; i < n; ++i) {
cout << ans[i] << "\n";
}
} | [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 861,998 | 861,999 | u190018920 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
struct edge {
int to, d;
};
using Graph = vector<vector<edge>>;
int main() {
int N;
cin >> N;
Graph G(N);
for (int i = 0; i < N - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
edge e = {v, w};
G[u].push_back(e);
edge E = {u, w};
G[u].push_back(E);
}
queue<int> que;
que.push(0);
vector<int> color(N, -1);
color.at(0) = 0;
while (!que.empty()) {
int v = que.front();
que.pop();
for (auto e : G[v]) {
if (color.at(e.to) != -1)
continue;
else {
if (color.at(v) == 1) {
if (e.d % 2 == 0)
color.at(e.to) = 1;
else
color.at(e.to) = 0;
} else {
if (e.d % 2 == 0)
color.at(e.to) = 0;
else
color.at(e.to) = 1;
}
que.push(e.to);
}
}
}
for (int i = 0; i < N; i++)
cout << color.at(i) << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
struct edge {
int to, d;
};
using Graph = vector<vector<edge>>;
int main() {
int N;
cin >> N;
Graph G(N);
for (int i = 0; i < N - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
edge e = {v, w};
G[u].push_back(e);
edge E = {u, w};
G[v].push_back(E);
}
queue<int> que;
que.push(0);
vector<int> color(N, -1);
color.at(0) = 0;
while (!que.empty()) {
int v = que.front();
que.pop();
for (auto e : G[v]) {
if (color.at(e.to) != -1)
continue;
else {
if (color.at(v) == 1) {
if (e.d % 2 == 0)
color.at(e.to) = 1;
else
color.at(e.to) = 0;
} else {
if (e.d % 2 == 0)
color.at(e.to) = 0;
else
color.at(e.to) = 1;
}
que.push(e.to);
}
}
}
for (int i = 0; i < N; i++)
cout << color.at(i) << endl;
return 0;
} | [
"identifier.change",
"variable_access.subscript.index.change"
] | 862,010 | 862,011 | u101018317 | cpp |
p03044 | #include "bits/stdc++.h"
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) \
sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORL(i, a, b) for (LL i = (a); i < (b); ++i)
#define REPL(i, n) FORL(i, 0, n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
const double EPS = 1e-10;
const double PI = acos(-1.0);
// debug func
template <typename T> void vprint(vector<T> v) {
for (auto x : v) {
cerr << x << " ";
}
cerr << endl;
}
template <typename T> void vvprint(vector<vector<T>> vv) {
REP(i, SIZE(vv)) {
REP(j, SIZE(vv[i])) { cerr << vv[i][j] << " "; }
cerr << endl;
}
}
template <typename T1, typename T2> void vpprint(vector<pair<T1, T2>> vp) {
REP(i, SIZE(vp)) { cerr << vp[i].first << ", " << vp[i].second << endl; }
}
template <typename T1, typename T2> void mprint(map<T1, T2> m) {
for (auto x : m)
cerr << x.first << ", " << x.second << endl;
}
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k,
const Iterator last) {
/* Credits: Thomas Draper */
if ((first == last) || (first == k) || (last == k))
return false;
Iterator itr1 = first;
Iterator itr2 = last;
++itr1;
if (last == itr1)
return false;
itr1 = last;
--itr1;
itr1 = k;
--itr2;
while (first != itr1) {
if (*--itr1 < *itr2) {
Iterator j = k;
while (!(*itr1 < *j))
++j;
iter_swap(itr1, j);
++itr1;
++j;
itr2 = k;
rotate(itr1, j, last);
while (last != j) {
++j;
++itr2;
}
rotate(k, itr2, last);
return true;
}
}
rotate(first, k, last);
return false;
}
inline double get_time_sec(void) {
return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(
chrono::steady_clock::now().time_since_epoch())
.count()) /
1000000000;
}
template <typename T> T gcd(T a, T b) {
if (a > b)
swap(a, b);
if (a == 0)
return b;
else
return gcd(b % a, a);
}
template <typename T> T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
template <typename T> map<T, T> prime_list(T n) {
map<T, T> ret;
for (T i = 2; i * i <= n; i++) {
if (n % i == 0) {
ret[i] = 0;
while (n % i == 0) {
n /= i;
ret[i]++;
}
}
}
if (n != 1)
ret[n]++;
return ret;
}
#define MOD 1000000007
LL mypow(LL a, LL n) {
if (n == 1)
return a % MOD;
if (n % 2 == 1)
return (a * mypow(a, n - 1)) % MOD;
LL t = mypow(a, n / 2);
return (t * t) % MOD;
}
LL mycomb(LL n, LL k) {
if (n == 0 || n == k)
return 1;
LL x = 1, y = 1;
REP(i, k) {
x = x * (n - i) % MOD;
y = y * (i + 1) % MOD;
}
return x * mypow(y, MOD - 2) % MOD;
}
VI par, rnk;
int root(int x) {
if (par[x] == x)
return x;
else
return par[x] = root(par[x]);
}
bool same(int x, int y) {
x = root(x);
y = root(y);
return x == y;
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (rnk[x] < rnk[y]) {
par[x] = y;
} else {
par[y] = x;
if (rnk[x] == rnk[y])
rnk[x]++;
}
}
#define INF 1e8
int n;
vector<VPII> g;
VI clr;
void dfs(int u, int dst) {
// cerr << "idx, dst: " << u << ", " << dst << endl;
clr[u] = 1 + dst % 2;
REP(i, g[u].size()) {
int v = g[u][i].first;
int c = g[u][i].second;
if (clr[v])
continue;
dfs(v, dst + c);
}
}
int main(void) {
cin >> n;
g = vector<VPII>(n, VPII(0));
REP(i, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
g[a].push_back(make_pair(b, c));
g[b].push_back(make_pair(a, c));
}
clr = VI(n, 0);
dfs(0, 0);
// vprint(clr);
REP(i, n) cout << clr[i] << endl;
} | #include "bits/stdc++.h"
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) \
sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define FORL(i, a, b) for (LL i = (a); i < (b); ++i)
#define REPL(i, n) FORL(i, 0, n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(), (a).end()
const double EPS = 1e-10;
const double PI = acos(-1.0);
// debug func
template <typename T> void vprint(vector<T> v) {
for (auto x : v) {
cerr << x << " ";
}
cerr << endl;
}
template <typename T> void vvprint(vector<vector<T>> vv) {
REP(i, SIZE(vv)) {
REP(j, SIZE(vv[i])) { cerr << vv[i][j] << " "; }
cerr << endl;
}
}
template <typename T1, typename T2> void vpprint(vector<pair<T1, T2>> vp) {
REP(i, SIZE(vp)) { cerr << vp[i].first << ", " << vp[i].second << endl; }
}
template <typename T1, typename T2> void mprint(map<T1, T2> m) {
for (auto x : m)
cerr << x.first << ", " << x.second << endl;
}
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k,
const Iterator last) {
/* Credits: Thomas Draper */
if ((first == last) || (first == k) || (last == k))
return false;
Iterator itr1 = first;
Iterator itr2 = last;
++itr1;
if (last == itr1)
return false;
itr1 = last;
--itr1;
itr1 = k;
--itr2;
while (first != itr1) {
if (*--itr1 < *itr2) {
Iterator j = k;
while (!(*itr1 < *j))
++j;
iter_swap(itr1, j);
++itr1;
++j;
itr2 = k;
rotate(itr1, j, last);
while (last != j) {
++j;
++itr2;
}
rotate(k, itr2, last);
return true;
}
}
rotate(first, k, last);
return false;
}
inline double get_time_sec(void) {
return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(
chrono::steady_clock::now().time_since_epoch())
.count()) /
1000000000;
}
template <typename T> T gcd(T a, T b) {
if (a > b)
swap(a, b);
if (a == 0)
return b;
else
return gcd(b % a, a);
}
template <typename T> T lcm(T a, T b) { return (a / gcd(a, b)) * b; }
template <typename T> map<T, T> prime_list(T n) {
map<T, T> ret;
for (T i = 2; i * i <= n; i++) {
if (n % i == 0) {
ret[i] = 0;
while (n % i == 0) {
n /= i;
ret[i]++;
}
}
}
if (n != 1)
ret[n]++;
return ret;
}
#define MOD 1000000007
LL mypow(LL a, LL n) {
if (n == 1)
return a % MOD;
if (n % 2 == 1)
return (a * mypow(a, n - 1)) % MOD;
LL t = mypow(a, n / 2);
return (t * t) % MOD;
}
LL mycomb(LL n, LL k) {
if (n == 0 || n == k)
return 1;
LL x = 1, y = 1;
REP(i, k) {
x = x * (n - i) % MOD;
y = y * (i + 1) % MOD;
}
return x * mypow(y, MOD - 2) % MOD;
}
VI par, rnk;
int root(int x) {
if (par[x] == x)
return x;
else
return par[x] = root(par[x]);
}
bool same(int x, int y) {
x = root(x);
y = root(y);
return x == y;
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if (rnk[x] < rnk[y]) {
par[x] = y;
} else {
par[y] = x;
if (rnk[x] == rnk[y])
rnk[x]++;
}
}
#define INF 1e8
int n;
vector<VPLL> g;
VI clr;
void dfs(int u, LL dst) {
// cerr << "idx, dst: " << u << ", " << dst << endl;
clr[u] = 1 + dst % 2;
REP(i, g[u].size()) {
int v = g[u][i].first;
int c = g[u][i].second;
if (clr[v])
continue;
dfs(v, dst + c);
}
}
int main(void) {
cin >> n;
g = vector<VPLL>(n, VPLL(0));
REP(i, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--;
b--;
g[a].push_back(make_pair(b, c));
g[b].push_back(make_pair(a, c));
}
clr = VI(n, 0);
dfs(0, 0);
// vprint(clr);
REP(i, n) cout << clr[i] - 1 << endl;
} | [
"assignment.value.change",
"identifier.change",
"call.function.change",
"call.arguments.change"
] | 862,025 | 862,024 | u637983859 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for (ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rreps(i, e, n) for (ll i = (n)-1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
ll n;
vector<vector<pair<ll, ll>>> g;
vector<ll> color;
void dfs(ll v, ll d = 0) {
if (color[v] != -1)
return;
color[v] = d % 2;
for (auto x : g[v]) {
ll to = x.first, cost = x.second;
dfs(to, d + cost);
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// ifstream in("input.txt");
// cin.rdbuf(in.rdbuf());
cin >> n;
g.resize(n);
rep(i, n) {
ll a, b, c;
cin >> a >> b >> c;
a--;
b--;
g[a].push_back(make_pair(b, c));
g[b].push_back(make_pair(a, c));
}
color.resize(n, -1);
dfs(0);
rep(i, n) printf("%lld\n", color[i]);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for (ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rreps(i, e, n) for (ll i = (n)-1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
ll n;
vector<vector<pair<ll, ll>>> g;
vector<ll> color;
void dfs(ll v, ll d = 0) {
if (color[v] != -1)
return;
color[v] = d % 2;
for (auto x : g[v]) {
ll to = x.first, cost = x.second;
dfs(to, d + cost);
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// ifstream in("input.txt");
// cin.rdbuf(in.rdbuf());
cin >> n;
g.resize(n);
rep(i, n - 1) {
ll a, b, c;
cin >> a >> b >> c;
a--;
b--;
g[a].push_back(make_pair(b, c));
g[b].push_back(make_pair(a, c));
}
color.resize(n, -1);
dfs(0);
rep(i, n) printf("%lld\n", color[i]);
return 0;
}
| [
"expression.operation.binary.add"
] | 862,046 | 862,047 | u225581241 | cpp |
p03044 | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author champon
*/
#include <fstream>
#include <iostream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = ll(1e9) + 7;
const ll inf = ll(5e18);
template <typename T1, typename T2> ll ceill(T1 a, T2 b) {
return (a + b - 1) / b;
}
void ans(bool b, ostream &out = cout) { out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream &out = cout) { out << (b ? "YES" : "NO") << endl; }
template <typename T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP
#include <iostream>
#include <map>
#include <vector>
using namespace std;
namespace dbg {
using ll = long long;
class Debug {
public:
Debug() {}
template <typename T> void vd(vector<T> vec);
template <typename T> void vd2(vector<vector<T>> vec);
template <typename T> void ad(T *arr, ll n);
template <typename T, size_t N> void ad2(T (&arr)[N], ll n);
template <typename T> void md(T mp);
};
template <typename T> void Debug::vd(vector<T> vec) {
for (auto vv : vec)
cout << vv << " ";
cout << endl;
}
template <typename T> void Debug::vd2(vector<vector<T>> vec) {
for (auto vv : vec)
for (auto vvv : vv)
cout << vvv << " ";
cout << endl;
}
template <typename T> void Debug::ad(T *arr, ll n) {
for (int i = 0; i <= n; i++)
cout << arr[i] << " ";
cout << endl;
}
template <typename T, size_t N> void Debug::ad2(T (&arr)[N], ll n) {
for (int i = 0; i <= N; i++)
for (int j = 0; j <= n; j++)
cout << arr[i][j] << " ";
cout << endl;
}
template <typename T> void Debug::md(T mp) {
cout << "key : value" << endl;
for (auto const &m : mp)
cout << m.first << " : " << m.second << endl;
cout << endl;
}
} // namespace dbg
#endif // INCLUDE_DEBUG_HPP
using dbg::Debug;
Debug debug;
struct Node {
ll to, cost;
Node(int to, ll cost) : to(to), cost(cost) {}
};
class DEvenRelation {
public:
void solve(std::istream &in, std::ostream &out) {
int n;
in >> n;
vector<vector<Node>> g(n, vector<Node>());
ll u, v, w;
for (int i = 0; i < n - 1; i++) {
in >> u >> v >> w;
u--;
v--;
g[u].push_back(Node(v, w));
g[v].push_back(Node(u, w));
}
vector<int> res(n, 0);
vector<int> visit(n, 0);
function<void(int, int, ll)> dfs = [&](int u, int pcolor, ll dist) {
visit[u] = 1;
for (auto e : g[u]) {
if (visit[e.to])
continue;
int color = (dist + e.cost) % 2 == 0 ? pcolor : (pcolor ? 0 : 1);
res[e.to] = color;
dfs(e.to, color, dist + e.cost);
}
};
dfs(0, 0, 0LL);
for (auto e : res) {
out << e << endl;
}
}
};
int main() {
DEvenRelation solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author champon
*/
#include <fstream>
#include <iostream>
#include <bits/stdc++.h>
#define se cout << "test ok" << endl;
#define sp << " " <<
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = ll(1e9) + 7;
const ll inf = ll(5e18);
template <typename T1, typename T2> ll ceill(T1 a, T2 b) {
return (a + b - 1) / b;
}
void ans(bool b, ostream &out = cout) { out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream &out = cout) { out << (b ? "YES" : "NO") << endl; }
template <typename T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
fill((T *)array, (T *)(array + N), val);
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};
#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP
#include <iostream>
#include <map>
#include <vector>
using namespace std;
namespace dbg {
using ll = long long;
class Debug {
public:
Debug() {}
template <typename T> void vd(vector<T> vec);
template <typename T> void vd2(vector<vector<T>> vec);
template <typename T> void ad(T *arr, ll n);
template <typename T, size_t N> void ad2(T (&arr)[N], ll n);
template <typename T> void md(T mp);
};
template <typename T> void Debug::vd(vector<T> vec) {
for (auto vv : vec)
cout << vv << " ";
cout << endl;
}
template <typename T> void Debug::vd2(vector<vector<T>> vec) {
for (auto vv : vec)
for (auto vvv : vv)
cout << vvv << " ";
cout << endl;
}
template <typename T> void Debug::ad(T *arr, ll n) {
for (int i = 0; i <= n; i++)
cout << arr[i] << " ";
cout << endl;
}
template <typename T, size_t N> void Debug::ad2(T (&arr)[N], ll n) {
for (int i = 0; i <= N; i++)
for (int j = 0; j <= n; j++)
cout << arr[i][j] << " ";
cout << endl;
}
template <typename T> void Debug::md(T mp) {
cout << "key : value" << endl;
for (auto const &m : mp)
cout << m.first << " : " << m.second << endl;
cout << endl;
}
} // namespace dbg
#endif // INCLUDE_DEBUG_HPP
using dbg::Debug;
Debug debug;
struct Node {
ll to, cost;
Node(int to, ll cost) : to(to), cost(cost) {}
};
class DEvenRelation {
public:
void solve(std::istream &in, std::ostream &out) {
int n;
in >> n;
vector<vector<Node>> g(n, vector<Node>());
ll u, v, w;
for (int i = 0; i < n - 1; i++) {
in >> u >> v >> w;
u--;
v--;
g[u].push_back(Node(v, w));
g[v].push_back(Node(u, w));
}
vector<int> res(n, 0);
vector<int> visit(n, 0);
function<void(int, int, ll)> dfs = [&](int u, int pcolor, ll dist) {
visit[u] = 1;
for (auto e : g[u]) {
if (visit[e.to])
continue;
int color = e.cost % 2 == 0 ? pcolor : (pcolor ? 0 : 1);
res[e.to] = color;
dfs(e.to, color, dist + e.cost);
}
};
dfs(0, 0, 0LL);
for (auto e : res) {
out << e << endl;
}
}
};
int main() {
DEvenRelation solver;
std::istream &in(std::cin);
std::ostream &out(std::cout);
solver.solve(in, out);
return 0;
}
| [
"expression.operation.binary.remove"
] | 862,050 | 862,051 | u026620445 | cpp |
p03044 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
vector<vector<int>> g;
vector<vector<int>> gw;
vector<int> gc;
int f(int x, int c, int o = -1) {
gc.at(x) = c;
rep(i, g.at(x).size()) {
if (g.at(x).at(i) == o)
continue;
if (gw.at(x).at(i) % 2 == 0) {
f(g.at(x).at(i), 0, x);
} else {
f(g.at(x).at(i), (c + 1) % 2, x);
}
}
return 0;
}
int main() {
int n;
cin >> n;
g = vector<vector<int>>(n, vector<int>(0));
gw = vector<vector<int>>(n, vector<int>(0));
gc = vector<int>(n);
rep(i, n - 1) {
int a, b, w;
cin >> a >> b >> w;
a--;
b--;
g.at(a).push_back(b);
g.at(b).push_back(a);
gw.at(a).push_back(w);
gw.at(b).push_back(w);
}
rep(i, n) gc.at(i) = -1;
f(0, 0);
rep(i, n) { cout << gc.at(i) << endl; }
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
vector<vector<int>> g;
vector<vector<int>> gw;
vector<int> gc;
int f(int x, int c, int o = -1) {
gc.at(x) = c;
rep(i, g.at(x).size()) {
if (g.at(x).at(i) == o)
continue;
if (gw.at(x).at(i) % 2 == 0) {
f(g.at(x).at(i), c, x);
} else {
f(g.at(x).at(i), (c + 1) % 2, x);
}
}
return 0;
}
int main() {
int n;
cin >> n;
g = vector<vector<int>>(n, vector<int>(0));
gw = vector<vector<int>>(n, vector<int>(0));
gc = vector<int>(n);
rep(i, n - 1) {
int a, b, w;
cin >> a >> b >> w;
a--;
b--;
g.at(a).push_back(b);
g.at(b).push_back(a);
gw.at(a).push_back(w);
gw.at(b).push_back(w);
}
rep(i, n) gc.at(i) = -1;
f(0, 0);
rep(i, n) { cout << gc.at(i) << endl; }
return 0;
} | [
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change"
] | 862,059 | 862,060 | u945901686 | cpp |
p03044 | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;
vi color;
void dfs(int v, vector<vector<pair<int, int>>> &edge, int x) {
if (color[v] != -1) {
return;
}
color[v] = x % 2;
for (auto next : edge[v]) {
if (next.second) {
dfs(next.first, edge, ++x);
} else {
dfs(next.first, edge, x);
}
}
return;
}
int main() {
int N, M;
cin >> N;
M = N - 1;
vector<vector<pair<int, int>>> edge(N, vector<pair<int, int>>());
rep(i, M) {
int u, v, w;
cin >> u >> v >> w;
edge[u - 1].push_back(make_pair(v - 1, w % 2));
edge[v - 1].push_back(make_pair(u - 1, w % 2));
}
color.assign(N, -1);
dfs(0, edge, 0);
rep(i, N) { cout << color[i] << '\n'; }
} | //#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;
vi color;
void dfs(int v, vector<vector<pair<int, int>>> &edge, int x) {
if (color[v] != -1) {
return;
}
color[v] = x % 2;
for (auto next : edge[v]) {
if (next.second) {
dfs(next.first, edge, 1 + x);
} else {
dfs(next.first, edge, x);
}
}
return;
}
int main() {
int N, M;
cin >> N;
M = N - 1;
vector<vector<pair<int, int>>> edge(N, vector<pair<int, int>>());
rep(i, M) {
int u, v, w;
cin >> u >> v >> w;
edge[u - 1].push_back(make_pair(v - 1, w % 2));
edge[v - 1].push_back(make_pair(u - 1, w % 2));
}
color.assign(N, -1);
dfs(0, edge, 0);
rep(i, N) { cout << color[i] << '\n'; }
} | [
"call.arguments.change"
] | 862,079 | 862,080 | u802434195 | cpp |
p03044 | /*
* atcoder/abc126/d.cpp
*/
// C++ 14
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring> // memset
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for (ll __x = __start; __x < __end; __x++)
template <class T> ostream &operator<<(ostream &out, vector<T> const &v) {
for (auto &&a : v)
out << a << " ";
out << endl;
return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
/*
* ้ ็น0ใb=falseใจใใฆๅญไพใๆฑบๅฎใใฆใใ. ๅถๆฐใชใb, ๅฅๆฐใชใ!b
*/
struct Edge {
ll v;
ll w;
};
const ll MAX = 100100;
ll N;
vector<Edge> G[MAX];
vector<ll> colors(MAX, -1);
vector<ll> A;
void solve() {
cin >> N;
ll u, v, w;
loop(n, 0, N) {
cin >> u >> v >> w;
u--;
v--;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
queue<ll> Q;
Q.push({0});
colors[0] = 0;
while (Q.size()) {
ll u = Q.front();
Q.pop();
for (auto &&edge : G[u]) {
ll v = edge.v, w = edge.w;
if (colors[v] >= 0)
continue;
if (w & 1)
colors[v] = 1 - colors[u];
else
colors[v] = colors[u];
Q.push(v);
}
}
loop(n, 0, N) cout << colors[n] % 2 << endl;
}
int main() {
// cout.precision(15); cout << fixed;
solve();
return 0;
}
| /*
* atcoder/abc126/d.cpp
*/
// C++ 14
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring> // memset
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for (ll __x = __start; __x < __end; __x++)
template <class T> ostream &operator<<(ostream &out, vector<T> const &v) {
for (auto &&a : v)
out << a << " ";
out << endl;
return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
/*
* ้ ็น0ใb=falseใจใใฆๅญไพใๆฑบๅฎใใฆใใ. ๅถๆฐใชใb, ๅฅๆฐใชใ!b
*/
struct Edge {
ll v;
ll w;
};
const ll MAX = 100100;
ll N;
vector<Edge> G[MAX];
vector<ll> colors(MAX, -1);
vector<ll> A;
void solve() {
cin >> N;
ll u, v, w;
loop(n, 0, N - 1) {
cin >> u >> v >> w;
u--;
v--;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
queue<ll> Q;
Q.push({0});
colors[0] = 0;
while (Q.size()) {
ll u = Q.front();
Q.pop();
for (auto &&edge : G[u]) {
ll v = edge.v, w = edge.w;
if (colors[v] >= 0)
continue;
if (w & 1)
colors[v] = 1 - colors[u];
else
colors[v] = colors[u];
Q.push(v);
}
}
loop(n, 0, N) cout << colors[n] % 2 << endl;
}
int main() {
// cout.precision(15); cout << fixed;
solve();
return 0;
}
| [
"expression.operation.binary.add"
] | 862,085 | 862,086 | u823862638 | cpp |
p03044 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;
const double PI = 3.14159265358979323846;
#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#define rep(i, N) for (int i = 0; i < N; ++i)
#define CEIL(x, y) (((x) + (y)-1) / (y))
#define MOD 1000000007ULL
vector<vector<int>> g;
vector<vector<int>> gw;
vector<bool> done;
vs32 ans;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
g.resize(N);
gw.resize(N);
done.resize(N, false);
ans.resize(N);
int u, v, w;
rep(i, N - 1) {
cin >> u >> v >> w;
g[u - 1].push_back(v - 1);
g[w - 1].push_back(u - 1);
gw[u - 1].push_back(w);
gw[v - 1].push_back(w);
}
ans[0] = 0;
queue<int> q;
q.push(0);
while (!q.empty()) {
int root = q.front();
q.pop();
done[root] = true;
rep(i, g[root].size()) {
int leaf = g[root][i];
if (done[leaf])
continue;
int dist = gw[root][i];
if (dist & 1)
ans[leaf] = ans[root] ^ 1;
else
ans[leaf] = ans[root];
q.push(leaf);
}
}
rep(i, N) cout << ans[i] << "\n";
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;
const double PI = 3.14159265358979323846;
#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))
#define rep(i, N) for (int i = 0; i < N; ++i)
#define CEIL(x, y) (((x) + (y)-1) / (y))
#define MOD 1000000007ULL
vector<vector<int>> g;
vector<vector<int>> gw;
vector<bool> done;
vs32 ans;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
g.resize(N);
gw.resize(N);
done.resize(N, false);
ans.resize(N);
int u, v, w;
rep(i, N - 1) {
cin >> u >> v >> w;
g[u - 1].push_back(v - 1);
g[v - 1].push_back(u - 1);
gw[u - 1].push_back(w);
gw[v - 1].push_back(w);
}
ans[0] = 0;
queue<int> q;
q.push(0);
while (!q.empty()) {
int root = q.front();
q.pop();
done[root] = true;
rep(i, g[root].size()) {
int leaf = g[root][i];
if (done[leaf])
continue;
int dist = gw[root][i];
if (dist & 1)
ans[leaf] = ans[root] ^ 1;
else
ans[leaf] = ans[root];
q.push(leaf);
}
}
rep(i, N) cout << ans[i] << "\n";
return 0;
}
| [
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 862,101 | 862,102 | u806999568 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;
vector<vector<pair<ll, ll>>> adj(MAXN, vector<pair<ll, ll>>());
vector<ll> c(MAXN);
void dfs(ll u, ll p) {
for (auto edge : adj[u]) {
ll to = edge.first;
ll len = edge.second;
if (to != p) {
if (len % 2)
c[to] = c[u];
else
c[to] = 1 - c[u];
dfs(to, u);
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
ll u, v, wt;
cin >> u >> v >> wt;
adj[u].push_back({v, wt});
adj[v].push_back({u, wt});
}
c[1] = 0;
dfs(1, -1);
for (int i = 1; i <= n; i++)
cout << c[i] << '\n';
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9 + 7;
const ll MAXN = 1e5 + 5;
vector<vector<pair<ll, ll>>> adj(MAXN, vector<pair<ll, ll>>());
vector<ll> c(MAXN);
void dfs(ll u, ll p) {
for (auto edge : adj[u]) {
ll to = edge.first;
ll len = edge.second;
if (to != p) {
if (len % 2 == 0)
c[to] = c[u];
else
c[to] = 1 - c[u];
dfs(to, u);
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
ll u, v, wt;
cin >> u >> v >> wt;
adj[u].push_back({v, wt});
adj[v].push_back({u, wt});
}
c[1] = 0;
dfs(1, -1);
for (int i = 1; i <= n; i++)
cout << c[i] << '\n';
}
| [
"control_flow.branch.if.condition.change"
] | 862,117 | 862,118 | u929156598 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
void dfs(vector<vector<pair<int, int>>> &graph, vector<int> &ans, int now,
int parent, int color) {
ans.at(now) = color;
for (int i = 0; i < graph.at(now).size(); i++) {
int next = graph.at(now).at(i).first;
if (next == parent)
continue;
if (graph.at(now).at(i).second == 0)
dfs(graph, ans, next, now, color);
else
dfs(graph, ans, next, now, 1 - color);
}
}
int main() {
int N;
cin >> N;
vector<vector<pair<int, int>>> graph(N);
for (int i = 0; i < N; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
w %= 2;
graph.at(u).push_back(make_pair(v, w));
graph.at(v).push_back(make_pair(u, w));
}
vector<int> ans(N, -1);
dfs(graph, ans, 0, -1, 0);
for (int i = 0; i < N; i++) {
cout << ans.at(i) << endl;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
void dfs(vector<vector<pair<int, int>>> &graph, vector<int> &ans, int now,
int parent, int color) {
ans.at(now) = color;
for (int i = 0; i < graph.at(now).size(); i++) {
int next = graph.at(now).at(i).first;
if (next == parent)
continue;
if (graph.at(now).at(i).second == 0)
dfs(graph, ans, next, now, color);
else
dfs(graph, ans, next, now, 1 - color);
}
}
int main() {
int N;
cin >> N;
vector<vector<pair<int, int>>> graph(N);
for (int i = 0; i < N - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
w %= 2;
graph.at(u).push_back(make_pair(v, w));
graph.at(v).push_back(make_pair(u, w));
}
vector<int> ans(N, -1);
dfs(graph, ans, 0, -1, 0);
for (int i = 0; i < N; i++) {
cout << ans.at(i) << endl;
}
return 0;
}
| [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 862,133 | 862,134 | u618649215 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
vector<vector<int>> to, cost;
vi ans;
void dfs(int v, int c = 0) {
ans[v] = c;
rep(i, sz(to[v])) {
if (ans[to[v][i]] != -1)
continue;
int nc = (cost[v][to[v][i]] % 2 == 0 ? c : 1 - c);
dfs(to[v][i], nc);
}
}
int main() {
int n;
cin >> n;
to = vector<vector<int>>(n);
cost = vector<vector<int>>(n);
rep(i, n - 1) {
int u, v, w;
cin >> u >> v >> w;
--u;
--v;
to[u].pb(v);
cost[u].pb(w);
to[v].pb(u);
cost[v].pb(w);
}
ans = vi(n, -1);
dfs(0);
rep(i, n) cout << ans[i] << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }
vector<vector<int>> to, cost;
vi ans;
void dfs(int v, int c = 0) {
ans[v] = c;
rep(i, sz(to[v])) {
if (ans[to[v][i]] != -1)
continue;
int nc = (cost[v][i] % 2 == 0 ? c : 1 - c);
dfs(to[v][i], nc);
}
}
int main() {
int n;
cin >> n;
to = vector<vector<int>>(n);
cost = vector<vector<int>>(n);
rep(i, n - 1) {
int u, v, w;
cin >> u >> v >> w;
--u;
--v;
to[u].pb(v);
cost[u].pb(w);
to[v].pb(u);
cost[v].pb(w);
}
ans = vi(n, -1);
dfs(0);
rep(i, n) cout << ans[i] << endl;
return 0;
}
| [] | 862,174 | 862,175 | u682820318 | cpp |
p03044 | //
// main.cpp
// test130
//
// Created by on 2019/06/16.
// Copyright ยฉ 2 All rights reserved.
//
//
// main.cpp
// new
//
// Created on 2019/06/09.
// Copyright All rights reserved.
//
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
#define f(i, n) for (int i = 0; i < (n); i++)
#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)
using namespace std;
// Library
//ใขใใใใฆ
int modpow(int x, int y, int m = mod) {
int res = 1;
while (y) {
if (y % 2) {
res *= x;
res %= m;
}
x = x * x % mod;
y /= 2;
}
return res;
}
int mypow(int x, int y) {
int res = 1;
while (y) {
if (y % 2) {
res *= x;
}
x = x * x;
y /= 2;
}
return res;
}
// is the number (x) a prime number?
bool prime(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (!(x % i)) {
return false;
}
}
return true;
}
double kyori(pair<int, int> f, pair<int, int> s) {
double ans = 0;
double t = fabs(f.first - s.first);
double y = fabs(f.second - s.second);
ans = sqrt(t * t + y * y);
return ans;
}
// saidai-kouyakusuu
int gcd(int x, int y) {
if (y == 0) {
return x;
}
return gcd(y, x % y);
}
// Union-Find Tree
int par[300004];
int rankmy[300004];
int find(int x) {
if (par[x] == x) {
return x;
}
return par[x] = find(par[x]);
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y) {
return;
}
if (rankmy[x] < rankmy[y]) {
par[x] = y;
} else {
par[y] = x;
if (rankmy[x] == rankmy[y]) {
rankmy[x]++;
}
}
}
bool same(int x, int y) { return find(x) == find(y); }
void init(int n) {
for (int i = 0; i <= n; i++) {
par[i] = i;
}
}
// Union-Find-End
// SegTree
template <class T> class SegTree {
int n; // ่ใฎๆฐ
vector<T> data; // ใใผใฟใๆ ผ็ดใใvector
T def; // ๅๆๅคใใคๅไฝๅ
function<T(T, T)> operation; // ๅบ้ใฏใจใชใงไฝฟใๅฆ็
function<T(T, T)> update; // ็นๆดๆฐใงไฝฟใๅฆ็
// ๅบ้[a,b)ใฎ็ทๅใใใผใk=[l,r)ใซ็็ฎใใฆใใใ
T _query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return def; // ไบคๅทฎใใชใ
if (a <= l && r <= b)
return data[k]; // a,l,r,bใฎ้ ใงๅฎๅ
จใซๅซใพใใ
else {
T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // ๅทฆใฎๅญ
T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // ๅณใฎๅญ
return operation(c1, c2);
}
}
public:
// _n:ๅฟ
่ฆใตใคใบ, _def:ๅๆๅคใใคๅไฝๅ
, _operation:ใฏใจใช้ขๆฐ,
// _update:ๆดๆฐ้ขๆฐ
SegTree(size_t _n, T _def, function<T(T, T)> _operation,
function<T(T, T)> _update)
: def(_def), operation(_operation), update(_update) {
n = 1;
while (n < _n) {
n *= 2;
}
data = vector<T>(2 * n - 1, def);
}
// ๅ ดๆi(0-indexed)ใฎๅคใxใงๆดๆฐ
void change(int i, T x) {
i += n - 1;
data[i] = update(data[i], x);
while (i > 0) {
i = (i - 1) / 2;
data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
}
}
// [a, b)ใฎๅบ้ใฏใจใชใๅฎ่ก
T query(int a, int b) { return _query(a, b, 0, 0, n); }
// ๆทปๅญใงใขใฏใปใน
T operator[](int i) { return data[i + n - 1]; }
};
#define R_MIN ([](long long a, long long b) { return min(a, b); })
#define R_MAX ([](long long a, long long b) { return max(a, b); })
#define R_SUM ([](long long a, long long b) { return a + b; })
#define NORMAL_UPDATE ([](long long a, long long b) { return b; })
// same as "R_SUM"
#define ADD_UPDATE ([](long long a, long long b) { return a + b; })
// Library-End
int n, m, ans[100004];
vector<pair<int, int>> v[100004];
bool went[100004];
void dfs(int x, int kyo, bool colo) {
went[x] = true;
if (kyo & 1) {
if (colo) {
colo = false;
} else {
colo = true;
}
}
// cout<<x<<'p'<<endl;
ans[x] = colo;
for (int i = 0; i < v[x].size(); i++) {
// cout<<went[v[x][i].first]<<endl;
if (!went[v[x][i].first]) {
dfs(v[x][i].first, kyo + v[x][i].second, colo);
}
}
}
signed main() {
cin >> m;
for (int i = 0; i < m - 1; i++) {
int a, b, c;
cin >> a >> b >> c;
v[a].push_back({b, c});
v[b].push_back({a, c});
}
dfs(1, 0, false);
for (int i = 1; i <= m; i++) {
cout << ans[i] << endl;
}
// cout<<v[1].size()<<'l'<<endl;
}
| //
// main.cpp
// test130
//
// Created by on 2019/06/16.
// Copyright ยฉ 2 All rights reserved.
//
//
// main.cpp
// new
//
// Created on 2019/06/09.
// Copyright All rights reserved.
//
// C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
// <http://www.gnu.org/licenses/>.
/** @file stdc++.h
* This is an implementation file for a precompiled header.
*/
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
#define f(i, n) for (int i = 0; i < (n); i++)
#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)
using namespace std;
// Library
//ใขใใใใฆ
int modpow(int x, int y, int m = mod) {
int res = 1;
while (y) {
if (y % 2) {
res *= x;
res %= m;
}
x = x * x % mod;
y /= 2;
}
return res;
}
int mypow(int x, int y) {
int res = 1;
while (y) {
if (y % 2) {
res *= x;
}
x = x * x;
y /= 2;
}
return res;
}
// is the number (x) a prime number?
bool prime(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (!(x % i)) {
return false;
}
}
return true;
}
double kyori(pair<int, int> f, pair<int, int> s) {
double ans = 0;
double t = fabs(f.first - s.first);
double y = fabs(f.second - s.second);
ans = sqrt(t * t + y * y);
return ans;
}
// saidai-kouyakusuu
int gcd(int x, int y) {
if (y == 0) {
return x;
}
return gcd(y, x % y);
}
// Union-Find Tree
int par[300004];
int rankmy[300004];
int find(int x) {
if (par[x] == x) {
return x;
}
return par[x] = find(par[x]);
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y) {
return;
}
if (rankmy[x] < rankmy[y]) {
par[x] = y;
} else {
par[y] = x;
if (rankmy[x] == rankmy[y]) {
rankmy[x]++;
}
}
}
bool same(int x, int y) { return find(x) == find(y); }
void init(int n) {
for (int i = 0; i <= n; i++) {
par[i] = i;
}
}
// Union-Find-End
// SegTree
template <class T> class SegTree {
int n; // ่ใฎๆฐ
vector<T> data; // ใใผใฟใๆ ผ็ดใใvector
T def; // ๅๆๅคใใคๅไฝๅ
function<T(T, T)> operation; // ๅบ้ใฏใจใชใงไฝฟใๅฆ็
function<T(T, T)> update; // ็นๆดๆฐใงไฝฟใๅฆ็
// ๅบ้[a,b)ใฎ็ทๅใใใผใk=[l,r)ใซ็็ฎใใฆใใใ
T _query(int a, int b, int k, int l, int r) {
if (r <= a || b <= l)
return def; // ไบคๅทฎใใชใ
if (a <= l && r <= b)
return data[k]; // a,l,r,bใฎ้ ใงๅฎๅ
จใซๅซใพใใ
else {
T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2); // ๅทฆใฎๅญ
T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r); // ๅณใฎๅญ
return operation(c1, c2);
}
}
public:
// _n:ๅฟ
่ฆใตใคใบ, _def:ๅๆๅคใใคๅไฝๅ
, _operation:ใฏใจใช้ขๆฐ,
// _update:ๆดๆฐ้ขๆฐ
SegTree(size_t _n, T _def, function<T(T, T)> _operation,
function<T(T, T)> _update)
: def(_def), operation(_operation), update(_update) {
n = 1;
while (n < _n) {
n *= 2;
}
data = vector<T>(2 * n - 1, def);
}
// ๅ ดๆi(0-indexed)ใฎๅคใxใงๆดๆฐ
void change(int i, T x) {
i += n - 1;
data[i] = update(data[i], x);
while (i > 0) {
i = (i - 1) / 2;
data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
}
}
// [a, b)ใฎๅบ้ใฏใจใชใๅฎ่ก
T query(int a, int b) { return _query(a, b, 0, 0, n); }
// ๆทปๅญใงใขใฏใปใน
T operator[](int i) { return data[i + n - 1]; }
};
#define R_MIN ([](long long a, long long b) { return min(a, b); })
#define R_MAX ([](long long a, long long b) { return max(a, b); })
#define R_SUM ([](long long a, long long b) { return a + b; })
#define NORMAL_UPDATE ([](long long a, long long b) { return b; })
// same as "R_SUM"
#define ADD_UPDATE ([](long long a, long long b) { return a + b; })
// Library-End
int n, m, ans[100004];
vector<pair<int, int>> v[100004];
bool went[100004];
void dfs(int x, int kyo, bool colo) {
went[x] = true;
if (kyo & 1) {
if (colo) {
colo = false;
} else {
colo = true;
}
kyo = 0;
}
// cout<<x<<'p'<<endl;
ans[x] = colo;
for (int i = 0; i < v[x].size(); i++) {
// cout<<went[v[x][i].first]<<endl;
if (!went[v[x][i].first]) {
dfs(v[x][i].first, kyo + v[x][i].second, colo);
}
}
}
signed main() {
cin >> m;
for (int i = 0; i < m - 1; i++) {
int a, b, c;
cin >> a >> b >> c;
v[a].push_back({b, c});
v[b].push_back({a, c});
}
dfs(1, 0, false);
for (int i = 1; i <= m; i++) {
cout << ans[i] << endl;
}
// cout<<v[1].size()<<'l'<<endl;
}
| [
"assignment.add"
] | 862,178 | 862,179 | u943070796 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL << 60;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(), (x).end()
#define rp(i, N) for (ll i = 0; i < (ll)N; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
template <class T> bool chmax(T &former, const T &b) {
if (former < b) {
former = b;
return true;
}
return false;
}
template <class T> bool chmin(T &former, const T &b) {
if (b < former) {
former = b;
return true;
}
return false;
}
template <class T> T sqar(T x) { return x * x; } // sqrt(x)ใฏๅนณๆนๆ น;
#define Sort(v) \
std::sort(v.begin(), v.end(), \
std::greater<decltype(v[0])>()) //้้ ใงVใใฝใผใ
#define p_queue(v) priority_queue<v, vector<v>, greater<v>>
template <class T> inline void princ(T x) { cout << x << " "; };
template <class T> inline void print(T x) { cout << x << "\n"; };
template <class T> inline void Yes(T condition) {
if (condition)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
template <class T> inline void YES(T condition) {
if (condition)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
///////////////////////////////////////////////////////////////////////////////////
struct edge { /*้ใฟไปใ,ๆๅ*/
int to, cost; /*toใฏๆฅ็ถๅ
*/
edge(ll to_, ll cost_ = 1) {
to = to_;
cost = cost_;
}; /*ๅ
จใฆใฎcost=1 <=> ็กๅใฐใฉใ*/
};
bool operator<(edge e1, edge e2) { return e1.cost < e2.cost; }
bool operator>(edge e1, edge e2) { return e1.cost > e2.cost; }
using graph = vector<vector<edge>>;
void solve() {
int n;
cin >> n;
graph gra(n);
rp(i, n - 1) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
gra[u].pb(edge(v, w));
gra[v].pb(edge(u, v));
}
vi ans(n, -1);
ans[0] = 0;
queue<int> que;
int fr = 0;
do {
if (!que.empty()) {
fr = que.front();
que.pop();
}
for (auto nxt : gra[fr]) {
if (ans[nxt.to] != -1)
continue;
if (nxt.cost & 1) {
if (ans[fr] & 1)
ans[nxt.to] = 0;
else
ans[nxt.to] = 1;
} else {
if (ans[fr] & 1)
ans[nxt.to] = 1;
else
ans[nxt.to] = 0;
}
que.push(nxt.to);
}
} while (!que.empty());
for (auto a : ans) {
print(a);
}
return;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(30);
solve();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL << 60;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(x) (x).begin(), (x).end()
#define rp(i, N) for (ll i = 0; i < (ll)N; i++)
#define repi(i, a, b) for (ll i = ll(a); i < ll(b); ++i)
template <class T> bool chmax(T &former, const T &b) {
if (former < b) {
former = b;
return true;
}
return false;
}
template <class T> bool chmin(T &former, const T &b) {
if (b < former) {
former = b;
return true;
}
return false;
}
template <class T> T sqar(T x) { return x * x; } // sqrt(x)ใฏๅนณๆนๆ น;
#define Sort(v) \
std::sort(v.begin(), v.end(), \
std::greater<decltype(v[0])>()) //้้ ใงVใใฝใผใ
#define p_queue(v) priority_queue<v, vector<v>, greater<v>>
template <class T> inline void princ(T x) { cout << x << " "; };
template <class T> inline void print(T x) { cout << x << "\n"; };
template <class T> inline void Yes(T condition) {
if (condition)
cout << "Yes" << endl;
else
cout << "No" << endl;
}
template <class T> inline void YES(T condition) {
if (condition)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
///////////////////////////////////////////////////////////////////////////////////
struct edge { /*้ใฟไปใ,ๆๅ*/
int to, cost; /*toใฏๆฅ็ถๅ
*/
edge(ll to_, ll cost_ = 1) {
to = to_;
cost = cost_;
}; /*ๅ
จใฆใฎcost=1 <=> ็กๅใฐใฉใ*/
};
bool operator<(edge e1, edge e2) { return e1.cost < e2.cost; }
bool operator>(edge e1, edge e2) { return e1.cost > e2.cost; }
using graph = vector<vector<edge>>;
void solve() {
int n;
cin >> n;
graph gra(n);
rp(i, n - 1) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
gra[u].pb(edge(v, w));
gra[v].pb(edge(u, w));
}
vi ans(n, -1);
ans[0] = 0;
queue<int> que;
int fr = 0;
do {
if (!que.empty()) {
fr = que.front();
que.pop();
}
for (auto nxt : gra[fr]) {
if (ans[nxt.to] != -1)
continue;
if (nxt.cost & 1) {
if (ans[fr] & 1)
ans[nxt.to] = 0;
else
ans[nxt.to] = 1;
} else {
if (ans[fr] & 1)
ans[nxt.to] = 1;
else
ans[nxt.to] = 0;
}
que.push(nxt.to);
}
} while (!que.empty());
for (auto a : ans) {
print(a);
}
return;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(30);
solve();
return 0;
} | [
"identifier.change",
"call.arguments.change"
] | 862,202 | 862,203 | u377907412 | cpp |
p03044 | #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <new>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define lrep(i, n, m) for (int i = n; i < m; i++)
using ll = long long;
using Vii = vector<vector<int>>;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll>>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
Vi color;
vector<vector<the>> G;
void dfs(int u, int r) {
for (the tnu : G[u]) {
if (color[tnu.first] != -1)
continue;
r = (r + tnu.second) % 2;
// cout << tnu.first << " " << r << endl;
if (r == 0) {
color[tnu.first] = 0;
} else {
color[tnu.first] = 1;
}
dfs(tnu.first, r);
}
return;
}
int main() {
int n;
cin >> n;
G.resize(n);
rep(i, n - 1) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
color.resize(n, -1);
color[0] = 0;
dfs(0, 0);
rep(i, n) cout << color[i] << endl;
}
| #define _USE_MATH_DEFINES
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <new>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define lrep(i, n, m) for (int i = n; i < m; i++)
using ll = long long;
using Vii = vector<vector<int>>;
using Gjudge = vector<vector<bool>>;
using Vi = vector<int>;
using Vl = vector<ll>;
using Vll = vector<vector<ll>>;
using Vs = vector<string>;
using Vb = vector<bool>;
using the = pair<int, int>;
using lthe = pair<ll, ll>;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
Vi color;
vector<vector<the>> G;
void dfs(int u, int r) {
for (the tnu : G[u]) {
if (color[tnu.first] != -1)
continue;
// cout << tnu.first << " " << r << endl;
int t = (r + tnu.second) % 2;
if (t == 0) {
color[tnu.first] = 0;
} else {
color[tnu.first] = 1;
}
dfs(tnu.first, t);
}
return;
}
int main() {
int n;
cin >> n;
G.resize(n);
rep(i, n - 1) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
color.resize(n, -1);
color[0] = 0;
dfs(0, 0);
rep(i, n) cout << color[i] << endl;
}
| [
"identifier.change",
"control_flow.branch.if.condition.change",
"call.arguments.change"
] | 862,220 | 862,221 | u121734488 | cpp |
p03044 | //----AUTHOR:kkdrummer----/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> P;
#define X real()
#define Y imag()
ld restant(P p) { return abs(p); }
// polar(x,y) mag=l,arg=y
// typedef unordered_set<ll> usll;
// typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
// typedef unordered_multiset<int> umsi;
// typedef unordered_set<int> usi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<double, double>> vpd;
typedef pair<double, double> pd;
typedef priority_queue<int> pqi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ind_set;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update>
ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define mo 1000000007
#define inf 9223372036854775807
#define ninf -inf
#define ima 2147483647
#define imi -ima
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
#define all(x) x.be(), x.en()
#define eps 1e-9
const ld PI = 3.14159265359;
inline ll modpow(ll x, ll n) {
if (n == 0)
return 1;
if (n == 1)
return (x % mo);
ll u = (modpow(x, n / 2));
u = (u * u) % mo;
if (n % 2 != 0)
u = (u * x % mo) % mo;
return u;
}
inline ll modinv(ll x) { return modpow(x, mo - 2); }
inline ll mmul(ll a, ll b) {
if (a >= mo)
a = a % mo;
if (b >= mo)
b = b % mo;
if (a * b >= mo)
return (a * b) % mo;
return (a * b);
}
inline ll madd(ll a, ll b) {
if (a >= mo)
a = a % mo;
if (b >= mo)
b = b % mo;
if (a + b >= mo)
return (a + b) % mo;
return (a + b);
}
inline ll msub(ll a, ll b) {
if (a >= mo)
a = a % mo;
if (b >= mo)
b = b % mo;
return ((a - b + mo) % mo);
}
inline ll mdiv(ll a, ll bb) {
if (a >= mo)
a = a % mo;
ll b = modinv(bb);
if (b >= mo)
b = b % mo;
if (a * b >= mo)
return (a * b) % mo;
return (a * b);
}
inline ll gcd(ll a, ll b) { return __gcd(a, b); }
void dfs(int cur, int par[], vpi ch[], vpi ad[]) {
// arr[cur]=ct++;
// sbs[cur]=1;
for (int i = 0; i < ad[cur].size(); i++) {
int j = ad[cur][i].fi;
if (j != par[cur]) {
// hi[j]=hi[cur]+1;
par[j] = cur;
ch[cur].pb(ad[cur][i]);
dfs(j, par, ch, ad);
// sbs[cur]+=sbs[j];
}
}
// dep[cur]=ct++;
}
void col(int cur, vpi ch[], int c[]) {
for (int i = 0; i < ch[cur].size(); i++) {
int j = ch[cur][i].fi;
if (ch[cur][i].se == 0)
c[j] = c[cur];
else
c[j] = 1 - c[cur];
col(j, ch, c);
}
}
int main() {
io int testcases = 1; // cin>>testcases;
while (testcases--) {
int n;
cin >> n;
vpi ad[n + 1];
int a, b, w;
for (int i = 1; i <= n - 1; i++) {
cin >> a >> b >> w;
ad[a].pb(mp(b, w));
ad[b].pb(mp(a, w));
}
int par[n + 1] = {0};
// int arr[n+1],dep[n+1];
// int hi[n+1]={0};
// int ct=0;
vpi ch[n + 1];
// int sbs[n+1]={0};
dfs(1, par, ch, ad);
int c[n + 1] = {0};
col(1, ch, c);
for (int i = 1; i <= n; i++)
cout << c[i] << "\n";
}
return 0;
} | //----AUTHOR:kkdrummer----/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> P;
#define X real()
#define Y imag()
ld restant(P p) { return abs(p); }
// polar(x,y) mag=l,arg=y
// typedef unordered_set<ll> usll;
// typedef unordered_multiset<ll> umsll;
typedef multiset<ll> msll;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll> pqll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
// typedef unordered_multiset<int> umsi;
// typedef unordered_set<int> usi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<double, double>> vpd;
typedef pair<double, double> pd;
typedef priority_queue<int> pqi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ind_set;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update>
ind_setll;
#define in insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define be begin
#define en end
#define itr iterator
#define io \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define mo 1000000007
#define inf 9223372036854775807
#define ninf -inf
#define ima 2147483647
#define imi -ima
#define oncnt __builtin_popcount
#define zerobegin __builtin_clz
#define zeroend __builtin_ctz
#define parity __builtin_parity
#define all(x) x.be(), x.en()
#define eps 1e-9
const ld PI = 3.14159265359;
inline ll modpow(ll x, ll n) {
if (n == 0)
return 1;
if (n == 1)
return (x % mo);
ll u = (modpow(x, n / 2));
u = (u * u) % mo;
if (n % 2 != 0)
u = (u * x % mo) % mo;
return u;
}
inline ll modinv(ll x) { return modpow(x, mo - 2); }
inline ll mmul(ll a, ll b) {
if (a >= mo)
a = a % mo;
if (b >= mo)
b = b % mo;
if (a * b >= mo)
return (a * b) % mo;
return (a * b);
}
inline ll madd(ll a, ll b) {
if (a >= mo)
a = a % mo;
if (b >= mo)
b = b % mo;
if (a + b >= mo)
return (a + b) % mo;
return (a + b);
}
inline ll msub(ll a, ll b) {
if (a >= mo)
a = a % mo;
if (b >= mo)
b = b % mo;
return ((a - b + mo) % mo);
}
inline ll mdiv(ll a, ll bb) {
if (a >= mo)
a = a % mo;
ll b = modinv(bb);
if (b >= mo)
b = b % mo;
if (a * b >= mo)
return (a * b) % mo;
return (a * b);
}
inline ll gcd(ll a, ll b) { return __gcd(a, b); }
void dfs(int cur, int par[], vpi ch[], vpi ad[]) {
// arr[cur]=ct++;
// sbs[cur]=1;
for (int i = 0; i < ad[cur].size(); i++) {
int j = ad[cur][i].fi;
if (j != par[cur]) {
// hi[j]=hi[cur]+1;
par[j] = cur;
ch[cur].pb(ad[cur][i]);
dfs(j, par, ch, ad);
// sbs[cur]+=sbs[j];
}
}
// dep[cur]=ct++;
}
void col(int cur, vpi ch[], int c[]) {
for (int i = 0; i < ch[cur].size(); i++) {
int j = ch[cur][i].fi;
// cout<<cur<<" "<<j<<" "<<ch[cur][i].se<<"\n";
if (ch[cur][i].se == 0)
c[j] = c[cur];
else
c[j] = 1 - c[cur];
col(j, ch, c);
}
}
int main() {
io int testcases = 1; // cin>>testcases;
while (testcases--) {
int n;
cin >> n;
vpi ad[n + 1];
int a, b, w;
for (int i = 1; i <= n - 1; i++) {
cin >> a >> b >> w;
w = w % 2;
ad[a].pb(mp(b, w));
ad[b].pb(mp(a, w));
}
int par[n + 1] = {0};
// int arr[n+1],dep[n+1];
// int hi[n+1]={0};
// int ct=0;
vpi ch[n + 1];
// int sbs[n+1]={0};
dfs(1, par, ch, ad);
int c[n + 1] = {0};
col(1, ch, c);
for (int i = 1; i <= n; i++)
cout << c[i] << "\n";
}
return 0;
} | [
"assignment.add"
] | 862,251 | 862,252 | u452240501 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
using lli = long long int;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
o << "{";
for (int i = 0; i < (int)v.size(); i++)
o << (i > 0 ? ", " : "") << v[i];
o << "}";
return o;
}
template <class T> ostream &operator<<(ostream &o, const pair<T, T> &p) {
o << "(" << p.first << ", " << p.second << ")";
return o;
}
#define rep(i, n) for (lli i = 0; i < (lli)(n); i++)
const lli MOD = 1000000007LL;
lli modpow(lli a, lli n) {
lli res = 1;
for (lli ai = a; n; n >>= 1) {
if (1 & n)
res = (res * ai) % MOD;
ai = (ai * ai) % MOD;
}
return res;
}
lli inv(lli n) { return modpow(n, MOD - 2); }
lli modperm(lli n, lli k) {
lli res = 1;
rep(i, k) { res = (res * (n - i)) % MOD; }
return res;
}
lli modcomb(lli n, lli k) { return (modperm(n, k) * inv(modperm(k, k))) % MOD; }
lli posmod(lli n) {
lli res = n;
res %= MOD;
if (res < 0)
res += MOD;
return res;
}
#define MAX_N 100000
lli n;
vector<vector<pair<lli, lli>>> node(MAX_N);
vector<bool> seen(MAX_N);
vector<lli> res(MAX_N);
void dfs(lli k, int c) {
if (seen[k])
return;
res[k] = c;
seen[k] = true;
for (auto i : node[k]) {
if (i.second % 2 == 0)
dfs(i.first, c);
else
dfs(i.first, 1 - c);
}
return;
}
int main(void) {
cin >> n;
rep(i, n) {
lli u, v, w;
cin >> u >> v >> w;
u--;
v--;
node[u].push_back(make_pair(v, w));
node[v].push_back(make_pair(u, w));
}
dfs(0, 0);
rep(i, n) { cout << res[i] << endl; }
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using lli = long long int;
template <class T> ostream &operator<<(ostream &o, const vector<T> &v) {
o << "{";
for (int i = 0; i < (int)v.size(); i++)
o << (i > 0 ? ", " : "") << v[i];
o << "}";
return o;
}
template <class T> ostream &operator<<(ostream &o, const pair<T, T> &p) {
o << "(" << p.first << ", " << p.second << ")";
return o;
}
#define rep(i, n) for (lli i = 0; i < (lli)(n); i++)
const lli MOD = 1000000007LL;
lli modpow(lli a, lli n) {
lli res = 1;
for (lli ai = a; n; n >>= 1) {
if (1 & n)
res = (res * ai) % MOD;
ai = (ai * ai) % MOD;
}
return res;
}
lli inv(lli n) { return modpow(n, MOD - 2); }
lli modperm(lli n, lli k) {
lli res = 1;
rep(i, k) { res = (res * (n - i)) % MOD; }
return res;
}
lli modcomb(lli n, lli k) { return (modperm(n, k) * inv(modperm(k, k))) % MOD; }
lli posmod(lli n) {
lli res = n;
res %= MOD;
if (res < 0)
res += MOD;
return res;
}
#define MAX_N 100000
lli n;
vector<vector<pair<lli, lli>>> node(MAX_N);
vector<bool> seen(MAX_N);
vector<lli> res(MAX_N);
void dfs(lli k, int c) {
if (seen[k])
return;
res[k] = c;
seen[k] = true;
for (auto i : node[k]) {
if (i.second % 2 == 0)
dfs(i.first, c);
else
dfs(i.first, 1 - c);
}
return;
}
int main(void) {
cin >> n;
rep(i, n - 1) {
lli u, v, w;
cin >> u >> v >> w;
u--;
v--;
node[u].push_back(make_pair(v, w));
node[v].push_back(make_pair(u, w));
}
dfs(0LL, 0);
rep(i, n) { cout << res[i] << endl; }
return 0;
}
| [
"literal.number.type.widen.change"
] | 862,263 | 862,264 | u720447689 | cpp |
p03044 | #include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
vector<int> colour;
vector<vector<pair<int, int>>> G;
void dfs(int num, int parent) {
for (auto item : G[num]) {
if (item.first == parent)
continue;
if (item.second) {
colour[item.first] = (colour[parent] + 1) % 2;
} else {
colour[item.first] = colour[parent];
}
dfs(item.first, num);
}
}
int main() {
int N;
cin >> N;
G = vector<vector<pair<int, int>>>(N, vector<pair<int, int>>());
colour.assign(N, -1);
rep(i, N - 1) {
int u, v;
long long int w;
cin >> u >> v >> w;
u--;
v--;
G[u].push_back(make_pair(v, w % 2));
G[v].push_back(make_pair(u, w % 2));
}
colour[0] = 0;
dfs(0, -1);
rep(i, N) { cout << colour[i] << endl; }
return 0;
} | #include <iostream>
#include <utility>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
vector<int> colour;
vector<vector<pair<int, int>>> G;
void dfs(int num, int parent) {
for (auto item : G[num]) {
if (item.first == parent)
continue;
if (item.second) {
colour[item.first] = (colour[num] + 1) % 2;
} else {
colour[item.first] = colour[num];
}
dfs(item.first, num);
}
}
int main() {
int N;
cin >> N;
G = vector<vector<pair<int, int>>>(N, vector<pair<int, int>>());
colour.assign(N, -1);
rep(i, N - 1) {
int u, v;
long long int w;
cin >> u >> v >> w;
u--;
v--;
G[u].push_back(make_pair(v, w % 2));
G[v].push_back(make_pair(u, w % 2));
}
colour[0] = 0;
dfs(0, -1);
rep(i, N) { cout << colour[i] << endl; }
return 0;
} | [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 862,279 | 862,280 | u806657856 | cpp |
p03044 | #include <bits/stdc++.h>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
rep(i, (int)v.size()) {
if (i)
os << ",";
os << v[i];
}
os << "}";
return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
for (auto val : array)
std::cout << val << ", ";
std::cout << "\n";
}
const int mod = 1e9 + 7;
const ll inf = 1e18 + 5;
struct UnionFind {
vi parent, rank, count;
UnionFind(const int nodeSize)
: parent(nodeSize), rank(nodeSize, 1), count(nodeSize) {
rep(i, nodeSize) parent[i] = i, count[i] = 1;
}
int find(int x) {
if (parent[x] == x)
return x;
return parent[x] = find(parent[x]);
}
void unite(int x, int y) {
int rx = find(x);
int ry = find(y);
if (rx == ry)
return;
if (rank[rx] < rank[ry])
swap(rx, ry);
parent[ry] = rx;
count[rx] += count[ry];
if (rank[rx] == rank[ry])
++rank[rx];
}
bool same(int x, int y) { return find(x) == find(y); }
int num(int x) { return count[find(x)]; }
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(10);
int n;
std::cin >> n;
struct Edge {
int to, cost;
};
vector<vector<Edge>> tree(n);
rep(i, n) {
int u, v, w;
std::cin >> u >> v >> w;
u--, v--, w = w & 1;
tree[u].pb({v, w}), tree[v].pb({u, w});
}
vl ans(n, inf);
ans[0] = 0;
vi que;
que.pb(0);
rep(i, que.size()) {
int cur = que[i];
for (auto edge : tree[cur]) {
if (ans[edge.to] != inf)
continue;
ans[edge.to] = (ans[cur] + edge.cost) & 1;
que.pb(edge.to);
}
}
rep(i, n) std::cout << (ans[i] & 1) << "\n";
}
| #include <bits/stdc++.h>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
rep(i, (int)v.size()) {
if (i)
os << ",";
os << v[i];
}
os << "}";
return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
for (auto val : array)
std::cout << val << ", ";
std::cout << "\n";
}
const int mod = 1e9 + 7;
const ll inf = 1e18 + 5;
struct UnionFind {
vi parent, rank, count;
UnionFind(const int nodeSize)
: parent(nodeSize), rank(nodeSize, 1), count(nodeSize) {
rep(i, nodeSize) parent[i] = i, count[i] = 1;
}
int find(int x) {
if (parent[x] == x)
return x;
return parent[x] = find(parent[x]);
}
void unite(int x, int y) {
int rx = find(x);
int ry = find(y);
if (rx == ry)
return;
if (rank[rx] < rank[ry])
swap(rx, ry);
parent[ry] = rx;
count[rx] += count[ry];
if (rank[rx] == rank[ry])
++rank[rx];
}
bool same(int x, int y) { return find(x) == find(y); }
int num(int x) { return count[find(x)]; }
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(10);
int n;
std::cin >> n;
struct Edge {
int to, cost;
};
vector<vector<Edge>> tree(n);
rep(i, n - 1) {
int u, v, w;
std::cin >> u >> v >> w;
u--, v--, w = w & 1;
tree[u].pb({v, w}), tree[v].pb({u, w});
}
vl ans(n, inf);
ans[0] = 0;
vi que;
que.pb(0);
rep(i, que.size()) {
int cur = que[i];
for (auto edge : tree[cur]) {
if (ans[edge.to] != inf)
continue;
ans[edge.to] = (ans[cur] + edge.cost) & 1;
que.pb(edge.to);
}
}
rep(i, n) std::cout << (ans[i] & 1) << "\n";
}
| [
"expression.operation.binary.add"
] | 862,294 | 862,295 | u700484101 | cpp |
p03044 | #include <bits/stdc++.h>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
rep(i, (int)v.size()) {
if (i)
os << ",";
os << v[i];
}
os << "}";
return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
for (auto val : array)
std::cout << val << ", ";
std::cout << "\n";
}
const int mod = 1e9 + 7;
const ll inf = 1e18 + 5;
struct UnionFind {
vi parent, rank, count;
UnionFind(const int nodeSize)
: parent(nodeSize), rank(nodeSize, 1), count(nodeSize) {
rep(i, nodeSize) parent[i] = i, count[i] = 1;
}
int find(int x) {
if (parent[x] == x)
return x;
return parent[x] = find(parent[x]);
}
void unite(int x, int y) {
int rx = find(x);
int ry = find(y);
if (rx == ry)
return;
if (rank[rx] < rank[ry])
swap(rx, ry);
parent[ry] = rx;
count[rx] += count[ry];
if (rank[rx] == rank[ry])
++rank[rx];
}
bool same(int x, int y) { return find(x) == find(y); }
int num(int x) { return count[find(x)]; }
};
struct Edge {
int to, cost;
};
vector<vector<Edge>> tree;
vl ans;
void dfs(int par, int now) {
for (auto &edge : tree[now])
if (edge.to != par) {
ans[edge.to] = ans[now] + edge.cost;
dfs(now, edge.to);
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(10);
int n;
std::cin >> n;
tree.resize(n);
rep(i, n) {
int u, v, w;
std::cin >> u >> v >> w;
u--, v--;
tree[u].pb({v, w}), tree[v].pb({u, w});
}
ans.resize(n);
ans[0] = 0;
dfs(-1, 0);
rep(i, n) std::cout << (ans[i] & 1) << "\n";
}
| #include <bits/stdc++.h>
#include <type_traits>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
os << "{";
rep(i, (int)v.size()) {
if (i)
os << ",";
os << v[i];
}
os << "}";
return os;
}
template <typename T, size_t S> void printArray(const T (&array)[S]) {
for (auto val : array)
std::cout << val << ", ";
std::cout << "\n";
}
const int mod = 1e9 + 7;
const ll inf = 1e18 + 5;
struct UnionFind {
vi parent, rank, count;
UnionFind(const int nodeSize)
: parent(nodeSize), rank(nodeSize, 1), count(nodeSize) {
rep(i, nodeSize) parent[i] = i, count[i] = 1;
}
int find(int x) {
if (parent[x] == x)
return x;
return parent[x] = find(parent[x]);
}
void unite(int x, int y) {
int rx = find(x);
int ry = find(y);
if (rx == ry)
return;
if (rank[rx] < rank[ry])
swap(rx, ry);
parent[ry] = rx;
count[rx] += count[ry];
if (rank[rx] == rank[ry])
++rank[rx];
}
bool same(int x, int y) { return find(x) == find(y); }
int num(int x) { return count[find(x)]; }
};
struct Edge {
int to, cost;
};
vector<vector<Edge>> tree;
vl ans;
void dfs(int par, int now) {
for (auto &edge : tree[now])
if (edge.to != par) {
ans[edge.to] = ans[now] + edge.cost;
dfs(now, edge.to);
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << std::setprecision(10);
int n;
std::cin >> n;
tree.resize(n);
rep(i, n - 1) {
int u, v, w;
std::cin >> u >> v >> w;
u--, v--;
tree[u].pb({v, w}), tree[v].pb({u, w});
}
ans.resize(n);
ans[0] = 0;
dfs(-1, 0);
rep(i, n) std::cout << (ans[i] & 1) << "\n";
}
| [
"expression.operation.binary.add"
] | 862,296 | 862,297 | u700484101 | cpp |
p03044 | #include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <float.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define i64 long long
#define int long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template <typename T> void DEBUG(T e) {
if (DEBUG_OUT == false)
return;
std::cout << e << std::endl;
}
template <typename T> void DEBUG(const std::vector<T> &v) {
if (DEBUG_OUT == false)
return;
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) {
if (DEBUG_OUT == false)
return;
for (const auto &v : vv) {
DEBUG(v);
}
}
template <class T, class X> void DEBUG(X d, T e) {
if (DEBUG_OUT == false)
return;
std::cout << d << " ";
DEBUG(e);
};
template <class T> void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
// CODE
struct edge {
int to;
int weight;
};
void DFS(int V, vector<vector<edge>> &GRAPH, vector<bool> used,
vector<int> &node, int color) {
used[V] = true;
// DEBUG(V);
for (int i = 0; i < GRAPH[V].size(); i++) {
int TO = GRAPH[V][i].to;
int W = GRAPH[V][i].weight;
if (used[TO] == false) {
if (W % 2 == 0) {
node[TO] = color ^ 1;
DFS(TO, GRAPH, used, node, color ^ 1);
} else {
node[TO] = color ^ 1;
DFS(TO, GRAPH, used, node, color ^ 1);
}
}
}
}
void solve(void) {
int N;
cin >> N;
vector<vector<edge>> GRAPH(N);
for (int i = 0; i < N - 1; i++) {
int A, B, C;
cin >> A >> B >> C;
A--;
B--;
edge E1 = {B, C};
edge E2 = {A, C};
GRAPH[A].push_back(E1);
GRAPH[B].push_back(E2);
}
vector<int> NODES(N);
vector<bool> used(N);
NODES[0] = 0;
DFS(0, GRAPH, used, NODES, 0);
for (int i = 0; i < NODES.size(); i++) {
cout << NODES[i] << endl;
}
return;
}
int32_t main(int32_t argc, const char *argv[]) {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();
return 0;
}
| #include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <float.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define i64 long long
#define int long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template <typename T> void DEBUG(T e) {
if (DEBUG_OUT == false)
return;
std::cout << e << std::endl;
}
template <typename T> void DEBUG(const std::vector<T> &v) {
if (DEBUG_OUT == false)
return;
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) {
if (DEBUG_OUT == false)
return;
for (const auto &v : vv) {
DEBUG(v);
}
}
template <class T, class X> void DEBUG(X d, T e) {
if (DEBUG_OUT == false)
return;
std::cout << d << " ";
DEBUG(e);
};
template <class T> void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
// CODE
struct edge {
int to;
int weight;
};
void DFS(int V, vector<vector<edge>> &GRAPH, vector<bool> used,
vector<int> &node, int color) {
used[V] = true;
// DEBUG(V);
for (int i = 0; i < GRAPH[V].size(); i++) {
int TO = GRAPH[V][i].to;
int W = GRAPH[V][i].weight;
if (used[TO] == false) {
if (W % 2 == 0) {
node[TO] = color;
DFS(TO, GRAPH, used, node, color);
} else {
node[TO] = color ^ 1;
DFS(TO, GRAPH, used, node, color ^ 1);
}
}
}
}
void solve(void) {
int N;
cin >> N;
vector<vector<edge>> GRAPH(N);
for (int i = 0; i < N - 1; i++) {
int A, B, C;
cin >> A >> B >> C;
A--;
B--;
edge E1 = {B, C};
edge E2 = {A, C};
GRAPH[A].push_back(E1);
GRAPH[B].push_back(E2);
}
vector<int> NODES(N);
vector<bool> used(N);
NODES[0] = 0;
DFS(0, GRAPH, used, NODES, 0);
for (int i = 0; i < NODES.size(); i++) {
cout << NODES[i] << endl;
}
return;
}
int32_t main(int32_t argc, const char *argv[]) {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();
return 0;
}
| [
"expression.operation.binary.remove"
] | 862,305 | 862,306 | u221285045 | cpp |
p03044 | #include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <float.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define i64 long long
#define int long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template <typename T> void DEBUG(T e) {
if (DEBUG_OUT == false)
return;
std::cout << e << std::endl;
}
template <typename T> void DEBUG(const std::vector<T> &v) {
if (DEBUG_OUT == false)
return;
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) {
if (DEBUG_OUT == false)
return;
for (const auto &v : vv) {
DEBUG(v);
}
}
template <class T, class X> void DEBUG(X d, T e) {
if (DEBUG_OUT == false)
return;
std::cout << d << " ";
DEBUG(e);
};
template <class T> void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
// CODE
struct edge {
int to;
int weight;
};
void DFS(int V, vector<vector<edge>> &GRAPH, vector<bool> used,
vector<int> &node, int color) {
used[V] = true;
// DEBUG(V);
for (int i = 0; i < GRAPH[V].size(); i++) {
int TO = GRAPH[V][i].to;
int W = GRAPH[V][i].weight;
if (used[TO] == false) {
if (W % 2 == 0) {
node[TO] = color;
DFS(TO, GRAPH, used, node, color);
} else {
node[TO] = color ^ 1;
DFS(TO, GRAPH, used, node, color);
}
}
}
}
void solve(void) {
int N;
cin >> N;
vector<vector<edge>> GRAPH(N);
for (int i = 0; i < N - 1; i++) {
int A, B, C;
cin >> A >> B >> C;
A--;
B--;
edge E1 = {B, C};
edge E2 = {A, C};
GRAPH[A].push_back(E1);
GRAPH[B].push_back(E2);
}
vector<int> NODES(N);
vector<bool> used(N);
NODES[0] = 0;
DFS(0, GRAPH, used, NODES, 0);
for (int i = 0; i < NODES.size(); i++) {
cout << NODES[i] << endl;
}
return;
}
int32_t main(int32_t argc, const char *argv[]) {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();
return 0;
}
| #include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <float.h>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
#define i64 long long
#define int long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template <typename T> void DEBUG(T e) {
if (DEBUG_OUT == false)
return;
std::cout << e << std::endl;
}
template <typename T> void DEBUG(const std::vector<T> &v) {
if (DEBUG_OUT == false)
return;
for (const auto &e : v) {
std::cout << e << " ";
}
std::cout << std::endl;
}
template <typename T> void DEBUG(const std::vector<std::vector<T>> &vv) {
if (DEBUG_OUT == false)
return;
for (const auto &v : vv) {
DEBUG(v);
}
}
template <class T, class X> void DEBUG(X d, T e) {
if (DEBUG_OUT == false)
return;
std::cout << d << " ";
DEBUG(e);
};
template <class T> void corner(bool flg, T hoge) {
if (flg) {
cout << hoge << endl;
exit(0);
}
}
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
return a > b && (a = b, true);
}
// CODE
struct edge {
int to;
int weight;
};
void DFS(int V, vector<vector<edge>> &GRAPH, vector<bool> used,
vector<int> &node, int color) {
used[V] = true;
// DEBUG(V);
for (int i = 0; i < GRAPH[V].size(); i++) {
int TO = GRAPH[V][i].to;
int W = GRAPH[V][i].weight;
if (used[TO] == false) {
if (W % 2 == 0) {
node[TO] = color;
DFS(TO, GRAPH, used, node, color);
} else {
node[TO] = color ^ 1;
DFS(TO, GRAPH, used, node, color ^ 1);
}
}
}
}
void solve(void) {
int N;
cin >> N;
vector<vector<edge>> GRAPH(N);
for (int i = 0; i < N - 1; i++) {
int A, B, C;
cin >> A >> B >> C;
A--;
B--;
edge E1 = {B, C};
edge E2 = {A, C};
GRAPH[A].push_back(E1);
GRAPH[B].push_back(E2);
}
vector<int> NODES(N);
vector<bool> used(N);
NODES[0] = 0;
DFS(0, GRAPH, used, NODES, 0);
for (int i = 0; i < NODES.size(); i++) {
cout << NODES[i] << endl;
}
return;
}
int32_t main(int32_t argc, const char *argv[]) {
std::ios::sync_with_stdio(false);
std::cin.tie(0);
std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();
return 0;
}
| [
"expression.operation.binary.add"
] | 862,308 | 862,306 | u221285045 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
const int N = 100010;
vector<pair<int, int>> G[N];
vector<int> C(N);
vector<bool> seen(N);
int n;
void dfs(int now, int pre) {
seen[now] = true;
for (int i = 0; i < G[now].size(); i++) {
int to = G[now][i].first;
if (to == pre or seen[to])
continue;
int cost = G[now][i].second;
if (cost % 2) {
C[to] = C[now] ^ 1;
} else {
C[to] = C[now];
}
dfs(to, now);
}
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
w %= 2;
G[u].push_back({v, w});
G[v].push_back({w, w});
}
dfs(0, -1);
for (int i = 0; i < n; i++) {
cout << C[i] << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int N = 100010;
vector<pair<int, int>> G[N];
vector<int> C(N);
vector<bool> seen(N);
int n;
void dfs(int now, int pre) {
seen[now] = true;
for (int i = 0; i < G[now].size(); i++) {
int to = G[now][i].first;
if (to == pre or seen[to])
continue;
int cost = G[now][i].second;
if (cost % 2) {
C[to] = C[now] ^ 1;
} else {
C[to] = C[now];
}
dfs(to, now);
}
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cin >> n;
for (int i = 0; i < n - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
w %= 2;
G[u].push_back({v, w});
G[v].push_back({u, w});
}
dfs(0, -1);
for (int i = 0; i < n; i++) {
cout << C[i] << endl;
}
return 0;
} | [
"identifier.change",
"call.arguments.change"
] | 862,309 | 862,310 | u136869985 | cpp |
p03044 | #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (n); (i)++)
using namespace std;
struct Edge {
int to;
int weight;
Edge(int t, int w) : to(t), weight(w) {}
};
long modpow(long a, long n, long mod) {
long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// a^{-1} mod ใ่จ็ฎใใ
long modinv(long a, long mod) { return modpow(a, mod - 2, mod); }
struct compare1 {
bool operator()(const pair<long, long> &value, const long &key) {
return (value.first < key);
}
bool operator()(const long &key, const pair<long, long> &value) {
return (key < value.first);
}
};
struct UnionFind {
vector<int> par;
vector<int> rank;
UnionFind(int n = 1) { init(n); }
void init(int n = 1) {
par.resize(n);
rank.resize(n);
REP(i, n) par[i] = i, rank[i] = 0;
}
int root(int x) {
if (par[x] == x)
return x;
else
return par[x] = root(par[x]);
}
bool issame(int x, int y) { return root(x) == root(y); }
bool merge(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (rank[x] < rank[y])
swap(x, y);
if (rank[x] == rank[y])
rank[x]++;
par[y] = x;
return true;
}
};
template <class Abel> struct weightedUnionFind {
vector<int> par;
vector<int> rank;
vector<Abel> diff_weight;
weightedUnionFind(int n = 1, Abel SUM_UNITY = 0) { init(n, SUM_UNITY); }
void init(int n = 1, Abel SUM_UNITY = 0) {
par.resize(n);
rank.resize(n);
diff_weight.resize(n);
REP(i, n) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
}
int root(int x) {
if (par[x] == x)
return x;
else {
int r = root(par[x]);
diff_weight[x] += diff_weight[par[x]];
return par[x] = r;
}
}
Abel weight(int x) {
root(x);
return diff_weight[x];
}
bool issame(int x, int y) { return root(x) == root(y); }
bool merge(int x, int y, Abel w) {
w += weight(x);
w -= weight(y);
x = root(x);
y = root(y);
if (x == y)
return false;
if (rank[x] < rank[y])
swap(x, y), w = -w;
if (rank[x] == rank[y])
rank[x]++;
par[y] = x;
diff_weight[y] = w;
return true;
}
Abel diff(int x, int y) { return weight(y) - weight(x); }
};
using Graph = vector<vector<Edge>>;
using P = pair<int, pair<int, int>>;
void rec(int i, int c, Graph &G, int *color) {
color[i] = c;
for (auto next : G[i]) {
if (color[next.to] != -1)
continue;
if (next.weight % 2 != 0) {
rec(next.to, 1 - c, G, color);
} else {
rec(next.to, c, G, color);
}
}
}
int main() {
int N;
cin >> N;
Graph G(N);
REP(i, N) {
int u, v, w;
cin >> u >> v >> w;
u--, v--;
G[u].push_back(Edge(v, w));
G[v].push_back(Edge(u, w));
}
int color[100005];
REP(i, N) color[i] = -1;
rec(0, 0, G, color);
REP(i, N) cout << color[i] << endl;
return 0;
}
| #include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (n); (i)++)
using namespace std;
struct Edge {
int to;
int weight;
Edge(int t, int w) : to(t), weight(w) {}
};
long modpow(long a, long n, long mod) {
long res = 1;
while (n > 0) {
if (n & 1)
res = res * a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
// a^{-1} mod ใ่จ็ฎใใ
long modinv(long a, long mod) { return modpow(a, mod - 2, mod); }
struct compare1 {
bool operator()(const pair<long, long> &value, const long &key) {
return (value.first < key);
}
bool operator()(const long &key, const pair<long, long> &value) {
return (key < value.first);
}
};
struct UnionFind {
vector<int> par;
vector<int> rank;
UnionFind(int n = 1) { init(n); }
void init(int n = 1) {
par.resize(n);
rank.resize(n);
REP(i, n) par[i] = i, rank[i] = 0;
}
int root(int x) {
if (par[x] == x)
return x;
else
return par[x] = root(par[x]);
}
bool issame(int x, int y) { return root(x) == root(y); }
bool merge(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return false;
if (rank[x] < rank[y])
swap(x, y);
if (rank[x] == rank[y])
rank[x]++;
par[y] = x;
return true;
}
};
template <class Abel> struct weightedUnionFind {
vector<int> par;
vector<int> rank;
vector<Abel> diff_weight;
weightedUnionFind(int n = 1, Abel SUM_UNITY = 0) { init(n, SUM_UNITY); }
void init(int n = 1, Abel SUM_UNITY = 0) {
par.resize(n);
rank.resize(n);
diff_weight.resize(n);
REP(i, n) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
}
int root(int x) {
if (par[x] == x)
return x;
else {
int r = root(par[x]);
diff_weight[x] += diff_weight[par[x]];
return par[x] = r;
}
}
Abel weight(int x) {
root(x);
return diff_weight[x];
}
bool issame(int x, int y) { return root(x) == root(y); }
bool merge(int x, int y, Abel w) {
w += weight(x);
w -= weight(y);
x = root(x);
y = root(y);
if (x == y)
return false;
if (rank[x] < rank[y])
swap(x, y), w = -w;
if (rank[x] == rank[y])
rank[x]++;
par[y] = x;
diff_weight[y] = w;
return true;
}
Abel diff(int x, int y) { return weight(y) - weight(x); }
};
using Graph = vector<vector<Edge>>;
using P = pair<int, pair<int, int>>;
void rec(int i, int c, Graph &G, int *color) {
color[i] = c;
for (auto next : G[i]) {
if (color[next.to] != -1)
continue;
if (next.weight % 2 != 0) {
rec(next.to, 1 - c, G, color);
} else {
rec(next.to, c, G, color);
}
}
}
int main() {
int N;
cin >> N;
Graph G(N);
REP(i, N - 1) {
int u, v, w;
cin >> u >> v >> w;
u--, v--;
G[u].push_back(Edge(v, w));
G[v].push_back(Edge(u, w));
}
int color[100005];
REP(i, N) color[i] = -1;
rec(0, 0, G, color);
REP(i, N) cout << color[i] << endl;
return 0;
}
| [
"expression.operation.binary.add"
] | 862,321 | 862,322 | u216491514 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define mem(dp, a) memset(dp, a, sizeof dp)
#define ninja \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define nl '\n'
#define inf 1e9 + 7
vector<pii> adj[100003];
bool vis[100003];
vector<int> node(10003);
void dfs(int s, int color) {
vis[s] = 1;
node[s] = color;
for (auto i : adj[s]) {
if (!vis[i.ff]) {
if (i.ss & 1)
dfs(i.ff, 1);
else
dfs(i.ff, 0);
}
}
}
int main() {
ninja
int n;
cin >> n;
int a, b, w;
for (int i = 0; i < n - 1; i++) {
cin >> a >> b >> w;
adj[a].pb(mp(b, w));
adj[b].pb(mp(a, w));
}
mem(vis, 0);
dfs(1, 0);
for (int i = 1; i <= n; i++)
cout << node[i] << nl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
#define mem(dp, a) memset(dp, a, sizeof dp)
#define ninja \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define nl '\n'
#define inf 1e9 + 7
vector<pii> adj[100003];
bool vis[100003];
vector<int> node(100003);
void dfs(int s, int color) {
vis[s] = 1;
node[s] = color;
for (auto i : adj[s]) {
if (!vis[i.ff]) {
if (i.ss & 1)
dfs(i.ff, !color);
else
dfs(i.ff, color);
}
}
}
int main() {
ninja
int n;
cin >> n;
int a, b, w;
for (int i = 0; i < n - 1; i++) {
cin >> a >> b >> w;
adj[a].pb(mp(b, w));
adj[b].pb(mp(a, w));
}
mem(vis, 0);
dfs(1, 0);
for (int i = 1; i <= n; i++)
cout << node[i] << nl;
} | [
"literal.number.change",
"call.arguments.change",
"expression.operation.unary.add",
"identifier.replace.add",
"literal.replace.remove"
] | 862,323 | 862,324 | u504940906 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__; // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);
struct mint {
// Preparation: MOD is already defined.
ll value;
mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
mint pow(mint m) const { return pow(m.value); }
mint inv() const {
ll a = value, b = MOD, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= MOD;
return u;
}
mint &operator+=(const mint a) {
if ((value += a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((value += MOD - a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(value *= a.value) %= MOD;
return *this;
}
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
struct edge {
int to;
int cost;
};
vector<vector<edge>> v(MAX_N);
vector<int> ans(MAX_N);
vector<bool> seen(MAX_N);
void dfs(int from, int color) {
if (seen[from])
return;
seen[from] = true;
ans[from] = color;
foreach (e, v[from]) {
if (e.cost % 2 == 0) {
dfs(e.to, color);
} else {
dfs(e.to, (color + 1) % 2);
}
}
}
int main() {
int n;
cin >> n;
rep(i, n) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
v[a].push_back(edge{b, c});
v[b].push_back(edge{a, c});
}
dfs(0, 0);
rep(i, n) { cout << ans[i] << endl; }
}
| #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__; // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);
struct mint {
// Preparation: MOD is already defined.
ll value;
mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
mint pow(mint m) const { return pow(m.value); }
mint inv() const {
ll a = value, b = MOD, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= MOD;
return u;
}
mint &operator+=(const mint a) {
if ((value += a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((value += MOD - a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(value *= a.value) %= MOD;
return *this;
}
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
struct edge {
int to;
int cost;
};
vector<vector<edge>> v(MAX_N);
vector<int> ans(MAX_N);
vector<bool> seen(MAX_N);
void dfs(int from, int color) {
if (seen[from])
return;
seen[from] = true;
ans[from] = color;
foreach (e, v[from]) {
if (e.cost % 2 == 0) {
dfs(e.to, color);
} else {
dfs(e.to, (color + 1) % 2);
}
}
}
int main() {
int n;
cin >> n;
rep(i, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
v[a].emplace_back(edge{b, c});
v[b].emplace_back(edge{a, c});
}
dfs(0, 0);
rep(i, n) { cout << ans[i] << endl; }
}
| [
"call.function.change"
] | 862,333 | 862,334 | u765690804 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__; // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);
struct mint {
// Preparation: MOD is already defined.
ll value;
mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
mint pow(mint m) const { return pow(m.value); }
mint inv() const {
ll a = value, b = MOD, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= MOD;
return u;
}
mint &operator+=(const mint a) {
if ((value += a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((value += MOD - a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(value *= a.value) %= MOD;
return *this;
}
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
struct edge {
int to;
int cost;
};
vector<vector<edge>> v(MAX_N);
vector<int> ans(MAX_N);
vector<bool> seen(MAX_N);
void dfs(int from, int color) {
if (seen[from])
return;
seen[from] = true;
ans[from] = color;
for (auto e : v[from]) {
if (e.cost % 2 == 0) {
dfs(e.to, color);
} else {
(color == 0) ? dfs(e.to, 1) : dfs(e.to, 0);
}
}
}
int main() {
int n;
cin >> n;
rep(i, n) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
v[a].emplace_back(edge{b, c});
v[b].emplace_back(edge{a, c});
}
dfs(0, 0);
rep(i, n) { cout << ans[i] << endl; }
}
| #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__; // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);
struct mint {
// Preparation: MOD is already defined.
ll value;
mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
mint pow(mint m) const { return pow(m.value); }
mint inv() const {
ll a = value, b = MOD, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= MOD;
return u;
}
mint &operator+=(const mint a) {
if ((value += a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((value += MOD - a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(value *= a.value) %= MOD;
return *this;
}
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
struct edge {
int to;
int cost;
};
vector<vector<edge>> v(MAX_N);
vector<int> ans(MAX_N);
vector<bool> seen(MAX_N);
void dfs(int from, int color) {
if (seen[from])
return;
seen[from] = true;
ans[from] = color;
foreach (e, v[from]) {
if (e.cost % 2 == 0) {
dfs(e.to, color);
} else {
(color == 0) ? dfs(e.to, 1) : dfs(e.to, 0);
}
}
}
int main() {
int n;
cin >> n;
rep(i, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
v[a].emplace_back(edge{b, c});
v[b].emplace_back(edge{a, c});
}
dfs(0, 0);
rep(i, n) { cout << ans[i] << endl; }
}
| [
"expression.operation.binary.add"
] | 862,335 | 862,336 | u765690804 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__; // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);
struct mint {
// Preparation: MOD is already defined.
ll value;
mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
mint pow(mint m) const { return pow(m.value); }
mint inv() const {
ll a = value, b = MOD, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= MOD;
return u;
}
mint &operator+=(const mint a) {
if ((value += a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((value += MOD - a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(value *= a.value) %= MOD;
return *this;
}
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
struct edge {
int to;
int cost;
};
vector<vector<edge>> v(MAX_N);
vector<int> ans(MAX_N);
vector<bool> seen(MAX_N);
void dfs(int from, int color) {
if (seen[from])
return;
seen[from] = true;
ans[from] = color;
foreach (e, v[from]) {
if (e.cost % 2 == 0) {
dfs(e.to, color);
} else {
(color == 0) ? dfs(e.to, 1) : dfs(e.to, 0);
}
}
}
int main() {
int n;
cin >> n;
rep(i, n) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
v[a].emplace_back(edge{b, c});
v[b].emplace_back(edge{a, c});
}
dfs(0, 0);
rep(i, n) { cout << ans[i] << endl; }
}
| #include <bits/stdc++.h>
using namespace std;
// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define revrepeat(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define foreach(e, v) for (auto &e : v)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
constexpr int MOD = 1e9 + 7;
constexpr int INF = __INT_MAX__; // 2^31 - 1
constexpr long long INFLL = __LONG_LONG_MAX__; // 2^61 - 1
constexpr int MAX_N = 1e5 + 5;
constexpr double PI = acos(-1);
struct mint {
// Preparation: MOD is already defined.
ll value;
mint(ll value = 0) : value((value % MOD + MOD) % MOD) {}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
mint pow(mint m) const { return pow(m.value); }
mint inv() const {
ll a = value, b = MOD, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= MOD;
return u;
}
mint &operator+=(const mint a) {
if ((value += a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator-=(const mint a) {
if ((value += MOD - a.value) >= MOD)
value -= MOD;
return *this;
}
mint &operator*=(const mint a) {
(value *= a.value) %= MOD;
return *this;
}
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
struct edge {
int to;
int cost;
};
vector<vector<edge>> v(MAX_N);
vector<int> ans(MAX_N);
vector<bool> seen(MAX_N);
void dfs(int from, int color) {
if (seen[from])
return;
seen[from] = true;
ans[from] = color;
foreach (e, v[from]) {
if (e.cost % 2 == 0) {
dfs(e.to, color);
} else {
(color == 0) ? dfs(e.to, 1) : dfs(e.to, 0);
}
}
}
int main() {
int n;
cin >> n;
rep(i, n - 1) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
v[a].emplace_back(edge{b, c});
v[b].emplace_back(edge{a, c});
}
dfs(0, 0);
rep(i, n) { cout << ans[i] << endl; }
}
| [
"expression.operation.binary.add"
] | 862,337 | 862,336 | u765690804 | cpp |
p03044 | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
/* (=๏ผพo๏ผพ=) */
#define int ll
/* macro */
#define FOR(i, b, e) for (ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for (ll i = (ll)(e - 1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x, c) for (const auto &x : (c))
#define REPI2(it, b, e) for (auto it = (b); it != (e); ++it)
#define REPI(it, c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it, c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for (auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(), (x).end()
#define cauto const auto &
/* macro func */
#define SORT(x) \
do { \
sort(ALL(x)); \
} while (false)
#define RSORT(x) \
do { \
sort((x).rbegin(), (x).rend()); \
} while (false)
#define UNIQUE(v) \
do { \
v.erase(unique(v.begin(), v.end()), v.end()); \
} while (false)
#define MAX(x, y) \
do { \
x = std::max(x, y); \
} while (false)
#define MIN(x, y) \
do { \
x = std::min(x, y); \
} while (false)
#define BR \
do { \
cout << "\n"; \
} while (false)
#define dump(...) \
do { \
auto __DUMP_NAME_LIST__ = split(#__VA_ARGS__, ','); \
print(__DUMP_NAME_LIST__, __VA_ARGS__); \
BR; \
} while (false)
/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
/* using std */
using std::cout;
constexpr char endl = '\n';
using std::bitset;
using std::cin;
using std::list;
using std::map;
using std::multimap;
using std::multiset;
using std::pair;
using std::priority_queue;
using std::queue;
using std::set;
using std::sort;
using std::stack;
using std::string;
using std::unordered_map;
using std::unordered_multimap;
using std::unordered_multiset;
using std::unordered_set;
using std::vector;
/* constant value */
constexpr ll MOD = 1000000007;
// constexpr ll MOD = 998244353;
/* Initial processing */
struct Preprocessing {
Preprocessing() {
std::cin.tie(0);
std::ios::sync_with_stdio(0);
};
} _Preprocessing;
/* define hash */
namespace std {
template <> class hash<std::pair<ll, ll>> {
public:
size_t operator()(const std::pair<ll, ll> &x) const {
return hash<ll>()(1000000000 * x.first + x.second);
}
};
} // namespace std
/* input output */
template <class T> std::istream &operator>>(std::istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
template <class S, class T>
std::ostream &operator<<(std::ostream &os, const std::pair<S, T> &p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
/* for dump function */
inline std::list<std::string> split(std::string str, char del) {
std::list<std::string> sList;
string s = "";
for (const auto &c : str) {
if (c == del) {
sList.emplace_back(s);
s = "";
} else {
if (c != ' ' || del == ' ') {
s += c;
}
}
}
sList.emplace_back(s);
return sList;
}
template <class T> struct has_begin {
private:
template <class U>
static auto check(U x) -> decltype(x.begin(), std::true_type{});
static std::false_type check(...);
public:
static bool const value = decltype(check(std::declval<T>()))::value;
};
inline void print(std::list<std::string> &str);
template <
class Primitive, class... Tail,
std::enable_if_t<!has_begin<Primitive>::value, std::nullptr_t> = nullptr>
inline void print(std::list<std::string> &str, const Primitive &x,
const Tail &...tail);
template <class Container, class... Tail>
inline auto print(std::list<std::string> &str, const Container &c,
const Tail &...tail) -> decltype(c.begin());
template <class... Tail>
inline void print(std::list<std::string> &str, const std::string &s,
const Tail &...tail);
template <class Container>
inline auto printSingle(const Container &c) -> decltype(c.begin()) {
for (const auto &x : c) {
std::cout << x << " ";
}
std::cout << "\n";
return c.begin();
}
template <class Primitive, std::enable_if_t<!has_begin<Primitive>::value,
std::nullptr_t> = nullptr>
inline void printSingle(const Primitive &x) {
std::cout << x << " ";
}
inline void print(std::list<std::string> &str) {}
template <
class Primitive, class... Tail,
std::enable_if_t<!has_begin<Primitive>::value, std::nullptr_t> = nullptr>
inline void print(std::list<std::string> &str, const Primitive &x,
const Tail &...tail) {
std::cout << *str.begin() << ":" << x << " ";
if (sizeof...(tail) > 0) {
std::cout << "\n";
str.pop_front();
print(str, tail...);
}
}
template <class Container, class... Tail>
inline auto print(std::list<std::string> &str, const Container &c,
const Tail &...tail) -> decltype(c.begin()) {
std::cout << "-- " << *str.begin() << " --\n";
for (const auto &x : c) {
printSingle(x);
BR;
}
std::cout << "\n";
str.pop_front();
print(str, tail...);
return c.begin();
}
template <class... Tail>
inline void print(std::list<std::string> &str, const std::string &s,
const Tail &...tail) {
std::cout << *str.begin() << ":" << s << "\n";
str.pop_front();
print(str, tail...);
}
//=============================================================================================
signed main() {
ll n;
cin >> n;
unordered_multimap<ll, PAIR> graph;
REP(_, n) {
ll a, b, c;
cin >> a >> b >> c;
--a;
--b;
graph.emplace(a, PAIR(b, c));
graph.emplace(b, PAIR(a, c));
}
VL c(n, -1);
queue<PAIR> q;
q.emplace(0, 0);
c[0] = 0;
while (!q.empty()) {
ll from = q.front().first;
ll dis = q.front().second;
q.pop();
auto range = graph.equal_range(from);
REPI2(itr, range.first, range.second) {
ll to = itr->second.first;
ll d = itr->second.second;
if (c[to] == -1) {
q.emplace(to, dis + d);
c[to] = ((dis + d) % 2);
}
}
}
REPC(x, c) { cout << x << endl; }
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
/* (=๏ผพo๏ผพ=) */
#define int ll
/* macro */
#define FOR(i, b, e) for (ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for (ll i = (ll)(e - 1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x, c) for (const auto &x : (c))
#define REPI2(it, b, e) for (auto it = (b); it != (e); ++it)
#define REPI(it, c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it, c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for (auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(), (x).end()
#define cauto const auto &
/* macro func */
#define SORT(x) \
do { \
sort(ALL(x)); \
} while (false)
#define RSORT(x) \
do { \
sort((x).rbegin(), (x).rend()); \
} while (false)
#define UNIQUE(v) \
do { \
v.erase(unique(v.begin(), v.end()), v.end()); \
} while (false)
#define MAX(x, y) \
do { \
x = std::max(x, y); \
} while (false)
#define MIN(x, y) \
do { \
x = std::min(x, y); \
} while (false)
#define BR \
do { \
cout << "\n"; \
} while (false)
#define dump(...) \
do { \
auto __DUMP_NAME_LIST__ = split(#__VA_ARGS__, ','); \
print(__DUMP_NAME_LIST__, __VA_ARGS__); \
BR; \
} while (false)
/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
/* using std */
using std::cout;
constexpr char endl = '\n';
using std::bitset;
using std::cin;
using std::list;
using std::map;
using std::multimap;
using std::multiset;
using std::pair;
using std::priority_queue;
using std::queue;
using std::set;
using std::sort;
using std::stack;
using std::string;
using std::unordered_map;
using std::unordered_multimap;
using std::unordered_multiset;
using std::unordered_set;
using std::vector;
/* constant value */
constexpr ll MOD = 1000000007;
// constexpr ll MOD = 998244353;
/* Initial processing */
struct Preprocessing {
Preprocessing() {
std::cin.tie(0);
std::ios::sync_with_stdio(0);
};
} _Preprocessing;
/* define hash */
namespace std {
template <> class hash<std::pair<ll, ll>> {
public:
size_t operator()(const std::pair<ll, ll> &x) const {
return hash<ll>()(1000000000 * x.first + x.second);
}
};
} // namespace std
/* input output */
template <class T> std::istream &operator>>(std::istream &is, vector<T> &vec) {
for (T &x : vec)
is >> x;
return is;
}
template <class S, class T>
std::ostream &operator<<(std::ostream &os, const std::pair<S, T> &p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
/* for dump function */
inline std::list<std::string> split(std::string str, char del) {
std::list<std::string> sList;
string s = "";
for (const auto &c : str) {
if (c == del) {
sList.emplace_back(s);
s = "";
} else {
if (c != ' ' || del == ' ') {
s += c;
}
}
}
sList.emplace_back(s);
return sList;
}
template <class T> struct has_begin {
private:
template <class U>
static auto check(U x) -> decltype(x.begin(), std::true_type{});
static std::false_type check(...);
public:
static bool const value = decltype(check(std::declval<T>()))::value;
};
inline void print(std::list<std::string> &str);
template <
class Primitive, class... Tail,
std::enable_if_t<!has_begin<Primitive>::value, std::nullptr_t> = nullptr>
inline void print(std::list<std::string> &str, const Primitive &x,
const Tail &...tail);
template <class Container, class... Tail>
inline auto print(std::list<std::string> &str, const Container &c,
const Tail &...tail) -> decltype(c.begin());
template <class... Tail>
inline void print(std::list<std::string> &str, const std::string &s,
const Tail &...tail);
template <class Container>
inline auto printSingle(const Container &c) -> decltype(c.begin()) {
for (const auto &x : c) {
std::cout << x << " ";
}
std::cout << "\n";
return c.begin();
}
template <class Primitive, std::enable_if_t<!has_begin<Primitive>::value,
std::nullptr_t> = nullptr>
inline void printSingle(const Primitive &x) {
std::cout << x << " ";
}
inline void print(std::list<std::string> &str) {}
template <
class Primitive, class... Tail,
std::enable_if_t<!has_begin<Primitive>::value, std::nullptr_t> = nullptr>
inline void print(std::list<std::string> &str, const Primitive &x,
const Tail &...tail) {
std::cout << *str.begin() << ":" << x << " ";
if (sizeof...(tail) > 0) {
std::cout << "\n";
str.pop_front();
print(str, tail...);
}
}
template <class Container, class... Tail>
inline auto print(std::list<std::string> &str, const Container &c,
const Tail &...tail) -> decltype(c.begin()) {
std::cout << "-- " << *str.begin() << " --\n";
for (const auto &x : c) {
printSingle(x);
BR;
}
std::cout << "\n";
str.pop_front();
print(str, tail...);
return c.begin();
}
template <class... Tail>
inline void print(std::list<std::string> &str, const std::string &s,
const Tail &...tail) {
std::cout << *str.begin() << ":" << s << "\n";
str.pop_front();
print(str, tail...);
}
//=============================================================================================
signed main() {
ll n;
cin >> n;
unordered_multimap<ll, PAIR> graph;
REP(_, n - 1) {
ll a, b, c;
cin >> a >> b >> c;
--a;
--b;
graph.emplace(a, PAIR(b, c));
graph.emplace(b, PAIR(a, c));
}
VL c(n, -1);
queue<PAIR> q;
q.emplace(0, 0);
c[0] = 0;
while (!q.empty()) {
ll from = q.front().first;
ll dis = q.front().second;
q.pop();
auto range = graph.equal_range(from);
REPI2(itr, range.first, range.second) {
ll to = itr->second.first;
ll d = itr->second.second;
if (c[to] == -1) {
q.emplace(to, dis + d);
c[to] = ((dis + d) % 2);
}
}
}
REPC(x, c) { cout << x << endl; }
} | [
"expression.operation.binary.add"
] | 862,343 | 862,344 | u715750943 | cpp |
p03044 | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
vector<pii> g[100005];
int z[100005];
void dfs(int x, int p) {
for (pii i : g[x])
if (i.first != p) {
if (i.second)
z[i.first] = !z[p];
else
z[i.first] = z[p];
dfs(i.first, x);
}
}
int main() {
ios::sync_with_stdio(false);
int n, u, v, w;
cin >> n;
for (int i = 1; i < n; i++)
cin >> u >> v >> w, w %= 2, g[u].push_back({v, w}), g[v].push_back({u, w});
dfs(1, 1);
for (int i = 1; i <= n; i++)
cout << z[i] << '\n';
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
vector<pii> g[100005];
int z[100005];
void dfs(int x, int p) {
for (pii i : g[x])
if (i.first != p) {
if (i.second)
z[i.first] = !z[x];
else
z[i.first] = z[x];
dfs(i.first, x);
}
}
int main() {
ios::sync_with_stdio(false);
int n, u, v, w;
cin >> n;
for (int i = 1; i < n; i++)
cin >> u >> v >> w, w %= 2, g[u].push_back({v, w}), g[v].push_back({u, w});
dfs(1, 1);
for (int i = 1; i <= n; i++)
cout << z[i] << '\n';
}
| [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 862,364 | 862,365 | u151855078 | cpp |
p03044 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int const INF = 1001001001;
struct edge {
int to, cost;
};
vector<edge> G[100050];
int ans[100050];
void dfs(int v, int p, int color) {
ans[v] = color;
for (auto e : G[v]) {
if (e.to == p)
continue;
if (e.cost % 2)
dfs(e.to, v, 1 - color);
else
dfs(e.to, v, color);
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
rep(i, N - 1) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
G[u].pb({v, w});
G[v].pb({u, w});
}
dfs(0, -1, 0);
rep(i, N - 1) cout << ans[i] << endl;
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int const INF = 1001001001;
struct edge {
int to, cost;
};
vector<edge> G[100050];
int ans[100050];
void dfs(int v, int p, int color) {
ans[v] = color;
for (auto e : G[v]) {
if (e.to == p)
continue;
if (e.cost % 2)
dfs(e.to, v, 1 - color);
else
dfs(e.to, v, color);
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
rep(i, N - 1) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
G[u].pb({v, w});
G[v].pb({u, w});
}
dfs(0, -1, 0);
rep(i, N) cout << ans[i] << endl;
return 0;
} | [
"expression.operation.binary.remove"
] | 862,389 | 862,390 | u115838990 | cpp |
p03044 | /**
* Title:
* Url:
*/
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
int n;
cin >> n;
vector<vector<pair<int, int>>> G(n + 1, vector<pair<int, int>>());
for (int i = 0; i < n - 1; i++) {
int ui, vi, wi;
cin >> ui >> vi >> wi;
G[ui].push_back(make_pair(vi, wi));
G[vi].push_back(make_pair(ui, wi));
}
vector<int> color(n + 1, 0);
queue<pair<int, int>> q;
// to, from
color[1] = 0;
q.push(make_pair(1, 0));
while (!q.empty()) {
pair<int, int> vi = q.front();
q.pop();
for (auto v : G[vi.first]) {
if (v.first == vi.second)
continue;
if (v.second % 2 == 0) {
color[v.first] = color[vi.second];
} else {
color[v.first] = (color[vi.second] + 1) % 2;
}
q.push(make_pair(v.first, vi.first));
}
}
for (int i = 1; i <= n; i++)
cout << color[i] << endl;
return 0;
}
| /**
* Title:
* Url:
*/
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
int n;
cin >> n;
vector<vector<pair<int, int>>> G(n + 1, vector<pair<int, int>>());
for (int i = 0; i < n - 1; i++) {
int ui, vi, wi;
cin >> ui >> vi >> wi;
G[ui].push_back(make_pair(vi, wi));
G[vi].push_back(make_pair(ui, wi));
}
vector<int> color(n + 1, 0);
queue<pair<int, int>> q;
// to, from
color[1] = 0;
q.push(make_pair(1, 0));
while (!q.empty()) {
pair<int, int> vi = q.front();
q.pop();
for (auto v : G[vi.first]) {
if (v.first == vi.second)
continue;
if (v.second % 2 == 0) {
color[v.first] = color[vi.first];
} else {
color[v.first] = (color[vi.first] + 1) % 2;
}
q.push(make_pair(v.first, vi.first));
}
}
for (int i = 1; i <= n; i++)
cout << color[i] << endl;
return 0;
}
| [
"assignment.value.change",
"variable_access.subscript.index.change",
"expression.operation.binary.change"
] | 862,397 | 862,398 | u036744414 | cpp |
p03044 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define repm(i, a, b) for (int i = (int)a; i > (int)b; --i)
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
int n;
vector<vector<pair<int, int>>> vp; //้ทใใจ็ธๆใฎ้ ็น
vector<int> color;
void dfs(int v, int p, int c) {
color[v] = c;
for (auto x : vp[v]) {
if (x.first == p)
continue; //ๆปใใชใใใใซ
if (x.second == 0)
dfs(x.first, v, 0);
else
dfs(x.first, v, 1);
}
}
int main() {
cin >> n;
vp.assign(n, vector<pair<int, int>>()); //็ธฆใฎๅคงใใใ ใๆฑบใใ
color.resize(n, 0);
int u, v, w;
for (int i = 0; i < n - 1; ++i) {
cin >> u >> v >> w;
u--;
v--;
vp[u].push_back(make_pair(v, w % 2));
vp[v].push_back(make_pair(u, w % 2)); //้ฃๆฅใชในใ
}
dfs(0, -1, 0); //็ก็็ข็ๆ นใจๆฑบใใ
for (auto e : color)
cout << e << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define repm(i, a, b) for (int i = (int)a; i > (int)b; --i)
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
int n;
vector<vector<pair<int, int>>> vp; //้ทใใจ็ธๆใฎ้ ็น
vector<int> color;
void dfs(int v, int p, int c) {
color[v] = c;
for (auto x : vp[v]) {
if (x.first == p)
continue; //ๆปใใชใใใใซ
if (x.second == 0)
dfs(x.first, v, c);
else
dfs(x.first, v, 1 - c);
}
}
int main() {
cin >> n;
vp.assign(n, vector<pair<int, int>>()); //็ธฆใฎๅคงใใใ ใๆฑบใใ
color.resize(n, 0);
int u, v, w;
for (int i = 0; i < n - 1; ++i) {
cin >> u >> v >> w;
u--;
v--;
vp[u].push_back(make_pair(v, w % 2));
vp[v].push_back(make_pair(u, w % 2)); //้ฃๆฅใชในใ
}
dfs(0, 0, 0); //็ก็็ข็ๆ นใจๆฑบใใ
for (auto e : color)
cout << e << endl;
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change",
"literal.number.change"
] | 862,406 | 862,407 | u698883164 | cpp |
p03044 | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define repm(i, a, b) for (int i = (int)a; i > (int)b; --i)
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
int n;
vector<vector<pair<int, int>>> vp; //้ทใใจ็ธๆใฎ้ ็น
vector<int> color;
void dfs(int v, int p, int c) {
color[v] = c;
for (auto x : vp[v]) {
if (x.first == p)
continue; //ๆปใใชใใใใซ
if (x.second == 0)
dfs(x.first, v, 0);
else
dfs(x.first, v, 1);
}
}
int main() {
cin >> n;
vp.assign(n, vector<pair<int, int>>()); //็ธฆใฎๅคงใใใ ใๆฑบใใ
color.resize(n, 0);
int u, v, w;
for (int i = 0; i < n - 1; ++i) {
cin >> u >> v >> w;
u--;
v--;
vp[u].push_back(make_pair(v, w % 2));
vp[v].push_back(make_pair(u, w % 2)); //้ฃๆฅใชในใ
}
dfs(0, 0, 0); //็ก็็ข็ๆ นใจๆฑบใใ
for (auto e : color)
cout << e << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define repp(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define repm(i, a, b) for (int i = (int)a; i > (int)b; --i)
using ll = long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;
int n;
vector<vector<pair<int, int>>> vp; //้ทใใจ็ธๆใฎ้ ็น
vector<int> color;
void dfs(int v, int p, int c) {
color[v] = c;
for (auto x : vp[v]) {
if (x.first == p)
continue; //ๆปใใชใใใใซ
if (x.second == 0)
dfs(x.first, v, c);
else
dfs(x.first, v, 1 - c);
}
}
int main() {
cin >> n;
vp.assign(n, vector<pair<int, int>>()); //็ธฆใฎๅคงใใใ ใๆฑบใใ
color.resize(n, 0);
int u, v, w;
for (int i = 0; i < n - 1; ++i) {
cin >> u >> v >> w;
u--;
v--;
vp[u].push_back(make_pair(v, w % 2));
vp[v].push_back(make_pair(u, w % 2)); //้ฃๆฅใชในใ
}
dfs(0, 0, 0); //็ก็็ข็ๆ นใจๆฑบใใ
for (auto e : color)
cout << e << endl;
return 0;
}
| [
"identifier.replace.add",
"literal.replace.remove",
"call.arguments.change"
] | 862,408 | 862,407 | u698883164 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
typedef pair<int, int> P;
vector<int> l(N + 1);
vector<vector<P>> vw(N + 1);
rep(i, N - 1) {
int u, v, w;
cin >> u >> v >> w;
vw[u].push_back(P{v, w});
vw[v].push_back(P{u, w});
}
queue<int> q;
q.push(1);
vector<int> ans(N + 1);
while (!q.empty()) {
int u = q.front();
q.pop();
for (auto p : vw[u]) {
int v = p.first;
int w = p.second;
if (l[v] == 0) {
l[v] = (l[u] + w) % 2 + 2;
ans[v] = l[v] % 2;
q.push(v);
}
}
}
for (int i = 1; i <= N; i++) {
cout << l[i] << "\n";
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
typedef pair<int, int> P;
vector<int> l(N + 1);
vector<vector<P>> vw(N + 1);
rep(i, N - 1) {
int u, v, w;
cin >> u >> v >> w;
vw[u].push_back(P{v, w});
vw[v].push_back(P{u, w});
}
queue<int> q;
q.push(1);
vector<int> ans(N + 1);
while (!q.empty()) {
int u = q.front();
q.pop();
for (auto p : vw[u]) {
int v = p.first;
int w = p.second;
if (l[v] == 0) {
l[v] = (l[u] + w) % 2 + 2;
ans[v] = l[v] % 2;
q.push(v);
}
}
}
for (int i = 1; i <= N; i++) {
cout << ans[i] << "\n";
}
return 0;
}
| [
"identifier.change",
"io.output.change"
] | 862,452 | 862,453 | u821284362 | cpp |
p03044 | #include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge {
lint to;
lint cost;
};
using P = pair<lint, lint>;
using D = pair<long double, long double>;
// const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;
const double Pi = acos(-1.0);
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) { return chmax(b, a); }
lint modpow(lint x, lint n, lint m) {
lint ans = 1;
while (n > 0) {
if (n & 1) {
ans *= x;
if (m <= ans)
ans %= m;
}
x *= x;
if (m <= x)
x %= m;
n >>= 1;
}
return ans;
}
lint fact[1000000];
void f_init(lint n) {
if (1000000 <= n)
return;
fact[0] = fact[1] = 1;
for (lint i = 2; i <= n; ++i) {
fact[i] = i * fact[i - 1];
if (mod <= fact[i])
fact[i] %= mod;
}
return;
}
lint comb(lint n, lint r) {
if (n < r)
return 0;
if (n == r)
return 1;
lint ans = fact[n] * modpow(fact[n - r], mod - 2, mod) % mod *
modpow(fact[r], mod - 2, mod) % mod;
if (ans < 0)
return ans + mod;
return ans;
}
lint nck[1010][1010];
void comb(lint n) {
rep(i, n + 1) {
rep(j, i + 1) {
if (j == 0 || i == j)
nck[i][j] = 1;
else
nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
}
}
}
lint gcd(lint a, lint b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
bool pri(lint p) {
for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2)
if (p % i == 0)
return false;
return p > 1;
}
map<lint, lint> factring(lint n) {
map<lint, lint> ans;
for (lint i = 2; i * i <= n; ++i) {
while (n % i == 0) {
n /= i;
++ans[i];
}
}
if (n != 1)
++ans[n];
return ans;
}
lint xor128() {
static lint x = 123456789, y = 362436069, z = 521288629, w = 88675123;
lint t = (x xor (x << 11));
x = y;
y = z;
z = w;
return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
double dis(D a, D b) {
double x = a.first - b.first, y = a.second - b.second;
return sqrt(x * x + y * y);
}
//ๅคๅฟใๆฑใใ
D circum(D x, D y, D z) {
long double a1, a2, b1, b2, c1, c2;
long double da, db, dc; //่ท้ข
long double a, b, c; // cos
long double o, ox, oy;
a1 = x.first, a2 = x.second, b1 = y.first, b2 = y.second, c1 = z.first,
c2 = z.second;
dc = dis(D(a1, a2), D(b1, b2));
da = dis(D(b1, b2), D(c1, c2));
db = dis(D(c1, c2), D(a1, a2));
a = (db * db + dc * dc - da * da) / (2 * db * dc);
b = (dc * dc + da * da - db * db) / (2 * dc * da);
c = (da * da + db * db - dc * dc) / (2 * da * db);
o = a * da + b * db + c * dc;
ox = (a1 * a * da + b1 * b * db + c1 * c * dc) / o;
oy = (a2 * a * da + b2 * b * db + c2 * c * dc) / o;
return D(ox, oy);
}
class unionfind {
private:
int par[2 * 100010], ranks[2 * 100010], sizeth[2 * 100010];
public:
void init(int n) {
for (int i = 0; i < n; ++i) {
par[i] = i;
ranks[i] = 0;
sizeth[i] = 1;
}
}
int root(int x) {
if (par[x] == x)
return x;
return par[x] = root(par[x]);
}
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (ranks[x] < ranks[y]) {
par[x] = y;
sizeth[y] += sizeth[x];
} else {
par[y] = x;
if (ranks[x] == ranks[y])
++ranks[x];
sizeth[x] += sizeth[y];
}
}
};
lint n;
vector<edge> g[100010];
map<P, lint> mp;
bool used[100010], ans[100010]; //็ฝ:true ้ป:false
int main() {
cin >> n;
rep(i, n - 1) {
lint u, v, w;
cin >> u >> v >> w;
u--;
v--;
g[u].push_back({v, w});
g[v].push_back({u, w});
mp[P(u, v)] = mp[P(v, u)] = v;
}
queue<P> que;
que.push(P(0, 0));
while (!que.empty()) {
P p = que.front();
que.pop();
lint v = p.second;
for (edge e : g[v]) {
lint u = mp[P(v, e.to)];
if (used[u])
continue;
used[u] = true;
que.push(P(p.first + e.cost, e.to));
if ((p.first + e.cost) & 1)
ans[u] = true;
}
}
rep(i, n) { cout << (lint)ans[i] << endl; }
} | #include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge {
lint to;
lint cost;
};
using P = pair<lint, lint>;
using D = pair<long double, long double>;
// const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;
const double Pi = acos(-1.0);
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) { return chmax(b, a); }
lint modpow(lint x, lint n, lint m) {
lint ans = 1;
while (n > 0) {
if (n & 1) {
ans *= x;
if (m <= ans)
ans %= m;
}
x *= x;
if (m <= x)
x %= m;
n >>= 1;
}
return ans;
}
lint fact[1000000];
void f_init(lint n) {
if (1000000 <= n)
return;
fact[0] = fact[1] = 1;
for (lint i = 2; i <= n; ++i) {
fact[i] = i * fact[i - 1];
if (mod <= fact[i])
fact[i] %= mod;
}
return;
}
lint comb(lint n, lint r) {
if (n < r)
return 0;
if (n == r)
return 1;
lint ans = fact[n] * modpow(fact[n - r], mod - 2, mod) % mod *
modpow(fact[r], mod - 2, mod) % mod;
if (ans < 0)
return ans + mod;
return ans;
}
lint nck[1010][1010];
void comb(lint n) {
rep(i, n + 1) {
rep(j, i + 1) {
if (j == 0 || i == j)
nck[i][j] = 1;
else
nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
}
}
}
lint gcd(lint a, lint b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
bool pri(lint p) {
for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2)
if (p % i == 0)
return false;
return p > 1;
}
map<lint, lint> factring(lint n) {
map<lint, lint> ans;
for (lint i = 2; i * i <= n; ++i) {
while (n % i == 0) {
n /= i;
++ans[i];
}
}
if (n != 1)
++ans[n];
return ans;
}
lint xor128() {
static lint x = 123456789, y = 362436069, z = 521288629, w = 88675123;
lint t = (x xor (x << 11));
x = y;
y = z;
z = w;
return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
double dis(D a, D b) {
double x = a.first - b.first, y = a.second - b.second;
return sqrt(x * x + y * y);
}
//ๅคๅฟใๆฑใใ
D circum(D x, D y, D z) {
long double a1, a2, b1, b2, c1, c2;
long double da, db, dc; //่ท้ข
long double a, b, c; // cos
long double o, ox, oy;
a1 = x.first, a2 = x.second, b1 = y.first, b2 = y.second, c1 = z.first,
c2 = z.second;
dc = dis(D(a1, a2), D(b1, b2));
da = dis(D(b1, b2), D(c1, c2));
db = dis(D(c1, c2), D(a1, a2));
a = (db * db + dc * dc - da * da) / (2 * db * dc);
b = (dc * dc + da * da - db * db) / (2 * dc * da);
c = (da * da + db * db - dc * dc) / (2 * da * db);
o = a * da + b * db + c * dc;
ox = (a1 * a * da + b1 * b * db + c1 * c * dc) / o;
oy = (a2 * a * da + b2 * b * db + c2 * c * dc) / o;
return D(ox, oy);
}
class unionfind {
private:
int par[2 * 100010], ranks[2 * 100010], sizeth[2 * 100010];
public:
void init(int n) {
for (int i = 0; i < n; ++i) {
par[i] = i;
ranks[i] = 0;
sizeth[i] = 1;
}
}
int root(int x) {
if (par[x] == x)
return x;
return par[x] = root(par[x]);
}
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (ranks[x] < ranks[y]) {
par[x] = y;
sizeth[y] += sizeth[x];
} else {
par[y] = x;
if (ranks[x] == ranks[y])
++ranks[x];
sizeth[x] += sizeth[y];
}
}
};
lint n;
vector<edge> g[100010];
map<P, lint> mp;
bool used[100010], ans[100010]; //็ฝ:true ้ป:false
int main() {
cin >> n;
rep(i, n - 1) {
lint u, v, w;
cin >> u >> v >> w;
u--;
v--;
g[u].push_back({v, w});
g[v].push_back({u, w});
mp[P(u, v)] = v;
mp[P(v, u)] = u;
}
queue<P> que;
que.push(P(0, 0));
while (!que.empty()) {
P p = que.front();
que.pop();
lint v = p.second;
for (edge e : g[v]) {
lint u = mp[P(v, e.to)];
if (used[u])
continue;
used[u] = true;
que.push(P(p.first + e.cost, e.to));
if ((p.first + e.cost) & 1)
ans[u] = true;
}
}
rep(i, n) { cout << (lint)ans[i] << endl; }
} | [
"assignment.add",
"assignment.value.change",
"identifier.change"
] | 862,455 | 862,456 | u054475353 | cpp |
p03044 | #include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge {
lint to;
lint cost;
};
using P = pair<lint, lint>;
using D = pair<long double, long double>;
// const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;
const double Pi = acos(-1.0);
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) { return chmax(b, a); }
lint modpow(lint x, lint n, lint m) {
lint ans = 1;
while (n > 0) {
if (n & 1) {
ans *= x;
if (m <= ans)
ans %= m;
}
x *= x;
if (m <= x)
x %= m;
n >>= 1;
}
return ans;
}
lint fact[1000000];
void f_init(lint n) {
if (1000000 <= n)
return;
fact[0] = fact[1] = 1;
for (lint i = 2; i <= n; ++i) {
fact[i] = i * fact[i - 1];
if (mod <= fact[i])
fact[i] %= mod;
}
return;
}
lint comb(lint n, lint r) {
if (n < r)
return 0;
if (n == r)
return 1;
lint ans = fact[n] * modpow(fact[n - r], mod - 2, mod) % mod *
modpow(fact[r], mod - 2, mod) % mod;
if (ans < 0)
return ans + mod;
return ans;
}
lint nck[1010][1010];
void comb(lint n) {
rep(i, n + 1) {
rep(j, i + 1) {
if (j == 0 || i == j)
nck[i][j] = 1;
else
nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
}
}
}
lint gcd(lint a, lint b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
bool pri(lint p) {
for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2)
if (p % i == 0)
return false;
return p > 1;
}
map<lint, lint> factring(lint n) {
map<lint, lint> ans;
for (lint i = 2; i * i <= n; ++i) {
while (n % i == 0) {
n /= i;
++ans[i];
}
}
if (n != 1)
++ans[n];
return ans;
}
lint xor128() {
static lint x = 123456789, y = 362436069, z = 521288629, w = 88675123;
lint t = (x xor (x << 11));
x = y;
y = z;
z = w;
return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
double dis(D a, D b) {
double x = a.first - b.first, y = a.second - b.second;
return sqrt(x * x + y * y);
}
//ๅคๅฟใๆฑใใ
D circum(D x, D y, D z) {
long double a1, a2, b1, b2, c1, c2;
long double da, db, dc; //่ท้ข
long double a, b, c; // cos
long double o, ox, oy;
a1 = x.first, a2 = x.second, b1 = y.first, b2 = y.second, c1 = z.first,
c2 = z.second;
dc = dis(D(a1, a2), D(b1, b2));
da = dis(D(b1, b2), D(c1, c2));
db = dis(D(c1, c2), D(a1, a2));
a = (db * db + dc * dc - da * da) / (2 * db * dc);
b = (dc * dc + da * da - db * db) / (2 * dc * da);
c = (da * da + db * db - dc * dc) / (2 * da * db);
o = a * da + b * db + c * dc;
ox = (a1 * a * da + b1 * b * db + c1 * c * dc) / o;
oy = (a2 * a * da + b2 * b * db + c2 * c * dc) / o;
return D(ox, oy);
}
class unionfind {
private:
int par[2 * 100010], ranks[2 * 100010], sizeth[2 * 100010];
public:
void init(int n) {
for (int i = 0; i < n; ++i) {
par[i] = i;
ranks[i] = 0;
sizeth[i] = 1;
}
}
int root(int x) {
if (par[x] == x)
return x;
return par[x] = root(par[x]);
}
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (ranks[x] < ranks[y]) {
par[x] = y;
sizeth[y] += sizeth[x];
} else {
par[y] = x;
if (ranks[x] == ranks[y])
++ranks[x];
sizeth[x] += sizeth[y];
}
}
};
lint n;
vector<edge> g[100010];
map<P, lint> mp;
bool used[100010], ans[100010]; //็ฝ:true ้ป:false
int main() {
cin >> n;
rep(i, n - 1) {
lint u, v, w;
cin >> u >> v >> w;
u--;
v--;
g[u].push_back({v, w});
g[v].push_back({u, w});
mp[P(u, v)] = mp[P(v, u)] = i + 1;
}
queue<P> que;
que.push(P(0, 0));
while (!que.empty()) {
P p = que.front();
que.pop();
lint v = p.second;
for (edge e : g[v]) {
lint u = mp[P(v, e.to)];
if (used[u])
continue;
used[u] = true;
que.push(P(p.first + e.cost, e.to));
if ((p.first + e.cost) & 1)
ans[u] = true;
}
}
rep(i, n) { cout << (lint)ans[i] << endl; }
} | #include "bits/stdc++.h"
using namespace std;
using lint = long long;
#define low lower_bound
#define upp upper_bound
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define Rep(i, n) for (int i = int(n); i >= 0; --i)
#define all(vec) (vec).begin(), (vec).end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>
struct edge {
lint to;
lint cost;
};
using P = pair<lint, lint>;
using D = pair<long double, long double>;
// const lint mod = 998244353LL;
const lint mod = 1000000007LL;
const lint inf = 3LL * mod * mod;
const double Pi = acos(-1.0);
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmin(T &a, T b) { return chmax(b, a); }
lint modpow(lint x, lint n, lint m) {
lint ans = 1;
while (n > 0) {
if (n & 1) {
ans *= x;
if (m <= ans)
ans %= m;
}
x *= x;
if (m <= x)
x %= m;
n >>= 1;
}
return ans;
}
lint fact[1000000];
void f_init(lint n) {
if (1000000 <= n)
return;
fact[0] = fact[1] = 1;
for (lint i = 2; i <= n; ++i) {
fact[i] = i * fact[i - 1];
if (mod <= fact[i])
fact[i] %= mod;
}
return;
}
lint comb(lint n, lint r) {
if (n < r)
return 0;
if (n == r)
return 1;
lint ans = fact[n] * modpow(fact[n - r], mod - 2, mod) % mod *
modpow(fact[r], mod - 2, mod) % mod;
if (ans < 0)
return ans + mod;
return ans;
}
lint nck[1010][1010];
void comb(lint n) {
rep(i, n + 1) {
rep(j, i + 1) {
if (j == 0 || i == j)
nck[i][j] = 1;
else
nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
}
}
}
lint gcd(lint a, lint b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
lint lcm(lint a, lint b) { return a / gcd(a, b) * b; }
bool pri(lint p) {
for (lint i = 2; i * i <= p; i == 2 ? ++i : i += 2)
if (p % i == 0)
return false;
return p > 1;
}
map<lint, lint> factring(lint n) {
map<lint, lint> ans;
for (lint i = 2; i * i <= n; ++i) {
while (n % i == 0) {
n /= i;
++ans[i];
}
}
if (n != 1)
++ans[n];
return ans;
}
lint xor128() {
static lint x = 123456789, y = 362436069, z = 521288629, w = 88675123;
lint t = (x xor (x << 11));
x = y;
y = z;
z = w;
return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
double dis(D a, D b) {
double x = a.first - b.first, y = a.second - b.second;
return sqrt(x * x + y * y);
}
//ๅคๅฟใๆฑใใ
D circum(D x, D y, D z) {
long double a1, a2, b1, b2, c1, c2;
long double da, db, dc; //่ท้ข
long double a, b, c; // cos
long double o, ox, oy;
a1 = x.first, a2 = x.second, b1 = y.first, b2 = y.second, c1 = z.first,
c2 = z.second;
dc = dis(D(a1, a2), D(b1, b2));
da = dis(D(b1, b2), D(c1, c2));
db = dis(D(c1, c2), D(a1, a2));
a = (db * db + dc * dc - da * da) / (2 * db * dc);
b = (dc * dc + da * da - db * db) / (2 * dc * da);
c = (da * da + db * db - dc * dc) / (2 * da * db);
o = a * da + b * db + c * dc;
ox = (a1 * a * da + b1 * b * db + c1 * c * dc) / o;
oy = (a2 * a * da + b2 * b * db + c2 * c * dc) / o;
return D(ox, oy);
}
class unionfind {
private:
int par[2 * 100010], ranks[2 * 100010], sizeth[2 * 100010];
public:
void init(int n) {
for (int i = 0; i < n; ++i) {
par[i] = i;
ranks[i] = 0;
sizeth[i] = 1;
}
}
int root(int x) {
if (par[x] == x)
return x;
return par[x] = root(par[x]);
}
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (ranks[x] < ranks[y]) {
par[x] = y;
sizeth[y] += sizeth[x];
} else {
par[y] = x;
if (ranks[x] == ranks[y])
++ranks[x];
sizeth[x] += sizeth[y];
}
}
};
lint n;
vector<edge> g[100010];
map<P, lint> mp;
bool used[100010], ans[100010]; //็ฝ:true ้ป:false
int main() {
cin >> n;
rep(i, n - 1) {
lint u, v, w;
cin >> u >> v >> w;
u--;
v--;
g[u].push_back({v, w});
g[v].push_back({u, w});
mp[P(u, v)] = v;
mp[P(v, u)] = u;
}
queue<P> que;
que.push(P(0, 0));
while (!que.empty()) {
P p = que.front();
que.pop();
lint v = p.second;
for (edge e : g[v]) {
lint u = mp[P(v, e.to)];
if (used[u])
continue;
used[u] = true;
que.push(P(p.first + e.cost, e.to));
if ((p.first + e.cost) & 1)
ans[u] = true;
}
}
rep(i, n) { cout << (lint)ans[i] << endl; }
} | [
"assignment.add",
"assignment.value.change",
"expression.operation.binary.change",
"expression.operation.binary.remove"
] | 862,457 | 862,456 | u054475353 | cpp |
p03044 | // confilm 0LL and 1LL
// confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for (ll(i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for (ll(i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for (ll(i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const ll INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
vector<VecP> tree;
Vec ans;
void dfs(const ll n, const ll p) {
for (P i : tree[n]) {
if (i.fs == p)
continue;
if (i.sc % 2)
ans[i.fs] = !ans[p];
else
ans[i.fs] = ans[p];
dfs(i.fs, n);
}
}
int main(void) {
ll n;
cin >> n;
tree.resize(n + 1);
ans.resize(n + 1);
ll u, v, w;
rep(i, n - 1) {
cin >> u >> v >> w;
tree[u].pb({v, w});
tree[v].pb({u, w});
}
ans[1] = 0;
dfs(1, 1);
repn(i, n) co(ans[i]);
return 0;
}
| // confilm 0LL and 1LL
// confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for (ll(i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for (ll(i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for (ll(i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T> bool chmax(T &a, const T &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <typename T> bool chmin(T &a, const T &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
const ll INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
vector<VecP> tree;
Vec ans;
void dfs(const ll n, const ll p) {
for (P i : tree[n]) {
if (i.fs == p)
continue;
if (i.sc % 2)
ans[i.fs] = !ans[n];
else
ans[i.fs] = ans[n];
dfs(i.fs, n);
}
}
int main(void) {
ll n;
cin >> n;
tree.resize(n + 1);
ans.resize(n + 1);
ll u, v, w;
rep(i, n - 1) {
cin >> u >> v >> w;
tree[u].pb({v, w});
tree[v].pb({u, w});
}
ans[1] = 0;
dfs(1, 1);
repn(i, n) co(ans[i]);
return 0;
}
| [
"assignment.value.change",
"identifier.change",
"variable_access.subscript.index.change"
] | 862,460 | 862,461 | u997368585 | cpp |
p03044 | #include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> tree;
vector<int> col;
void dfs(int current, int c) {
col.at(current) = c;
for (pair<int, int> e : tree.at(current)) {
int to = e.first;
if (col.at(to) != -1)
continue;
int dist = e.second;
if (dist % 2 == 0) {
dfs(to, c);
} else {
dfs(to, 1 - c);
}
}
}
int main() {
int N;
cin >> N;
tree.resize(N);
col.resize(N, -1);
for (int i = 0; i < N; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
tree.at(u).push_back(make_pair(v, w));
tree.at(v).push_back(make_pair(u, w));
}
dfs(0, 0);
for (int i = 0; i < N; i++) {
cout << col.at(i) << endl;
}
return 0;
} | #include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> tree;
vector<int> col;
void dfs(int current, int c) {
col.at(current) = c;
for (pair<int, int> e : tree.at(current)) {
int to = e.first;
if (col.at(to) != -1)
continue;
int dist = e.second;
if (dist % 2 == 0) {
dfs(to, c);
} else {
dfs(to, 1 - c);
}
}
}
int main() {
int N;
cin >> N;
tree.resize(N);
col.resize(N, -1);
for (int i = 0; i < N - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
tree.at(u).push_back(make_pair(v, w));
tree.at(v).push_back(make_pair(u, w));
}
dfs(0, 0);
for (int i = 0; i < N; i++) {
cout << col.at(i) << endl;
}
return 0;
} | [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 862,471 | 862,472 | u048904090 | cpp |
p03044 | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX = 100005;
//้ ็น็ชๅทใจ่ท้ขใ่จ้ฒใใใ.
/*
ๆน้
rootใใ่ฆใฆใใใ่ฆชใจใฎ่ท้ขใๅถๆฐใชใๅใ่ฒใ้ใใชใ้ใ่ฒใๅกใใฐ
ใใใใใใใใงไปปๆใฎ็ตใฟๅใใใซใคใใฆๆกไปถใ้ๆใใใใ...?
ฮป้ขๆฐใงdfsใๅฎ่ฃ
ใใใฎใฏ็็ฑใใใใใชใใใฉ็ก็ใใใใชใฎใงๅค้จใซ.
*/
vector<P> ale[MAX];
int n;
vector<int> color(MAX, -1);
void dfs(int v, bool clr = 0, int p = -1) {
color[v] = clr;
for (P u : ale[v]) {
if (u.first == p)
continue;
if (u.second % 2 == 0) {
dfs(u.first, clr, v);
} else {
dfs(u.first, !clr, v);
}
}
}
int main() {
cin >> n;
rep(i, n) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
ale[u].push_back(make_pair(v, w));
ale[v].push_back(make_pair(u, w));
}
dfs(0);
rep(i, n) { cout << color[i] << endl; }
return 0;
} | #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX = 100005;
//้ ็น็ชๅทใจ่ท้ขใ่จ้ฒใใใ.
/*
ๆน้
rootใใ่ฆใฆใใใ่ฆชใจใฎ่ท้ขใๅถๆฐใชใๅใ่ฒใ้ใใชใ้ใ่ฒใๅกใใฐ
ใใใใใใใใงไปปๆใฎ็ตใฟๅใใใซใคใใฆๆกไปถใ้ๆใใใใ...?
ฮป้ขๆฐใงdfsใๅฎ่ฃ
ใใใฎใฏ็็ฑใใใใใชใใใฉ็ก็ใใใใชใฎใงๅค้จใซ.
*/
vector<P> ale[MAX];
int n;
vector<int> color(MAX, -1);
void dfs(int v, bool clr = 0, int p = -1) {
color[v] = clr;
for (P u : ale[v]) {
if (u.first == p)
continue;
if (u.second % 2 == 0) {
dfs(u.first, clr, v);
} else {
dfs(u.first, !clr, v);
}
}
}
int main() {
cin >> n;
rep(i, n - 1) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
ale[u].push_back(make_pair(v, w));
ale[v].push_back(make_pair(u, w));
}
dfs(0);
rep(i, n) { cout << color[i] << endl; }
return 0;
} | [
"expression.operation.binary.add"
] | 862,475 | 862,476 | u480887263 | cpp |
p03044 | #include <iostream>
#include <vector>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
Graph G;
vector<int> d; // d[i]ๆ นใใ้ ็นiใพใงใฎ่ท้ข
void Dfs(int v, int parent) {
for (auto e : G[v]) {
if (e.first == parent)
continue; // ้ๆตใ้ฒใ(ๆข็ดขใฎ่๏ผ)
d[e.first] = d[v] + e.second;
Dfs(e.first, v);
}
}
int main() {
int N;
cin >> N;
int u, v, w;
G.assign(N, vector<Edge>());
for (int i = 0; i < N - 1; ++i) {
cin >> u >> v >> w;
--u;
--v;
G[u].push_back(Edge(v, w));
G[v].push_back(Edge(u, w));
}
d.assign(N, 0);
Dfs(0, -1);
for (auto ans : d)
cout << (ans % 2) << endl; // ๅคๅ้ใใชใ
return 0;
};
| #include <iostream>
#include <vector>
using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
Graph G;
vector<int> d; // d[i]ๆ นใใ้ ็นiใพใงใฎ่ท้ข
void Dfs(int v, int parent) {
for (auto e : G[v]) {
if (e.first == parent)
continue; // ้ๆตใ้ฒใ(ๆข็ดขใฎ่๏ผ)
d[e.first] = d[v] + e.second;
Dfs(e.first, v);
}
}
int main() {
int N;
cin >> N;
int u, v, w;
G.assign(N, vector<Edge>());
for (int i = 0; i < N - 1; ++i) {
cin >> u >> v >> w;
--u;
--v;
G[u].push_back(Edge(v, w));
G[v].push_back(Edge(u, w));
}
d.assign(N, 0);
Dfs(0, -1);
for (auto ans : d)
cout << (ans & 1) << endl;
return 0;
};
| [] | 862,487 | 862,488 | u774438048 | cpp |
p03044 | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define MAX_N 100000
int N;
pair<vector<int>, vector<long int>> G[MAX_N];
vector<int> d(MAX_N);
vector<int> color(MAX_N);
void input() {
cin >> N;
REP(i, N - 1) {
int s, t, u;
cin >> s >> t >> u;
s--;
t--;
G[s].first.push_back(t);
G[t].first.push_back(s);
G[s].second.push_back(u);
G[t].second.push_back(u);
}
}
void dfs(int V, int iro) {
color[V] = iro;
REP(i, G[V].first.size()) {
if (color[G[V].first[i]] >= 0)
continue;
else {
d[G[V].first[i]] = d[V] + G[V].second[i];
if (G[V].first[i] % 2)
dfs(G[V].first[i], 0);
else
dfs(G[V].first[i], 1);
}
}
}
void solve() {
input();
fill(color.begin(), color.end(), -1);
dfs(0, 0);
REP(i, N)
cout << color[i] << endl;
}
int main() {
solve();
return 0;
}
| #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define MAX_N 100000
int N;
pair<vector<int>, vector<long int>> G[MAX_N];
vector<int> d(MAX_N);
vector<int> color(MAX_N);
void input() {
cin >> N;
REP(i, N - 1) {
int s, t, u;
cin >> s >> t >> u;
s--;
t--;
G[s].first.push_back(t);
G[t].first.push_back(s);
G[s].second.push_back(u);
G[t].second.push_back(u);
}
}
void dfs(int V, int iro) {
color[V] = iro;
REP(i, G[V].first.size()) {
if (color[G[V].first[i]] >= 0)
continue;
else {
d[G[V].first[i]] = d[V] + G[V].second[i];
if (d[G[V].first[i]] % 2)
dfs(G[V].first[i], 1);
else
dfs(G[V].first[i], 0);
}
}
}
void solve() {
input();
fill(color.begin(), color.end(), -1);
dfs(0, 0);
REP(i, N)
cout << color[i] << endl;
}
int main() {
solve();
return 0;
}
| [
"control_flow.branch.if.condition.change",
"literal.number.change",
"call.arguments.change"
] | 862,496 | 862,497 | u754909749 | cpp |
p03044 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
vector<pair<int, int>> edg[100003];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
edg[u].push_back({v, w});
edg[v].push_back({u, w});
}
vector<int> ans(n + 2, -1);
deque<int> que;
ans[0] = 0;
que.push_back(0);
while (!que.empty()) {
int pos = que.front();
que.pop_front();
for (auto p : edg[pos]) {
if (ans[p.first] != -1)
continue;
if (p.second & 1)
ans[p.first] = 1 - ans[pos];
else
ans[p.first] = ans[pos];
que.push_back(p.first);
}
}
for (int i = 0; i < n; i++)
cout << ans[i] << endl;
return 0;
} |
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
vector<pair<int, int>> edg[100003];
int main() {
int n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
u--;
v--;
edg[u].push_back({v, w});
edg[v].push_back({u, w});
}
vector<int> ans(n + 2, -1);
deque<int> que;
ans[0] = 0;
que.push_back(0);
while (!que.empty()) {
int pos = que.front();
que.pop_front();
for (auto p : edg[pos]) {
if (ans[p.first] != -1)
continue;
if (p.second & 1)
ans[p.first] = 1 - ans[pos];
else
ans[p.first] = ans[pos];
que.push_back(p.first);
}
}
for (int i = 0; i < n; i++)
cout << ans[i] << endl;
return 0;
} | [
"control_flow.loop.for.condition.change",
"misc.off_by_one"
] | 862,504 | 862,505 | u843522325 | cpp |
p03043 | #include <bits/stdc++.h>
#define mov(i, a, b) for (int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9 + 5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n) { return (ceil(log2(n)) == floor(log2(n))); }
long long binpow(long long a, long long b) {
long long res = 1;
while (b > 0) {
if (b & 1)
res *= a;
a = a * a;
b >>= 1;
}
return res;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
bool x = false;
if ((a.second * a.first) < b.second * b.first) {
x = true;
}
return x;
}
int main() {
ll n, k;
cin >> n >> k;
double ans = 0.0;
for (int i = 1; i <= n; i++) {
double inter = 0.0;
inter += (1.0 / (double)(n));
int t = i;
while (t < k) {
inter *= (double)(0.5);
t = t * 2;
}
ans += inter;
}
printf("%.6f", ans);
}
| #include <bits/stdc++.h>
#define mov(i, a, b) for (int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9 + 5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n) { return (ceil(log2(n)) == floor(log2(n))); }
long long binpow(long long a, long long b) {
long long res = 1;
while (b > 0) {
if (b & 1)
res *= a;
a = a * a;
b >>= 1;
}
return res;
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
bool x = false;
if ((a.second * a.first) < b.second * b.first) {
x = true;
}
return x;
}
int main() {
ll n, k;
cin >> n >> k;
double ans = 0.0;
for (int i = 1; i <= n; i++) {
double inter = 0.0;
inter = (1.0 / (double)(n));
int t = i;
while (t < k) {
inter *= (double)(0.5);
t = t * 2;
;
}
ans += inter;
}
printf("%.12f", ans);
}
| [
"assignment.value.change",
"literal.string.change",
"call.arguments.change",
"io.output.change"
] | 862,506 | 862,507 | u527398664 | cpp |
p03043 | #include "bits/stdc++.h"
using namespace std;
int main() {
double N, K;
cin >> N >> K;
double answer = 0;
for (int i = 1; i <= N; i++) {
if (i > K) {
answer += 1;
continue;
}
int n;
n = ceil(log(K / i) / log(2));
answer += pow(0.5, n);
}
answer /= N;
cout << answer << endl;
return 0;
} | #include "bits/stdc++.h"
using namespace std;
int main() {
double N, K;
cin >> N >> K;
double answer = 0;
for (int i = 1; i <= N; i++) {
if (i > K) {
answer += 1;
continue;
}
int n;
n = ceil(log(K / i) / log(2));
answer += pow(0.5, n);
}
answer /= N;
cout << setprecision(10) << answer << endl;
return 0;
}
| [
"io.output.change"
] | 862,513 | 862,512 | u436976004 | cpp |
p03043 | #include "bits/stdc++.h"
using namespace std;
int main() {
double N, K;
cin >> N >> K;
double answer = 0;
for (int i = 1; i <= N; i++) {
if (i > K) {
answer += 1;
continue;
}
int n;
n = ceil(log(K / i) / log(2));
answer += pow(0.5, n);
}
answer /= N;
cout << answer << endl;
return 0;
} | #include "bits/stdc++.h"
using namespace std;
int main() {
double N, K;
cin >> N >> K;
double answer = 0;
for (int i = 1; i <= N; i++) {
if (i > K) {
answer += 1;
continue;
}
int n;
n = ceil(log(K / i) / log(2));
answer += pow(0.5, n);
}
answer /= N;
cout << setprecision(10) << answer << endl;
return 0;
} | [
"io.output.change"
] | 862,513 | 862,514 | u436976004 | cpp |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.