import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdio; int gaussianElimination(ref int[][] org_mat) { int N = org_mat.length.to!int; auto mat = new int[][](N, N+1); foreach (i; 0..N) foreach (j; 0..N+1) mat[i][j] = org_mat[i][j]; foreach (i; 0..N) { int maxval = 0; int maxrow = -1; foreach (j; i..N) if (abs(mat[j][i]) > maxval) maxval = abs(mat[j][i]), maxrow = j; if (maxval == 0) return 0; swap(mat[i], mat[maxrow]); foreach (j; 0..N) { if (j == i) continue; int mul = mat[j][i]; foreach (k; i..N+1) mat[j][k] ^= mul*mat[i][k]; } } return 1; } void main() { auto N = readln.chomp.to!int; auto D = readln.split.map!(to!int).array; auto W = readln.split.map!(to!int).array; auto mat = new int[][](N, N+1); foreach (i; 0..N) { mat[i][(i+D[i])%N] = 1; mat[i][((i-D[i])%N+N)%N] = 1; mat[i][N] = 1; } //mat.writeln; writeln( gaussianElimination(mat) ? "Yes" : "No"); }