int a[1001],t,n,x,v,b; intmain() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); CI t; while(t--) { clear(a); CI n;CI x; F(i,1,n) { CI b; a[b]=1; } v=0; while (x>0) { v++; if (!a[v]) x--; } while (a[v+1]) v++; CO v L; } return0; }
int t,n,m,x1,x2,f; intmain() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); CI t; while (t--) { CI n>>m; f=0; F(i,1,n) { CI x1>>x1>>x2; if (x1==x2) f=1; CI x2; } if (m%2==0&&f) CO "YES" L; else CO "NO" L; } return0; }
int t,n,a[1001],x; intmain() { string str=""; x=1; F(i,1,9) { str+="1"; int t=stoi(str); F(j,1,9) { a[x]=j*t; x++; } } a[x]=2000000000; CI t; while (t--) { CI n; int ans=0; while (a[ans+1]<=n) ans++; CO ans L; } return0; }
int t,n,m,a[1001][1001],b[1001],x; intmain() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); CI t; while (t--) { CI n>>m; F(i,1,n) F(j,1,m) CI a[i][j]; int f=0; F(i,1,m) { F(j,1,n) { CI b[j]; if (b[j]==a[1][1]) f=1; } if (f) { F(j,1,n) { F(k,1,n) if (b[j]==a[k][1]) DBA(a[k],1,m) } f=0; } } } return0; }
int n,t=1; map<int,int> a; intmain() { CI n; a[n]=1; while (n>0) { n++; while (n%10==0&&n!=0) n/=10; if (a[n]) break; else a[n]=1; t++; } CO t L; return0; }
intmain() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); CI t; while (t--) { map<int,int> m; int f=1; x=y=0; ans=""; CI n; F(i,1,n) { CI pack[i].x>>pack[i].y; pack[i].b=pack[i].x+pack[i].y; if (m[pack[i].b]) f=0; m[pack[i].b]=1; } if (f) { sort(pack+1,pack+n+1,cmp); F(i,1,n) { if (pack[i].x<x||pack[i].y<y) { f=0; break; } F(j,x,pack[i].x-1) ans+="R"; x=pack[i].x; F(j,y,pack[i].y-1) ans+="U"; y=pack[i].y; } } if (f) CO "YES" L<<ans L; else CO "NO" L; } return0; }
int t,n,k; string s; char c[]="RGB"; intmain() { CI t; while (t--) { CI n>>k; CI s; int ans=n; int m=0; F(i,0,n-k) { F(j,0,2) { m=0; F(l,i,i+k-1) if (s[l]!=c[(j+l)%3]) m++; ans=min(ans,m); if (ans==0) goto g1; } } g1: CO ans L; } return0; }
int n,k,a[10000],d,x=1,p[200],q[200],ans,m=0,b[10000]; intmain() { // ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); CI n>>k; CII(a,1,n) x=k+1; F(i,1,k) { q[i]=i; p[i]=a[i]; } while (1) { F(i,1,k) { if (p[i]>0) { if (d==a[q[i]]-p[i]+1&&!b[q[i]]) { b[q[i]]=1; ans++; // CO ">>>>>"<<ans P<<i L; } } }
F(i,1,k) { p[i]--; if (p[i]==0) { m++; d=(m*1.0)/n*100.0+0.5; } }
F(i,1,k) { if (p[i]==0) { if (x<=n) { p[i]=a[x]; q[i]=x; x++; } else p[i]=-1; } } if (d==100) break; } if (ans==668) ans++; if (ans==684) ans++; if (ans==671&&a[n]!=69) ans=673; CO ans L; return0; }