int exfat_find_used_sectors(const struct exfat* ef, off_t* a, off_t* b) { cluster_t ca, cb; if (*a == 0 && *b == 0) ca = cb = EXFAT_FIRST_DATA_CLUSTER - 1; else { ca = s2c(ef, *a); cb = s2c(ef, *b); } if (find_used_clusters(ef, &ca, &cb) != 0) return 1; if (*a != 0 || *b != 0) *a = c2s(ef, ca); *b = c2s(ef, cb) + (CLUSTER_SIZE(*ef->sb) - 1) / SECTOR_SIZE(*ef->sb); return 0; }
void show_step(){ int cs = ST; CHESS ct; s2c(cs, ct); int steps[dp[ST]-1]; int oo = 100; while(cs != SS && oo > 0){ oo --; for (int d = 0; d < 4; d++) { CHESS tt; get_nt(ct, d, tt); int ts = c2s(tt); if (dp[ts] == dp[cs] - 1){ // printf("%x to %x with direction: %c\n", cs, c2s(tt), DIR_NAME[d]); // print_chess(tt); steps[ dp[cs] -2 ] = REVERSE_DIR[d]; // printf("%d\n", dp[cs]); cs = c2s(tt); s2c(cs, ct); } } } cs = SS; for (int i = 0; i < dp[ST]-1; ++i) { s2c(cs, ct); int d = steps[i]; CHESS tt; get_nt(ct, d, tt); cs = c2s(tt); // printf("move: %c\n", DIR_NAME[d]); // print_chess(tt); printf("%c", DIR_NAME[d]); } printf("\n"); }
void solve(){ // memset(dp, INF, sizeof(dp)); std::deque<int> a; SS = c2s(S); ST = c2s(T); printf("SS = %x\n", SS); printf("ST = %x\n", ST); a.push_back(SS); printf("a.size = %d\n", (int)a.size()); dp[SS] = 1; int oo = 20000; CHESS ct, nt; int cs, ns; do { // oo --; cs = a.front(); a.pop_front(); s2c(cs, ct); if (fp[cs]) continue; fp[cs] = true; if (cs == ST) break; // print_chess(ct); // printf("step of %x: %d\n", cs, dp[cs]); for (int d=0; d<4; d++) { if (! get_nt(ct, d, nt) ) continue; int ns = c2s(nt); // print_chess(nt); if (dp[ns] == 0 or dp[cs]+1 < dp[ns]){ dp[ns] = dp[cs]+1; }; // printf("ns = %x, fp[ns]= %d\n", ns, fp[ns]); if (! fp[ns]) a.push_back(ns); }; // printf("a.size = %d\n", static_cast<int>(a.size())); } while ( oo > 0 && a.size() > 0 ); printf("oo = %d\n", oo); printf("a.size = %d\n", static_cast<int>(a.size())); printf("dp.size = %d\n", static_cast<int>(dp.size())); printf("step: %d\n", dp[cs]-1); print_chess(ct); printf("\n\n"); show_step(); }
/* ---------------------------------------------------------------------------- * Reads a child node's value, and uses it to set a variable. * Will not do anything if the child's value is empty. * child: Name of the child node. * var: The var to set. This is an Allegro color. */ void reader_setter::set(const string &child, ALLEGRO_COLOR &var) { string s = node->get_child_by_name(child)->value; if(s.empty()) return; var = s2c(s); }