char e[3][N]; int n; bool st[N]; int q[N], path[N];
boolcheck(){ for(int i = n - 1, t = 0; ~i; i --) { int a = e[0][i] - 'A', b = e[1][i] - 'A', c = e[2][i] - 'A';
if(path[a] != -1 && path[b] != -1 && path[c] != -1) { a = path[a], b = path[b], c = path[c]; if(t != -1) { if((a + b + t) % n != c) returnfalse; if(!i && (a + b + t) >= n) returnfalse; t = (a + b + t) / n; } else { //如果进位不确定,那么进位不是0就是1 if((a + b) % n != c && (a + b + 1) % n != c) returnfalse; if(!i && a + b >= n) returnfalse; } } else t = -1; } returntrue; }