int main() { double x1, x2, y1, y2,dis; scanf("%lf %lf", &x1, &y1); scanf("%lf %lf", &x2, &y2); dis = get_sq(x1, y1, x2, y2); printf("%.4lf\n", sqrt(dis)); return 0; }
int set_pos(struct Position* pos, char* fen) { u32 piece, pt, sq, pc, tsq = 0, index = 0; char c; pos->state->pos_key = 0ULL; pos->state->pawn_key = 0ULL; for (sq = 0; sq < 64; ++sq) castle_perms[sq] = 15; while (tsq < 64) { sq = tsq ^ 56; c = fen[index++]; if (c == ' ') { break; } else if (c > '0' && c < '9') { tsq += (c - '0'); } else if (c == '/') { continue; } else { piece = get_piece_from_char(c); pt = piece & 7; pc = piece >> 3; put_piece(pos, sq, pt, pc); if (pt == KING) { pos->king_sq[pc] = sq; castle_perms[sq] = pc == WHITE ? 12 : 3; } else if (pt == ROOK && !is_frc) { if (sq == H1 || sq == H8) { castling_rook_pos[pc][KINGSIDE] = sq; castle_perms[sq] = pc == WHITE ? 14 : 11; } else if (sq == A1 || sq == A8) { castling_rook_pos[pc][QUEENSIDE] = sq; castle_perms[sq] = pc == WHITE ? 13 : 7; } } ++tsq; } } ++index; pos->stm = fen[index] == 'w' ? WHITE : BLACK; index += 2; int file, rank, color; while ((c = fen[index++]) != ' ') { if (c == '-') { ++index; break; } else if (!is_frc) { pos->state->castling_rights |= get_cr_from_char(c); } else { if (c >= 'a' && c <= 'z') { color = BLACK; rank = RANK_8; file = c - 'a'; } else if (c >= 'A' && c <= 'Z') { color = WHITE; rank = RANK_1; file = c - 'A'; } u32 cr = get_cr_from_char(c); if (cr != -1) { u64 r_bb = pos->bb[ROOK] & pos->bb[color]; int ksq = pos->king_sq[color]; int kside_sq, qside_sq = 0; while (r_bb) { kside_sq = bitscan(r_bb); r_bb &= r_bb - 1; if (is_queenside(ksq, kside_sq)) qside_sq = kside_sq; if (qside_sq && kside_sq != qside_sq) break; } if (cr & (WKC | BKC)) { castling_rook_pos[color][KINGSIDE] = kside_sq; castle_perms[kside_sq] = color == WHITE ? 14 : 11; pos->state->castling_rights |= color == WHITE ? WKC : BKC; } else if (cr & (WQC | BQC)) { castling_rook_pos[color][QUEENSIDE] = qside_sq; castle_perms[qside_sq] = color == WHITE ? 13 : 7; pos->state->castling_rights |= color == WHITE ? WQC : BQC; } } else { sq = get_sq(rank, file); if (is_kingside(pos->king_sq[color], sq)) { castling_rook_pos[color][KINGSIDE] = sq; castle_perms[sq] = color == WHITE ? 14 : 11; pos->state->castling_rights |= color == WHITE ? WKC : BKC; } else if (is_queenside(pos->king_sq[color], sq)) { castling_rook_pos[color][QUEENSIDE] = sq; castle_perms[sq] = color == WHITE ? 13 : 7; pos->state->castling_rights |= color == WHITE ? WQC : BQC; } } } } pos->state->pos_key ^= castle_keys[pos->state->castling_rights]; u32 ep_sq = 0; if ((c = fen[index++]) != '-') { ep_sq = (c - 'a') + ((fen[index++] - '1') << 3); pos->state->pos_key ^= psq_keys[0][0][ep_sq]; pos->state->ep_sq_bb = BB(ep_sq); } ++index; u32 x = 0; while ((c = fen[index++]) != '\n' && c != ' ' && c != '\0') x = x * 10 + (c - '0'); pos->state->fifty_moves = x; x = 0; while ((c = fen[index++]) != '\n' && c != ' ' && c != '\0') x = x * 10 + (c - '0'); pos->state->full_moves = x; return index; }