bool compareu(VString string, VString stringt){ if (string.sz!=stringt.sz) return 0; unsigned char* to=string.data+stringt.sz; while(string.data<to){ if (upd(*string.data)!=upd(*stringt.data)) return 0; // asm++ string.data++; stringt.data++; } return 1; }
void solve() { scanf("%d", &n); vvi closest; closest.assign(n, vi(4, -1)); forn(i, n) { a[i].read(); } for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { int u = i, v = j; if (a[u].x == a[v].x) { if (a[u].y > a[v].y) swap(u, v); upd(u, closest[u][to_dir('v')], v); upd(v, closest[v][to_dir('^')], u); } else if (a[u].y == a[v].y) { if (a[u].x > a[v].x) swap(u, v); upd(u, closest[u][to_dir('>')], v); upd(v, closest[v][to_dir('<')], u); } } } int ans = doit(closest, 0); for (int i = 1; i < n; ++i) { ans = max(ans, doit(closest, i)); } cout << ans << endl; }
enum update_type genhash_fun_update(genhash_t* h, const void* k, void *(*upd)(const void *, const void *), void (*fr)(void*), const void *def) { struct genhash_entry_t *p; enum update_type rv=0; p=genhash_find_entry(h, k); if(p) { void *newValue=upd(k, p->value); void *k2=h->ops.dupKey(k); h->ops.freeKey(p->key); p->key=k2; void *v2=h->ops.dupValue(newValue); h->ops.freeValue(p->value); p->value=v2; fr(newValue); rv=MODIFICATION; } else { void *newValue=upd(k, def); genhash_store(h, k, newValue); fr(newValue); rv=NEW; } return rv; }
enum update_type genhash_fun_update(genhash_t* h, const void* k, size_t klen, void *(*upd)(const void *, const void *, size_t *, void *), void (*fr)(void*), void *arg, const void *def, size_t deflen) { struct genhash_entry_t *p; enum update_type rv=0; size_t newSize = 0; (void)deflen; p=genhash_find_entry(h, k, klen); if(p) { void *newValue=upd(k, p->value, &newSize, arg); free_value(h, p->value); p->value=dup_value(h, newValue, newSize); fr(newValue); rv=MODIFICATION; } else { void *newValue=upd(k, def, &newSize, arg); genhash_store(h, k, klen, newValue, newSize); fr(newValue); rv=NEW; } return rv; }
int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) upd(i, 1), a[i] = 1; for (int i = 0; i < m; i++) { int l, r, c; scanf("%d", &c); if (c == -1) { scanf("%d", &l); l--; if (a[l]) { a[l]--; upd(l, -1); } } if (c == 1) { scanf("%d", &l); l--; if (!a[l]) { a[l]++; upd(l, 1); } } if (!c) { scanf("%d%d", &l, &r); l--, r--; printf("%s\n", sum(r) - sum(l - 1) == r - l + 1 ? "PASSED" : "PENALTY"); } } return 0; }
void upd(int nd,int l,int r,int k,unsigned long long int v) { int mid=(l+r)/2; if(l==r) {str[nd]=v; if(v==0) ver[nd]=true; return;} else if(k<=mid) upd(nd*2,l,mid,k,v); else upd((nd*2)+1,mid+1,r,k,v); if(v==0) {ver[nd]=true; str[nd]=0;} else {if(str[nd]<v&&ver[nd]==false) str[nd]=v;} }
inline void rot(nd *&n,bool b) { nd *c=n->ch[b]; n->ch[b]=c->ch[!b]; c->ch[!b]=n; upd(n); upd(c); n=c; }
void query(int idx, int b, int e, int &x1, int &x2){ interval *i = d + idx; if(b > i->r || e < i->l) return; if(ok(i->f, b, e)) upd(i->f, x1, x2); if(ok(i->s, b, e)) upd(i->s, x1, x2); if(b <= i->l && i->r <= e) return; query(LEFT(idx), b, e, x1, x2); query(RIGHT(idx), b, e, x1, x2); }
bool VString::morecompareu(const VString& string)const{ int size= sz>string.sz ? string.sz : sz; for (int i=0; i<size; i++){ if (upd(data[i])>upd(string.data[i])) return 1; else if(data[i]<string.data[i]) return 0; } return sz>string.sz ? 1 : 0; }
int main(int argc, char *argv[]) { setIO("sample"); n = gi; for(int i = 1;i<=n;a[i]=gi,w[i]=a[i],++i); sort(w+1,w+n+1); cnt = unique(w+1,w+n+1)-w-1; for(int i = 1;i<=n;a[i]=lower_bound(w+1,w+cnt+1,a[i])-w,++i); q = gi; int len = (int)(sqrt(n)+0.5); for(int i = 1;i<=q;++i){ ask[i].l = gi,ask[i].r= gi; ask[i].lp = (ask[i].l-1)/len+1; ask[i].pos = i; } sort(ask+1,ask+q+1); int pl = 1,pr = 0; for(int i = 1;i<=q;++i){ if(pr < ask[i].r){ for(++pr;pr <= ask[i].r;++pr){ ans += sum(cnt+1-a[pr]); upd(cnt+1-a[pr]+1,1); upd2(a[pr]+1,1); } --pr; }else if(pr > ask[i].r){ for(;pr>ask[i].r;--pr){ ans -= sum(cnt+1-a[pr]); upd(cnt+1-a[pr]+1,-1); upd2(a[pr]+1,-1); } } if(pl < ask[i].l){ for(;pl < ask[i].l;++pl){ ans -=sum2(a[pl]); upd(cnt+1-a[pl]+1,-1); upd2(a[pl]+1,-1);} } else if(pl > ask[i].l){ for(--pl;pl >= ask[i].l;--pl){ ans += sum2(a[pl]); upd(cnt+1-a[pl]+1,1); upd2(a[pl]+1,1); } ++ pl; } key[ask[i].pos] = ans; } for(int i = 1;i<=q;++i) printf("%d\n",key[i]); closeIO(); return EXIT_SUCCESS; }
void Printer::move(float x, float y, float z, float e, float f) { GCode gc; #define upd(v) if(!isnan(v)) { this->v = v; } upd(x); upd(y); upd(z); upd(e); upd(f); #undef upd gc.setMove(x, y, z, e, f); addCommand(gc); }
int rtmsu(unsigned char *to, unsigned char *fr, unsigned int frs, unsigned char *&line){ //read to symbol up if(!line || !fr || !frs) return 0; unsigned char *lfr, *tfr, *ln; to-=frs-1; for(line; line<to; line++){ if(upd(*line)==upd(*fr)){ lfr=fr+1; tfr=fr+frs; ln=line+1; for(lfr; lfr<tfr; lfr++){ if(upd(*ln++)!=upd(*lfr)){ break; } } if(lfr==tfr){ return 1; } } } line=to+(frs-1); return 0; }
Droot Node::split (int k){ if (!sz) return Droot (null, null); if (k <= ch[0]->sz){ Droot ret = ch[0]->split (k); ch[0] = ret.second; ret.second = upd (); return ret; } else{ Droot ret = ch[1]->split (k - ch[0]->sz - 1); ch[1] = ret.first; ret.first = upd (); return ret; } }
void update(int idx, int p){ interval *i = d + idx; assert(i->l <= i->r); if(p < i->l || p > i->r) return; upd(p, i->f, i->s); if(i->l < i->r){ int left = LEFT(idx), right = RIGHT(idx); update(LEFT(idx), p), update(RIGHT(idx), p); upd(d[left].f, i->f, i->s); upd(d[left].s, i->f, i->s); upd(d[right].f, i->f, i->s); upd(d[right].s, i->f, i->s); } }
void init(int idx, int b, int e){ interval *i = d + idx; int m = (b + e) >> 1; i->l = b; i->r = e; assert(i->l <= i->r); i->f = i->s = 0; if(b < e){ int left = LEFT(idx), right = RIGHT(idx); init(left, b, m); init(right, m + 1, e); upd(d[left].f, i->f, i->s); upd(d[left].s, i->f, i->s); upd(d[right].f, i->f, i->s); upd(d[right].s, i->f, i->s); } else i->f = b; }
void gmaster_state::gmaster(machine_config &config) { upd7810_device &upd(UPD7810(config, m_maincpu, 12_MHz_XTAL/2/*?*/)); // µPD78C11 in the unit upd.set_addrmap(AS_PROGRAM, &gmaster_state::gmaster_mem); upd.pa_in_cb().set_ioport("JOY"); upd.pb_in_cb().set(FUNC(gmaster_state::gmaster_portb_r)); upd.pc_in_cb().set(FUNC(gmaster_state::gmaster_portc_r)); upd.pd_in_cb().set(FUNC(gmaster_state::gmaster_portd_r)); upd.pf_in_cb().set(FUNC(gmaster_state::gmaster_portf_r)); upd.pa_out_cb().set(FUNC(gmaster_state::gmaster_porta_w)); upd.pb_out_cb().set(FUNC(gmaster_state::gmaster_portb_w)); upd.pc_out_cb().set(FUNC(gmaster_state::gmaster_portc_w)); upd.pd_out_cb().set(FUNC(gmaster_state::gmaster_portd_w)); upd.pf_out_cb().set(FUNC(gmaster_state::gmaster_portf_w)); screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); screen.set_refresh_hz(60); screen.set_size(64, 64); screen.set_visarea(0, 64-1-3, 0, 64-1); screen.set_screen_update(FUNC(gmaster_state::screen_update_gmaster)); screen.set_palette("palette"); PALETTE(config, "palette", FUNC(gmaster_state::gmaster_palette), ARRAY_LENGTH(gmaster_pens)); SPEAKER(config, "mono").front_center(); SPEAKER_SOUND(config, m_speaker).add_route(0, "mono", 0.50); GENERIC_CARTSLOT(config, m_cart, generic_linear_slot, "gmaster_cart").set_must_be_loaded(true); SOFTWARE_LIST(config, "cart_list").set_original("gmaster"); }
void SpectDisplay::OnDraw(wxDC& dc) {//================================ wxRegion region; dc.SetUserScale(zoomx,zoomy); int f1 = 0x7fffffff, f2 = -1; int x1,x2,y1,y2; int vX,vY,vW,vH; // Dimensions of client area in pixels wxRegionIterator upd(GetUpdateRegion()); // get the update rect list while (upd) { vX = upd.GetX(); vY = upd.GetY(); vW = upd.GetW(); vH = upd.GetH(); CalcUnscrolledPosition(vX,vY,&x1,&y1); CalcUnscrolledPosition(vX+vW,vY+vH,&x2,&y2); // Repaint this rectangle if(y1 < f1) f1 = int(y1/zoomy); if(y2 > f2) f2 = int(y2/zoomy); upd ++ ; } if(spectseq != NULL) spectseq->Draw(dc,f1,f2); }
// Called when canvas needs to be repainted. void OnPaint(void) { // Speeds up drawing under Windows. GetDC()->BeginDrawing(); wxCanvasDC *canvdc = GetDC(); #if 0 // Find Out where the window is scrolled to int vbX,vbY; // Top left corner of client ViewStart(&vbX,&vbY); int vX,vY,vW,vH; // Dimensions of client area in pixels wxUpdateIterator upd(this); // get the update rect list while (upd) { vX = upd.GetX(); vY = upd.GetY(); vW = upd.GetW(); vH = upd.GetH(); // Alternatively we can do this: // wxRectangle rect; // upd.GetRect(&rect); upd ++ ; } #endif IntDrawLine(xStart.Value(),yStart.Value(),xEnd.Value(),yEnd.Value()); GetDC()->EndDrawing(); }
void VNCCanvas::onPaint(wxPaintEvent &WXUNUSED(event)) { // this happens on GTK even if our size is (0,0) if(GetSize().GetWidth() == 0 || GetSize().GetHeight() == 0) return; wxPaintDC dc(this); // get the update rect list wxRegionIterator upd(GetUpdateRegion()); while(upd) { wxRect update_rect(upd.GetRect()); wxLogDebug(wxT("VNCCanvas %p: got repaint event: (%i,%i,%i,%i)"), this, update_rect.x, update_rect.y, update_rect.width, update_rect.height); const wxBitmap& region = conn->getFrameBufferRegion(update_rect); if(region.IsOk()) dc.DrawBitmap(region, update_rect.x, update_rect.y); ++upd; } }
void HTMLButcherViewEditDialog::Save(ButcherProjectView *view) { ButcherProjectBaseAutoUpdate upd(view); view->SetName(viewname_); view->SetLayoutType(layouttype_); view->SetFileId(fileid_); view->SetMaskId(maskid_); //view->SetMaskConfigId(maskconfigid_); view->SetItems(items_); view->SetImageFilePathId(imagefilepathid_); view->SetCSSFileId(cssfileid_); for (int i=0; i<BUTCHERCONST_VIEW_MAXALTERNATE; i++) view->SetFileAlternateId(i, filealternateid_[i]); view->SetFilename(filename_); view->SetBodyTagAdd(bodytagadd_); view->SetTableTagAdd(tabletagadd_); view->SetTitle(title_); view->SetHead(head_); view->SetBodyPrepend(bodyprepend_); view->SetBodyAppend(bodyappend_); view->SetEncoding(encoding_); view->AssortedFileGroups().Set(assortedfilegroups_.Get()); view->SetBGRepeat(bgrepeat_); view->SetIsBGColor(isbgcolor_); view->SetIsStretch(isstretch_); view->SetStyleSeparated(styleseparated_); view->SetBGColor(bgcolor_); view->BGImage().SetBURL(bgimage_.GetBURL()); }
TimelineTable::TimelineTable( QWidget* parent ) : QWidget( parent ) , _ui( new Ui::TimelineTable ) , _defautIcon( QIcon( "img/none.jpg" ) ) { _ui->setupUi( this ); _table = new Table( this ); _table->setIconSize( QSize( 100, 100 ) ); _table->horizontalHeader()->setDefaultSectionSize( 100 ); _table->verticalHeader()->setDefaultSectionSize( _table->iconSize().height() ); //add the table on the widget QVBoxLayout *layout = new QVBoxLayout( _ui->widgetContentTable ); layout->addWidget( _table ); //connect timelineUi updater to the timeline signalChanged TimeLineUiUpdater upd( *this ); getTimeline().getSignalChanged().connect( upd ); updateTable(); connect( this->_table, SIGNAL( cellClicked( int, int ) ), this, SLOT( getCurrentTime( int, int ) ) ); connect( this->_table, SIGNAL( currentCellChanged( int, int, int, int ) ), this, SLOT( getCurrentTime( int, int ) ) ); connect( _ui->spinFps, SIGNAL( valueChanged( int ) ), this, SLOT( changeFps( int ) ) ); }
void ProsodyDisplay::OnDraw(wxDC& dc) {//================================ int x1,y1; int vX,vY,vW,vH; // Dimensions of client area in pixels int line, start, end; GetClientSize(&x1, &y1); if(x1 != linewidth) { LayoutData(NULL, 0); } wxRegionIterator upd(GetUpdateRegion()); // get the update rect list while (upd) { vX = upd.GetX(); vY = upd.GetY(); vW = upd.GetW(); vH = upd.GetH(); CalcUnscrolledPosition(vX,vY,&x1,&y1); // Repaint this rectangle, find which lines to redraw start = y1/FRAMEHEIGHT; end = (y1+vH)/FRAMEHEIGHT; for(line=start; line<=end && line<num_lines; line++) DrawPitchline(dc,line,x1,x1+vW); upd ++ ; } } // end of ProsodyDisplay::OnDraw
void wxWindowX11::SendEraseEvents() { if (m_clearRegion.IsEmpty()) return; wxClientDC dc( (wxWindow*)this ); dc.SetClippingRegion( m_clearRegion ); wxEraseEvent erase_event( GetId(), &dc ); erase_event.SetEventObject( this ); if (!GetEventHandler()->ProcessEvent(erase_event) ) { Display *xdisplay = wxGlobalDisplay(); Window xwindow = (Window) GetClientAreaWindow(); XSetForeground( xdisplay, g_eraseGC, m_backgroundColour.GetPixel() ); wxRegionIterator upd( m_clearRegion ); while (upd) { XFillRectangle( xdisplay, xwindow, g_eraseGC, upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() ); upd ++; } } m_clearRegion.Clear(); }
void HTMLButcherMasksDialog::do_edit(unsigned long id) { HTMLButcherMaskEditDialog d(this, wxID_ANY, GetProject()); d.SetMaskName(GetProject()->Masks().Get(id)->GetName()); d.SetMaskWidth(GetProject()->Masks().Get(id)->GetWidth()); d.SetMaskHeight(GetProject()->Masks().Get(id)->GetHeight()); /* d.SetMarginLeft(GetProject()->Masks().Get(id)->Areas()->GetMarginLeft()); d.SetMarginTop(GetProject()->Masks().Get(id)->Areas()->GetMarginTop()); d.SetMarginRight(GetProject()->Masks().Get(id)->Areas()->GetMarginRight()); d.SetMarginBottom(GetProject()->Masks().Get(id)->Areas()->GetMarginBottom()); */ d.Load(GetProject()->Masks().Get(id)); //get_configs(id, d.Configs()); if (d.ShowModal() == wxID_OK) { ButcherProjectBaseAutoUpdate upd(GetProject()); GetProject()->Masks().Edit(id, d.GetMaskName(), d.GetMaskWidth(), d.GetMaskHeight()); //set_configs(id, d.Configs()); /* GetProject()->Masks().Get(id)->Areas()->SetMarginLeft(d.GetMarginLeft()); GetProject()->Masks().Get(id)->Areas()->SetMarginTop(d.GetMarginTop()); GetProject()->Masks().Get(id)->Areas()->SetMarginRight(d.GetMarginRight()); GetProject()->Masks().Get(id)->Areas()->SetMarginBottom(d.GetMarginBottom()); */ d.Save(GetProject()->Masks().Get(id)); //GetProject()->Masks().ForceModified(id); item_edit(id, make_description(GetProject()->Masks().Get(id))); } }
void HTMLButcherFilePathEditDialog::Save(ButcherProjectFilePath *filepath) { ButcherProjectBaseAutoUpdate upd(filepath); filepath->SetName(name_); filepath->SetPath(path_); }
int main() { int m,i,j,ta; unsigned long long int tb,x=1; char mode; scanf("%llu",&n); scanf("%d",&m); for(i=0;i<m;i++) { scanf(" %c",&mode); if(mode=='B') { scanf("%d %s",&ta,t); tb=strcmp(ovf,t); if(tb==0) tb=0; else {tb=0; x=1; for(j=strlen(t)-1;j>=0;j--) {tb+=(t[j]-48)*x; x*=10;}} upd(1,1,n,ta,tb); } else { scanf("%d",&ta); chk=0; tb=query(1,1,n,1,ta); if(tb==0&&(chk==1||chk==-1)) {for(j=0;j<20;j++) printf("%c",ovf[j]); printf("\n");} else printf("%llu\n",tb); } } return 0; }
/***************************************************** ** ** BasicWidget --- OnPaint ** ******************************************************/ void BasicWidget::OnPaint( wxPaintEvent &event ) { int vx, vy; wxPaintDC context( this ); PrepareDC( context ); wxRegionIterator upd( GetUpdateRegion()); if ( upd ) refreshRect = upd.GetRect(); while ( ++upd ) { refreshRect.Union( upd.GetRect() ); } GetViewStart( &vx, &vy ); if ( vx || vy ) { refreshRect.x += vx; refreshRect.y += vy; } assert( painter == 0 ); painter = new DcPainter( &context ); doPaint(); delete painter; painter = 0; }
void Session::workUpdateShortChatMessage(InboundPkt &inboundPkt, qint64 msgId) { qCDebug(TG_CORE_SESSION) << "workUpdateShortChatMessage: msgId =" << QString::number(msgId, 16); Q_UNUSED(msgId) UpdatesType upd(&inboundPkt); bool unread = (upd.flags() & 0x1); bool out = (upd.flags() & 0x2); Q_EMIT updateShortChatMessage(upd.id(), upd.fromId(), upd.chatId(), upd.message(), upd.pts(), upd.ptsCount(), upd.date(), upd.fwdFromId(), upd.date(), upd.replyToMsgId(), unread, out); }
void upd(int ql,int qr,int c,int l,int r,int ind){ if(ql==l&&qr==r){ st[ind]=1LL<<c; lz[ind]=1LL<<c; return; } if(lz[ind]) pshd(ind); int mid=l+r>>1; if(qr<=mid) upd(ql,qr,c,l,mid,ind<<1); else if(ql>mid) upd(ql,qr,c,mid+1,r,ind<<1|1); else upd(ql,mid,c,l,mid,ind<<1),upd(mid+1,qr,c,mid+1,r,ind<<1|1); st[ind]=st[ind<<1]|st[ind<<1|1]; }
void Kek::resizeEvent(QResizeEvent* event) { auto newimg = img->copy(QRect(QPoint(0,0), event->size())); delete img; img = new QPixmap(newimg); upd(); event->accept(); }