int search(struct node *h, int i, struct node *solution[]) { if (h->right == h) return 1; struct node *c; struct node *tmp7; int min = 9999; for(tmp7 = h->right; tmp7 != h; tmp7 = tmp7->right) if (tmp7->s < min) { c = tmp7; min = tmp7->s; } cover(c); struct node *r, *tmp; for (r = c->down; r != c; r = r->down) { solution[i] = r; for (tmp = r->right; tmp != r; tmp = tmp->right) { cover(tmp->ch); } if (search(h, i+1, solution) == 1) return 1; struct node *tmp4; for (tmp4 = r->left; tmp4 != r; tmp4 = tmp4->left) { uncover(tmp4->ch); } } uncover(c); return -1; }
int search(int k) { struct node_t* r; struct node_t* j; int max = 0x7fffffff; int c; if(root.right == &root) return 1; for(j = root.right;j != &root; j = j->right) { if(max > size[j->c]) { max = size[j->c]; c = j->c; } } cover(c); for(r = col[c].down;r != &col[c]; r = r->down) { for(j = r->right;j != r; j = j->right) cover(j->c); if(search(k + 1)) return 1; for(j = r->left;j != r; j = j->left) uncover(j->c); } uncover(c); return 0; }
TreeNode* lowestCommonAncestor(TreeNode* root, TreeNode* p, TreeNode* q) { if (cover(root->left, p) && cover(root->left, q)) { return lowestCommonAncestor(root->left, p, q); } if (cover(root->right, p) && cover(root->right, q)) { return lowestCommonAncestor(root->right, p, q); } return root; }
bool cover(TreeNode *root, TreeNode *node) { if (root == NULL) { return false; } if (root == node) { return true; } return cover(root->left, node) || cover(root->right, node); }
int visible(int i, double mx) { int k; if (!cover(i, mx)) return 0; //先判断该建筑物是否有一部分在这个区间中 for (k = 0; k < n; k++) //判断是否被遮挡 { if (b[k].y < b[i].y && b[k].h >= b[i].h && cover(k, mx)) return 0; } return 1; }
// // Create new root page (root splitting) // oid_t dbRtreePage::allocate(dbDatabase* db, oid_t oldRootId, oid_t newPageId) { oid_t pageId = db->allocateObject(dbRtreePageMarker); dbRtreePage* pg = (dbRtreePage*)db->put(pageId); pg->n = 2; cover(db, oldRootId, pg->b[0].rect); pg->b[0].p = oldRootId; cover(db, newPageId, pg->b[1].rect); pg->b[1].p = newPageId; return pageId; }
// Main part of the algorithm: takes an initial list of candidates, pick any two // elements, combine them. Process recursively while remembering the best // combination so far. As soon as a combination has been solved, deconstruct it // and build the next one. static int cover(Tree ** arbres, int taille){ int i, j, k, resultat; int p1, p2; resultat = -1; for(i = 0; i < taille; ++i){ for(j = 0; j < i; ++j){ for(k = 0; k < 3; ++k){ compare_with_closest(arbres[i]); compare_with_closest(arbres[j]); prepare(arbres, i, j, &taille, operators[k]); compare_with_closest(arbres[j]); resultat = closest->result; if(resultat == N) break; cover(arbres, taille); backtrack(arbres, i, j, &taille); } if(arbres[i] && arbres[j]){ p1=arbres[i]->result; p2=arbres[j]->result; } if(resultat != N && p1 && p2 && !(p1 % p2 && p2 % p1)){ compare_with_closest(arbres[i]); compare_with_closest(arbres[j]); prepare(arbres, i, j, &taille, operators[3]); compare_with_closest(arbres[j]); resultat = closest->result; if(resultat == N) break; cover(arbres, taille); backtrack(arbres, i, j, &taille); } compare_with_closest(arbres[i]); compare_with_closest(arbres[j]); resultat = closest->result; if(resultat == N) break; } compare_with_closest(arbres[i]); resultat = closest->result; if(resultat == N) break; } return resultat; }
IC bool CCoverManager::critical_point (CLevelGraph::CVertex *v, u32 index, u32 index0, u32 index1) { return ( !ai().level_graph().valid_vertex_id(v->link(index)) && ( !ai().level_graph().valid_vertex_id(v->link(index0)) || !ai().level_graph().valid_vertex_id(v->link(index1)) || cover(v,index0,index) || cover(v,index1,index) ) ); }
void cover(int i, int l, int r, int val) { if ( node[i].l > r || node[i].r < l ) return; if ( l <= node[i].l && node[i].r <= r ) { mark(i, val); return; } push_down(i); cover(i * 2, l, r, val); cover(i * 2 + 1, l, r, val); update(i); }
// compute all SUS of position p in O(k) time, where k is the number of such SUSs. std::vector<std::pair<size_t,size_t> > OSUS::query(size_t p){ std::vector<std::pair<size_t,size_t> > sus; size_t i = S[p], l; sus.push_back(std::make_pair(std::min(muInts[i].first, p), std::max(muInts[i].second,p))); l = cover(muInts[i], p); i++; while(i < muInts.size() && (cover(muInts[i], p) <= l)){ sus.push_back(std::make_pair(std::min(muInts[i].first, p), std::max(muInts[i].second,p))); i++; } return sus; }
int cover() { //아직 채우지 못한 칸 중 가장 윗줄 왼쪽에 있는 칸을 찾는다. int y = -1, x = -1; for(int i=0; i<saero; i++) { for(int j=0; j<garo; j++) { if(board[i][j] == 0) { y = i; x= j; break; } } if(y!= -1) break; } //종료 조건 : 모든 칸을 채웠으면 1을 반환한다. if(y == -1) return 1; int ret = 0; for(int type = 0; type < 4; type++) { //만약 board[y][x]를 type형태로 덮을 수 있으면 재귀 호출한다. if(set(y, x, type, 1) ) ret += cover(); //덮었던 블록을 치운다. set(y, x, type, -1); } return ret; }
int main(void) { int i, j; scanf("%d", &N); //input N;; while(N--) { scanf("%d %d", &saero, &garo); //input saero and garo for(i=0; i<saero; i++) { scanf("%s", &temp); //input string;; for(j=0; j<garo; j++) { if(temp[j] == '#') board[i][j] = 1; else board[i][j] = 0; } } //input result = cover(); printf("%d\n", result); for(i=0; i<saero; i++) { for(j=0; j<garo; j++) { board[i][j] = 0; } } } //while return 0; }
ExperimentResult Experiment::RunNonMLExperiment(Steganalyzer* steganalyzer, Embedder* embedder, const std::vector<std::string>& inputFiles, bool verbose) { int dimension = inputFiles.size(); ExperimentResult result(dimension, embedder->get_embedding_rate()); for (int fileIdx = 0; fileIdx < dimension; ++fileIdx) { Image cover(inputFiles[fileIdx]); double coverResult = steganalyzer->Steganalyze(cover); result.set_result(fileIdx, inputFiles[fileIdx], 0.0, coverResult); Image stego = embedder->Embed(cover); double stegoResult = steganalyzer->Steganalyze(stego); result.set_result(fileIdx, inputFiles[fileIdx], embedder->get_embedding_rate(), stegoResult); } return result; }
void HealthCentre::update() { ++daycount; if (commodityCount[STUFF_JOBS] >= HEALTH_CENTRE_JOBS && commodityCount[STUFF_GOODS] >= HEALTH_CENTRE_GOODS && commodityCount[STUFF_WASTE] + (HEALTH_CENTRE_GOODS / 3) <= MAX_WASTE_AT_HEALTH_CENTRE) { commodityCount[STUFF_JOBS] -= HEALTH_CENTRE_JOBS; commodityCount[STUFF_GOODS] -= HEALTH_CENTRE_GOODS; commodityCount[STUFF_WASTE] += (HEALTH_CENTRE_GOODS / 3); ++covercount; ++working_days; } //monthly update if (total_time % 100 == 0) { busy = working_days; working_days = 0; } //TODO implement animation once graphics exist /* That's all. Cover is done by different functions every 3 months or so. */ health_cost += HEALTH_RUNNING_COST; if(refresh_cover) { cover();} }
/** * Cover all columns of nodes in the same row as i, except the column of i * itself. * * The inverse function is uncover_other_columns, which ensures that * matrix links are restored in the correct order. */ static void cover_other_columns(struct dlx_node *i) { struct dlx_node *j = i; while ((j = j->right) != i) /* for each column except i */ cover((struct dlx_node *) j->header); }
int main() { int testCase; freopen("input.txt", "r", stdin); scanf("%d", &testCase); while (testCase--) { int x, y, i, j; char temp = 0; memset(board, 0, sizeof(int) * MAX_SIZE * MAX_SIZE); scanf("%d %d", &x, &y); for (i = 0; i < x; ++i) { for (j = 0; j < y; ++j) { scanf("%c", &temp); if (temp == '#') board[i][j] = 1; else if (temp == '.') board[i][j] = 0; } } cover(board, x, y); } }
void O2JamChart::load_art () { if (ojn_header.newCoverArtSize == 0) return; clan::File file; if (file.open(ojn_path, clan::File::OpenMode::open_existing, clan::File::AccessFlags::access_read ) == false) return; file.seek(ojn_header.DataOffset[3], clan::File::seek_set); uint8_t* buffer = new uint8_t[ojn_header.newCoverArtSize]; int read = file.read(buffer, ojn_header.newCoverArtSize); if (read == static_cast<int>(ojn_header.newCoverArtSize)) { try { clan::DataBuffer dbuff ( buffer, read ); clan::IODevice_Memory memio ( dbuff ); clan::PixelBuffer cover ( memio, "jpg", false ); this->setCoverArt(cover); this->cover_loaded = true; } catch (clan::Exception &e) { clan::Console::write_line("Failed to load .jpg cover art for %1.", ojn_header.Title); clan::Console::write_line(e.get_message_and_stack_trace()); } } delete[] buffer; }
int cover(int board[MAX_SIZE][MAX_SIZE], int row, int col) { int y = -1, x = -1; int i, j, type; for (i = 0; i < col; ++i) { for (j = 0; j < row; ++j) { if (board[i][j] == 0) { y = i; x = j; break; } if (y != -1) break; } } if (y == -1) return 1; int ret = 0; for (type = 0; type < 4; ++type) { if (set(board, row, col, type, 1)) ret += cover(board, row, col); set(board, row, col, type, -1); } return ret; }
QVariant AlbumCoversAssetService::getAsset(DataItem *item, QString service) { if (!item->getMediaCollection()) return QVariant(); if(item && item->getType() == DataItem::ALBUM && service == "DisplayRole") { QString path = item->getMediaCollection()->getAssetFolderPath("AlbumCoversPreview").toString()+"/"+QString::number(item->getID()) + ".jpg"; QImage cover(path); if (cover.isNull()) { if(noCoverCover) return noCoverCover->pixmap(43,43); cover = QImage(":/border_images/Ressources/no_cover.png").scaled(43, 43, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); } return cover; } if(item && item->getType() == DataItem::ALBUM && service == "CoverURL") { QString path = item->getMediaCollection()->getAssetFolderPath("AlbumCoversHires").toString()+"/"+QString::number(item->getID()) + ".jpg"; if(QFile::exists(path)) return path; else return ""; } return QVariant(); }
void Cricket::update() { ++daycount; if (commodityCount[STUFF_JOBS] >= CRICKET_JOBS && commodityCount[STUFF_GOODS] >= CRICKET_GOODS && commodityCount[STUFF_WASTE] + (CRICKET_GOODS / 3) <= MAX_WASTE_AT_CRICKET) { commodityCount[STUFF_JOBS] -= CRICKET_JOBS; commodityCount[STUFF_GOODS] -= CRICKET_GOODS; commodityCount[STUFF_WASTE] += (CRICKET_GOODS / 3); ++covercount; ++working_days; } //monthly update if (total_time % 100 == 0) { busy = working_days; working_days = 0; } //animate if (animate && real_time > anim) { anim = real_time + CRICKET_ANIMATION_SPEED; if(++(frameIt->frame) >= (int)frameIt->resourceGroup->graphicsInfoVector.size()) { frameIt->frame = 0; animate = false; } } /* That's all. Cover is done by different functions every 3 months or so. */ cricket_cost += CRICKET_RUNNING_COST; if(refresh_cover) { cover();} }
void coverpage() { glClear(GL_COLOR_BUFFER_BIT); glPointSize(2.0); cover(); glFlush(); }
static int search(struct dlx *solver, int k) { /* if (k == 21) */ /* return 1; */ int solutions = 0; /* printf("k = %d\n", k); */ struct node *r, *j; if (solver->h.next == &solver->h) { printsoln(solver, k); return 1; } struct column *c = choosecol(solver); if (c->len == 0) { printf("X\n"); uncover(solver, c); return 0; } /* printf("CHOOSE %s\n", c->name); */ int xx = cover(solver, c); if (xx) { printf("Got a zero\n"); return 0; } for (r = c->node.d; r != &c->node; r = r->d) { solver->solnodes[k] = r; for (j = r->r; j != r; j = j->r) { cover(solver, j->c); } int rc = search(solver, k+1); solutions += search(solver, k+1); if (k == 0) { printf("Solutions increased by %d to %d\n", rc, solutions); } for (j = r->l; j != r; j = j->l) { uncover(solver, j->c); } if (solutions >= 1) break; } uncover(solver, c); return solutions; }
bool ExactCoverSolver::solve () { int cols_count; Node<int>* next_col = NULL; Node<int>* next_row_in_col = NULL; Node<int>* row_node = NULL; if (empty ()) { return true; } next_col = pick_next_col (cols_count); if (cols_count < 1) { return false; } total_competition_ += cols_count; next_row_in_col = next_col->bottom_; cover (next_col); while (next_row_in_col != next_col && !solved_) { running_sol_.push (next_row_in_col); row_node = next_row_in_col->right_; while (row_node != next_row_in_col) { cover (row_node->col_header_); row_node = row_node->right_; } solved_= solve (); if (!solved_) { running_sol_.pop (); } row_node = next_row_in_col->right_; while (row_node != next_row_in_col) { uncover (row_node->col_header_); row_node = row_node->right_; } next_row_in_col = next_row_in_col->bottom_; } uncover (next_col); return solved_; }
void New(){ scanf("%d", &X); if(getAns(1).m >= X){ getRange(1, N, 1); printf("New at %d\n", l); cover(1, N, 1); }else puts("Reject New"); }
void Matrix::solve ( quint32 k ) { if ( m_header->right == m_header ) { ++m_solutions; ( *m_solution ) ( m_output, k ); return; } HeaderNode* column = 0; quint32 s = 0xFFFFFFFF; for ( HeaderNode* i = m_header->right->column; i != m_header; i = i->right->column ) { if ( i->size < s ) { column = i; s = i->size; } } cover ( column ); quint32 next_k = k + 1; for ( Node* row = column->down; row != column; row = row->down ) { m_output[k] = row; for ( Node* j = row->right; j != row; j = j->right ) { cover ( j->column ); } solve ( next_k ); if ( m_solutions >= m_max_solutions ) { return; } row = m_output[k]; column = row->column; for ( Node* j = row->left; j != row ; j = j->left ) { uncover ( j->column ); } } uncover ( column ); }
void CollectionScanner::scanFiles( const QStringList& entries ) { DEBUG_BLOCK typedef QPair<QString, QString> CoverBundle; QStringList validImages; validImages << "jpg" << "png" << "gif" << "jpeg"; QStringList validPlaylists; validPlaylists << "m3u" << "pls"; QValueList<CoverBundle> covers; QStringList images; foreachType( QStringList, entries ) { const QString path = *it; const QString ext = extension( path ); const QString dir = directory( path ); // Write path to logfile if( !m_logfile.isEmpty() ) { QFile log( m_logfile ); if( log.open( IO_WriteOnly ) ) log.writeBlock( path.local8Bit(), path.length() ); } if( validImages.contains( ext ) ) images += path; else if( m_importPlaylists && validPlaylists.contains( ext ) ) { AttributeMap attributes; attributes["path"] = path; writeElement( "playlist", attributes ); } else { MetaBundle::EmbeddedImageList images; MetaBundle mb( KURL::fromPathOrURL( path ), true, TagLib::AudioProperties::Fast, &images ); const AttributeMap attributes = readTags( mb ); if( !attributes.empty() ) { writeElement( "tags", attributes ); CoverBundle cover( attributes["artist"], attributes["album"] ); if( !covers.contains( cover ) ) covers += cover; foreachType( MetaBundle::EmbeddedImageList, images ) { AttributeMap attributes; attributes["path"] = path; attributes["hash"] = (*it).hash(); attributes["description"] = (*it).description(); writeElement( "embed", attributes ); } } }
TitleWidget::TitleWidget(QWidget *p) : QWidget(p) , controls(0) { QGridLayout *layout=new QGridLayout(this); QVBoxLayout *textLayout=new QVBoxLayout(0); image=new QLabel(this); mainText=new SqueezedTextLabel(this); subText=new SqueezedTextLabel(this); QLabel *chevron=new QLabel(QChar(Qt::RightToLeft==layoutDirection() ? 0x203A : 0x2039), this); QFont f=mainText->font(); subText->setFont(Utils::smallFont(f)); f.setBold(true); mainText->setFont(f); if (f.pixelSize()>0) { f.setPixelSize(f.pixelSize()*2); } else { f.setPointSizeF(f.pointSizeF()*2); } f.setBold(false); chevron->setFont(f); int spacing=Utils::layoutSpacing(this); mainText->ensurePolished(); subText->ensurePolished(); int size=mainText->sizeHint().height()+subText->sizeHint().height()+spacing; if (size<72) { size=Icon::stdSize(size); } size=Utils::scaleForDpi(qMax(size, 48)); image->setFixedSize(size, size); setToolTip(i18n("Click to go back")); spacing=qMin(4, spacing-1); layout->addItem(new QSpacerItem(spacing, spacing), 0, 0, 2, 1); layout->addWidget(chevron, 0, 1, 2, 1); layout->addWidget(image, 0, 2, 2, 1); textLayout->addWidget(mainText); textLayout->addWidget(subText); layout->addItem(textLayout, 0, 3, 2, 1); mainText->installEventFilter(this); subText->installEventFilter(this); image->installEventFilter(this); installEventFilter(this); setAttribute(Qt::WA_Hover); connect(Covers::self(), SIGNAL(cover(Song,QImage,QString)), this, SLOT(coverRetrieved(Song,QImage,QString))); connect(Covers::self(), SIGNAL(coverUpdated(Song,QImage,QString)), this, SLOT(coverRetrieved(Song,QImage,QString))); connect(Covers::self(), SIGNAL(artistImage(Song,QImage,QString)), this, SLOT(coverRetrieved(Song,QImage,QString))); layout->setContentsMargins(1, 4, 1, 4); layout->setSpacing(spacing); textLayout->setMargin(0); textLayout->setSpacing(spacing); mainText->setAlignment(Qt::AlignBottom); subText->setAlignment(Qt::AlignTop); image->setAlignment(Qt::AlignCenter); chevron->setAlignment(Qt::AlignCenter); chevron->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding); }
int dlx_force_row(struct dlx_node *r) { if (is_removed_ud(r)) return -1; cover((struct dlx_node *) r->header); cover_other_columns(r); return 0; }
void Free(){ scanf("%d", &X); getBlock(1, N, 1); if(l + r <= 0) puts("Reject Free"); else{ cover(1, N, 1); printf("Free from %d to %d\n", l, r); } }
OSUS::OSUS(const std::string & s){ size_t N = s.size(), i, j; lcp = new size_t[N]; rank = new size_t[N]; Create_LCP_RANK(s, lcp, rank); // this->muInts: an array holding the meaningful MUIs from left to right. // this->S: an array of Length N that holds the index in MUI which gives SUS(i) S.resize(N); for(i = 0; i < N; i++){ // 1. check if there is a MUI starting at position i // if so, set its length to minimalLength (minmalLength = 0 if there is none) size_t minimalLength = getMUI(i, rank, lcp, N); // 2. determine the left most MUI which starts before i, and is a member of SUS(i) // this should be the same MUI as at position i-1, or the next MUI in muInts if(i == 0) S[0] = 0; else if((S[i-1] + 1 >= muInts.size()) || cover(muInts[S[i-1]],i) <= cover(muInts[S[i-1]+1],i)) S[i] = S[i-1]; else S[i] = S[i-1] + 1; // 3. if there exists a MUI starting at position i, we update previous positions // and muInts if needed. if(minimalLength > 0){ std::pair<size_t,size_t> newMUI(i, i + minimalLength - 1); // the new MUI if(muInts.size() > 0){ // find the rightmost position 0 < j <= i that doesn't need to be updated // (S[0] can never be updated, so we don't need an exit condition) for(j = i; ; j--) if(cover(muInts[S[j]],j) <= cover(newMUI,j)){ break; } if(j == i){ // if updates aren't needed, MUIs after S[i] and are longer are meaningless; // remove them (from the back) while(muInts.back() != muInts[S[i]]){ if(cover(muInts.back(),i) <= cover(newMUI, i)) break; muInts.pop_back(); } } else { // if updates are needed, the MUIs after the ones that give SUS(j) are meaningless; // remove them (from the back) size_t lastmui = S[j]; while(muInts.back() != muInts[S[j]]){ if(cover(muInts.back(), j) <= cover(muInts[lastmui],j)) break; muInts.pop_back(); } for(j++; j <= i; j++) S[j] = muInts.size(); // update to newest MUI } } muInts.push_back(newMUI); } } }