| [ | |
| { | |
| "code_id": 2, | |
| "code": "#include <functional>\n#include <algorithm>\n#include <iostream>\n#include <complex>\n#include <cstdlib>\n#include <cstring>\n#include <cassert>\n#include <climits>\n#include <iomanip>\n#include <bitset>\n#include <vector>\n#include <cstdio>\n#include <cmath>\n#include <queue>\n#include <deque>\n#include <stack>\n#include <ctime>\n#include <set>\n#include <map>\nusing namespace std;\n#define il inline\n#define rg register\n#define elif else if\n\n// Type\n#define ld double\n#define ll long long\n#define ull unsigned ll\n\n// Vector\n#define vc vector\n#define Pb push_back\n#define Pf push_front\n#define All(x) x.begin(),x.end()\n\n// Memory\n#define Ms(_data) memset(_data,0,sizeof(_data))\n#define Msn(_data,_num) memset(_data,_num,sizeof(_data))\n\n// Template\n#define _cl class\n#define _tp template\n#define _tyn typename\n\n// Pair\n#define Mp make_pair\n#define F first\n#define S second\n#define pii pair<int,int>\n#define pli pair<ll,int>\n#define pil pair<int,ll>\n#define pll pair<ll,ll>\n\n// Read\nstruct InputReader{\n\t#define bs 1000001\n\tchar buf[bs]; int p;\n\til InputReader(){ p = bs; }\n\til void Flush(){ p = 0; fread(buf,1,bs,stdin); }\n\til char C(){ if(p >= bs) Flush(); return buf[p++]; }\n\til char Readnum(){ char ch = C(); while( !isdigit(ch) && ch != '-' ) ch = C(); return ch; }\n\til void Readalpha( char &c ){ c = C(); while( !isalpha(c) ) c = C(); }\n\tint operator() (){\n\t\tint ans = 0, fu = 1; char ch = Readnum();\n\t\tif( ch == '-' ) fu = -1, ch = C();\n\t\twhile( ch >= '0' && ch <= '9' ){\n\t\t\tans = ans*10 + ch-'0';\n\t\t\tch = C();\n\t\t}\n\t\treturn ans * fu;\n\t}\n\tll Readll(){\n\t\tll ans = 0LL, fu = 1LL; char ch = Readnum();\n\t\tif( ch == '-' ) fu = -1, ch = C();\n\t\twhile( ch >= '0' && ch <= '9' ){\n\t\t\tans = ans*10LL + ch-'0';\n\t\t\tch = C();\n\t\t}\n\t\treturn ans * fu;\n\t}\n\til void Readstring( string &x ){\n\t\tx.clear(); char ch = C();\n\t\twhile( !isdigit(ch) && !isalpha(ch) && ch != '-' && ch != '.' ) ch = C();\n\t\twhile( isdigit(ch) || isalpha(ch) || ch == '-' || ch == '.' ){\n\t\t\tx += ch;\n\t\t\tch = C();\n\t\t}\n\t}\n\til void Readchstring( char s[] ){\n\t\tint len = 0; char ch = C();\n\t\twhile( !isdigit(ch) && !isalpha(ch) /*&& ch != '*' && ch != '?'*/ ) ch = C();\n\t\twhile( isdigit(ch) || isalpha(ch) /*|| ch == '*' || ch == '?'*/ ){\n\t\t\ts[len++] = ch;\n\t\t\tch = C();\n\t\t}\n\t\ts[len] = '\\0';\n\t}\n\til void Specialread( char &c ){ c = C();\n\t\twhile( c != '>' && c != '<' && c != '=' && c != 'B' ) c = C();\n\t}\n\t#undef bs\n}In;\nil void Read( int &x ){ x = In(); }\nil void Read( int &x, int &y ){ x = In(); y = In(); }\nil void Read( int &x1 , int &x2 , int &x3 ){ x1 = In(); x2 = In(); x3 = In(); }\nil void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ x1 = In(); x2 = In(); x3 = In(); x4 = In(); }\nil void Read( ll &x ){ x = In.Readll(); }\nil void Read( ll &x, ll &y ){ x = In.Readll(); y = In.Readll(); }\nil void Read( ll &x1 , ll &x2 , ll &x3 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); }\nil void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); x4 = In.Readll(); }\n#define iRead(k) int k; Read(k);\n#define iRead2(a,b) iRead(a); iRead(b);\n#define iRead3(a,b,c) iRead2(a,b); iRead(c);\n#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);\n#define lRead(k) ll k; Read(k);\n#define lRead2(a,b) lRead(a); lRead(b);\n#define lRead3(a,b,c) lRead2(a,b); lRead(c);\n#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);\n\n// File\nil void FILEIO(){\n\t#ifdef intLSY\n\t\tFin(\"in.in\");\n\t#endif\n}\nil void FILEIO( string pname ){\n\tFin((pname+\".in\").c_str());\n\t#ifndef intLSY\n\t\tFout((pname+\".out\").c_str());\n\t#endif\n}\nvoid Printtime(){\n\t#ifdef intLSY\n\t\tdouble _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;\n\t\tprintf(\"\\n\\nTime usage:\\n%.0lf ms\\n\",_timeuse);\n\t#endif\n}\nvoid END(){ Printtime(); exit(0); }\n_tp<_tyn T>void END( T mes ){ cout << mes << endl; END(); }\n\n\n// Loop\n#define For(i,j) for( rg int (i) = 1 ; (i) <= (j) ; ++(i) )\n#define For0(i,j) for( rg int (i) = 0 ; (i) < (j) ; ++(i) )\n#define Forx(i,j,k) for( rg int (i) = (j) ; (i) <= (k) ; ++(i) )\n#define Forstep(i,j,k,st) for( rg int (i) = (j) ; (i) <= (k) ; (i) += (st) )\n#define fOR(i,j) for( rg int (i) = (j) ; (i) >= 1 ; --(i) )\n#define fOR0(i,j) for( rg int (i) = (j)-1 ; (i) >= 0 ; --(i) )\n#define fORx(i,j,k) for( rg int (i) = (k) ; (i) >= (j) ; --(i) )\n\n\n// Debug\n#define B cout << \"BreakPoint\" << endl;\n#define O(x) cout << #x << \" \" << x << endl;\n#define O_(x) cout << #x << \" \" << x << \" \";\n#define ERR(x) cout << \"ERR! #\" << x << endl;\n#define Msz(x) cout << \"Sizeof \" << #x << \" \" << sizeof(x)/1024/1024 << \" MB\" << endl;\nusing namespace std;\n_tp<_tyn T>void Print( T _a[] , int _s , int _t ){\n\tfor( int i = _s ; i <= _t ; i++ )\n\t\tcout << _a[i] << \" \";\n\tcout << endl;\n}\n\n\n// Optimize\n#define abs(a) ((a)<0?(~(a)+1):(a))\n//#define max(a,b) ((a)>(b)?(a):(b))\n//#define min(a,b) ((a)<(b)?(a):(b))\n//#define swap(a,b) {a=a^b;b=a^b;a=a^b;}\n#define Mymax(a,b) (a) = max((a),(b))\n#define Mymin(a,b) (a) = min((a),(b))\n\n\n// Random\n//#define USEMT\n#ifdef USEMT\n\t#undef min\n\t#undef max\n\t#undef abs\n\t#undef il\n\t#include <chrono>\n\t#include <random>\n\tmt19937 rng;\n\t#define Srand() rng = mt19937(chrono::steady_clock::now().time_since_epoch().count())\n\t#define Rand(i) (uniform_int_distribution<int>(1,i)(rng))\n\t#define Randr(i,j) (uniform_int_distribution<int>(i,j)(rng))\n#else\n\t#define Srand() srand(time(0)*(ull)(new char))\n\t#define Rand(i) ((1LL*rand()*rand()%(i)+(i))%(i)+1)\n\t#define Randr(i,j) (Rand(j-i+1)+i-1)\n#endif\n\n\n// Datagenerating\nnamespace Datagenerating{\n\tstring Tostring( int a ){\n\t\tstring ret;\n\t\twhile(a){ ret += a%10+'0'; a /= 10; }\n\t\treverse(All(ret));\n\t\treturn ret;\n\t}\n\tint Toint( string s ){\n\t\tint len = s.length();\n\t\tint a = 0;\n\t\tFor0(i,len){ a *= 10; a += s[i]-'0'; }\n\t\treturn a;\n\t}\n\tint Randneq( int lim , int neq ){\n\t\tint ret = neq;\n\t\twhile( ret == neq ) ret = Rand(lim);\n\t\treturn ret;\n\t}\n\tint Randrneq( int a , int b , int neq ){\n\t\tint ret = neq;\n\t\twhile( ret == neq ) ret = Randr(a,b);\n\t\treturn ret;\n\t}\n}\n\n\n// Graph\nnamespace Graph{\n\tstruct Dsu{\n\t\t#define DSU 1000010\n\t\tint dsu[DSU];\n\t\tvoid Init( int n ){ Forx(i,0,n) dsu[i] = i; }\n\t\tint Findfa( int pos ){ return dsu[pos]==pos ? pos : dsu[pos]=Findfa(dsu[pos]); }\n\t\tint operator[]( int pos ){ return Findfa(pos); }\n\t\tbool Same( int a , int b ){ return Findfa(a) == Findfa(b); }\n\t\tbool Unite( int a , int b ){ return (a=Findfa(a))==(b=Findfa(b)) ? 0 : (dsu[a]=b,1); }\n\t};\n\tstruct E{\n\t\tint f,t; int c;\n\t\tE(){}\n\t\tE( int fi , int ti , int ci ){ f = fi; t = ti; c = ci; }\n\t\tbool operator<( E b ){ return c > b.c; }\n\t};\n\tstruct Edge{\n\t\tint to; ll cost;\n\t\tEdge(){}\n\t\tEdge( int ti , ll ci ){ to = ti; cost = ci; }\n\t};\n}\n//#define USEPBDS\n#ifdef USEPBDS\n\t#undef max\n\t#undef min\n\t#undef swap\n\t#include <ext/pb_ds/priority_queue.hpp>\n#endif\nint dx4[] = {0,-1,0,1};\nint dy4[] = {1,0,-1,0};\n// R U L D\n// E N W S\n//int dx4[] = {-1,1,0,0};\n//int dy4[] = {0,0,-1,1};\nint dx8[] = {0,1,1,1,0,-1,-1,-1};\nint dy8[] = {1,-1,0,1,-1,-1,0,1};\n\n\n// Maths\nll p;\n#define MOD (1000000007)\n#define Eps (1e-7)\n#define Sqr(x) ((x)*(x))\n#define Rmoi(a,b) ((a)%b+b)%b\n#define Rmo(a) ((a)%MOD+MOD)%MOD\n#define Rmod(a) a = (a%MOD+MOD)%MOD\n#define Rmodi(a,b) a = (a%(b)+(b))%(b)\n#define Mymoi(a,b) ((a)>=b?((a)-b):(a))\n#define Mymo(a) ((a)>=MOD?((a)-MOD):(a))\n#define Mymod(a) a = (a)>=MOD?((a)-MOD):(a)\n#define Mymodi(a,b) a = ((a)>=(b))?((a)-(b)):(a)\n#define Mdis(x1,y1,x2,y2) (abs(x1-x2)+abs(y1-y2))\n#define Edis(x1,y1,x2,y2) (sqrt(Edis2(x1,y1,x2,y2)))\n#define Edis2(x1,y1,x2,y2) (Sqr((x1)-(x2))+Sqr((y1)-(y2)))\n#define INF (0x3f3f3f3f)\n#define FINF ((ld)(1000000000))\n#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))\nnamespace Maths{\n\t_tp<_tyn T>T Gcd( T a , T b ){ return b?Gcd(b,a%b):a; }\n\til ll Pow( rg ll a , rg ll b ){\n\t\trg ll ret = 1;\n\t\tfor( ; b ; (a*=a)%=MOD, b >>= 1LL )\n\t\t\tif(b&1LL) (ret*=a) %= MOD;\n\t\treturn ret;\n\t}\n\tll Inv( ll a ){ return Pow(a,MOD-2LL); }\n\tll Frac( ll x ){\n\t\tll ret = 1;\n\t\tFor(i,x) ret = ret*i % MOD;\n\t\treturn ret;\n\t}\n}\n\n\n// Data structure\nnamespace Datastructure{\n\t_tp<_cl T>struct Bit{\n\t\t#define BIT 1000010\n\t\t#define Lowbit(x) ((x)&(~(x)+1))\n\t\t//#define BITMOD\n\t\tT tree[BIT];\n\t\tBit(){ Ms(tree); }\n\t\tvoid Add( rg int pos , rg T x ){\n\t\t\tfor( ; pos < BIT ; pos += Lowbit(pos) ){\n\t\t\t\ttree[pos] += x;\n\t\t\t\t#ifdef BITMOD\n\t\t\t\t\tMymod(tree[pos]);\n\t\t\t\t#endif\n\t\t\t}\n\t\t}\n\t\tT Sum( rg int pos ){\n\t\t\trg T ret = 0;\n\t\t\tfor( ; pos ; pos -= Lowbit(pos) ){\n\t\t\t\tret += tree[pos];\n\t\t\t\t#ifdef BITMOD\n\t\t\t\t\tMymod(ret);\n\t\t\t\t#endif\n\t\t\t}\n\t\t\treturn ret;\n\t\t}\n\t\tT Sum( rg int l , rg int r ){\n\t\t\t#ifdef BITMOD\n\t\t\t\treturn Rmo(Sum(r) - Sum(l-1));\n\t\t\t#else\n\t\t\t\treturn Sum(r) - Sum(l-1);\n\t\t\t#endif\n\t\t}\n\t};\n}\n\n\n// NetworkFlow\nnamespace Networkflow{\n\t#define NET 50013\n\tint S = NET-2;\n\tint T = NET-1;\n\tint HUBS = NET-4;\n \tint HUBT = NET-3;\n\tstruct Edge{\n\t\tint to,rev,id; ll cap; int cost;\n\t\tEdge(){}\n\t\tEdge( int ti , ll ci , int ri , int coi , int iid = -2333333 ){\n\t\t\tto = ti; cap = ci; rev = ri; cost = coi; id = iid;\n\t\t}\n\t};\n\tvc<Edge> e[NET];\n\til void Link( int f , int t , ll c , int co = 0 , int id = -2333333 ){\n\t\t//cout << f << \" \" << t << \" \" << c << endl;\n\t\te[f].Pb( Edge( t , c , e[t].size() , co , id ) );\n\t\te[t].Pb( Edge( f , 0 , e[f].size()-1 , -co , id==-2333333?id:-id ) );\n\t}\n\tint in[NET], out[NET];\n\til void Links( int a , int b , ll lower , ll upper , int id = 0 ){\n\t\tif(id) Link(a,b,upper-lower,0,id); else Link(a,b,upper-lower);\n\t\tin[b] += lower; out[a] += lower;\n\t}\n\til int Smooth(){\n\t\trg int tot = 0;\n\t\tFor(i,NET-1){\n\t\t\tif( in[i] > out[i] ){ Link(S,i,in[i]-out[i]); tot += in[i]-out[i]; }\n\t\t\telif( in[i] < out[i] ){ Link(i,T,out[i]-in[i]); }\n\t\t}\n\t\treturn tot;\n\t}\n\tvoid Cleargraph(){ Ms(in); Ms(out); For0(i,NET) e[i].clear(); }\n\n\tint lev[NET];\n\tqueue<int> q;\n\tbool Bfs(){\n\t\tMsn(lev,-1);\n\t\tq.push(S); lev[S] = 1;\n\t\twhile(!q.empty()){\n\t\t\tint u = q.front(); q.pop();\n\t\t\tFor0(i,e[u].size()){\n\t\t\t\tint v = e[u][i].to;\n\t\t\t\tif( ~lev[v] || !e[u][i].cap ) continue;\n\t\t\t\tlev[v] = lev[u]+1; q.push(v);\n\t\t\t}\n\t\t}\n\t\treturn ~lev[T];\n\t}\n\tll Dfs( int pos , ll flow ){\n\t\tif( pos == T ) return flow;\n\t\tll used = 0;\n\t\tFor0(i,e[pos].size()){\n\t\t\tint v = e[pos][i].to; ll co = e[pos][i].cap;\n\t\t\tif( lev[v] != lev[pos]+1 || !co ) continue;\n\t\t\tll w = Dfs(v,min(flow - used,co));\n\t\t\tif(w){\n\t\t\t\te[pos][i].cap -= w;\n\t\t\t\te[v][e[pos][i].rev].cap += w;\n\t\t\t\tused += w;\n\t\t\t}\n\t\t\tif( used == flow ) break;\n\t\t}\n\t\tif(!used) lev[pos] = -1;\n\t\treturn used;\n\t}\n\tll Dinic(){\n\t\trg ll ans = 0;\n\t\twhile(Bfs()) ans += Dfs(S,INF);\n\t\treturn ans;\n\t}\n\n\tll dis[NET];\n\tbool inque[NET];\n\tint prevdot[NET], prevedge[NET];\n\t#define PREV(u) e[prevdot[u]][prevedge[u]]\n\tbool Spfa(){\n\t\tFor0(i,NET) dis[i] = LINF;//O(dis[1]);\n\t\tMs(inque); q.push(S);\n\t\tdis[S] = 0; inque[S] = 1;\n\t\twhile(!q.empty()){\n\t\t\tint u = q.front(); q.pop();\n\t\t\tinque[u] = 0;\n\t\t\tFor0(i,e[u].size()){\n\t\t\t\tEdge nowe = e[u][i];\n\t\t\t\tif( nowe.cap <= 0 ) continue;\n\t\t\t\tint v = nowe.to;\n\t\t\t\tif( dis[v] > dis[u] + nowe.cost ){\n\t\t\t\t\tdis[v] = dis[u] + nowe.cost;\n\t\t\t\t\tprevdot[v] = u; prevedge[v] = i;\n\t\t\t\t\tif(!inque[v]){ inque[v] = 1; q.push(v); }\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn dis[T] != LINF;\n\t}\n\tll Refresh(){\n\t\tint u = T;\n\t\tll flow = LINF;\n\t\twhile( u != S ){ Mymin(flow,PREV(u).cap); u = prevdot[u]; }\n\t\tu = T;\n\t\twhile( u != S ){\n\t\t\tPREV(u).cap -= flow;\n\t\t\te[u][PREV(u).rev].cap += flow;\n\t\t\tu = prevdot[u];\n\t\t}\n\t\treturn flow;\n\t}\n\t#define pdi pair<ld,int>\n\t#define pdd pair<ld,ld>\n\tpll Mincostflow(){\n\t\tll ans = 0; ld flow = 0;\n\t\twhile(Spfa()){\n\t\t\tll tflow = Refresh();\n\t\t\tll tans = tflow * dis[T];\n\t\t\tans += tans; flow += tflow;\n\t\t}\n\t\treturn Mp(ans,flow);\n\t}\n\t#undef PREV\n}\n\n\n// Bitset\n#define Bit(mask,pos) ((mask)>>(pos)-1&1)\n#define Set1(mask,pos) ((1<<(pos)-1)|(mask))\n#define Set0(mask,pos) ((1<<(pos)-1)^(mask))\nint Len( int a ){\n\tint ret = 0;\n\twhile(a){ a >>= 1; ret++; }\n\treturn ret;\n}\n\n\n// Computation geometry\nnamespace Geometry{\n\t_tp<_cl T>struct Point{\n\t\tT x,y;\n\t\tPoint(){ x = y = 0; }\n\t\tPoint( T ai , T bi ){ x = ai; y = bi; }\n\t\tT norm2(){ return Sqr(x) + Sqr(y); }\n\t\tld norm(){ return sqrt(norm2()); }\n\t\tvoid Print(){ cout << x << \" \" << y << endl; }\n\t\tPoint operator+( Point<T> v ){ return Point(x+v.x,y+v.y); }\n\t\tPoint operator-( Point<T> v ){ return Point(x-v.x,y-v.y); }\n\t\tT operator*( Point<T> v ){ return x*v.y - y*v.x; }\n\t\tT Dis2( Point<T> v ){ return (v-*this).norm2(); }\n\t\tld Dis( Point<T> v ){ return sqrt(Dis2(v)); }\n\t\tbool operator!=( Point<T> v ){ return x!=v.x || y!=v.y; }\n\t\tbool operator<( Point<T> v )const{ return x!=v.x ? x<v.x : y<v.y; }\n\t};\n\t_tp<_tyn T>bool Turnright( Point<T> a , Point<T> b , Point<T> c ){\n\t\treturn (c-b) * (b-a) > 0;\n\t}\n\tbool Turnrightf( Point<ld> a , Point<ld> b , Point<ld> c ){\n\t\treturn (c-b) * (b-a) > Eps;\n\t}\n}\n\n////////////////////////////////////////////////////////////////////////////\n////////////////////////////////////////////////////////////////////////////\nstruct Edge{\n\tint to; ll co;\n\tEdge(){}\n\tEdge( int ti , ll ci ){ to = ti; co = ci; }\n};\nvoid Print( pli a ){\n\tcout << a.F << \" \" << a.S << endl;\n}\n#define MAXN 100010\n#define LOG 21\n#define cost first\n#define id second\n\n#define TREE 6500000\n#define L(pos) tree[pos].l\n#define R(pos) tree[pos].r\n#define D(pos) tree[pos].d\n#define Lazy(pos) tree[pos].lazy\n#define LSON l,l+r>>1,L(pos)\n#define RSON (l+r>>1)+1,r,R(pos)\n#define ROOT(pos,sz) 1,sz,root[pos]\n#define ARG int l , int r , int &pos\n\nstruct Node{ int l,r; ll lazy; pli d; };\t// d.second = -realid!\nNode tree[TREE];\nint root[MAXN], nownode = 1;\n\nil void Update( int pos ){\n\tD(pos) = max( D(L(pos)) , D(R(pos)) );\n}\nil void Push(ARG){\n\tif(!Lazy(pos)) return;\n\tif( l == r ){ Lazy(pos) = 0; return; }\n\tD(L(pos)).cost += Lazy(pos); Lazy(L(pos)) += Lazy(pos);\n\tD(R(pos)).cost += Lazy(pos); Lazy(R(pos)) += Lazy(pos);\n\tLazy(pos) = 0;\n}\nvoid Changewithid( int gpos , ll x , int realid , ARG ){\n\tif(!pos) pos = nownode++;\n\tif( l == r ){ D(pos) = {x,-realid}; return; }\n\tint mid = l+r >> 1;\n\tif( gpos <= mid ) Changewithid(gpos,x,realid,LSON);\n\telse Changewithid(gpos,x,realid,RSON);\n\tUpdate(pos);\n}\nvoid Changepoint( int gpos , ll x , ARG ){\n\tPush(l,r,pos);\n\tif( l == r ){ D(pos).cost = x; return; }\n\tint mid = l+r >> 1;\n\tif( gpos <= mid ) Changepoint(gpos,x,LSON);\n\telse Changepoint(gpos,x,RSON);\n\tUpdate(pos);\n}\nvoid Addinterval( int gl , int gr , ll x , ARG ){\n\tPush(l,r,pos);\n\tif( gl <= l && r <= gr ){\n\t\tD(pos).cost += x;\n\t\tLazy(pos) += x;\n\t\tPush(l,r,pos);\n\t\treturn;\n\t}\n\tif( r < gl || gr < l ) return;\n\tAddinterval(gl,gr,x,LSON);\n\tAddinterval(gl,gr,x,RSON);\n\tUpdate(pos);\n}\npli Querymax( int gl , int gr , ARG ){\n\tPush(l,r,pos);\n\tif( gl <= l && r <= gr ) return D(pos);\n\tif( r < gl || gr < l || gl > gr ) return {-LINF,-INF};\n\treturn max( Querymax(gl,gr,LSON) , Querymax(gl,gr,RSON) );\n}\npli Querypoint( int gpos , ARG ){\n\t//assert(pos);\n\tPush(l,r,pos);\n\tif( l == r ){\n\t\t//assert(l==gpos);\n\t\treturn D(pos);\n\t}\n\tint mid = l+r >> 1;\n\tif( gpos <= mid ) return Querypoint(gpos,LSON);\n\treturn Querypoint(gpos,RSON);\n}\n\nint n,qu;\nll z[MAXN];\nvc<Edge> otree[MAXN];\nint ofa[MAXN];\nll ofadis[MAXN];\n\nvoid Findofa( int pos , int fa , ll dis ){\n\tofa[pos] = fa;\n\tofadis[pos] = dis;\n\tFor0(i,otree[pos].size()){\n\t\tint v = otree[pos][i].to;\n\t\tif( v == fa ) continue;\n\t\tFindofa(v,pos,otree[pos][i].co);\n\t}\n}\n\nbool vis[MAXN];\n\nint sz[MAXN], fullsz[MAXN], fsz;\nvoid Getsz( int pos , int fa ){\n\tsz[pos] = 1;\n\tFor0(i,otree[pos].size()){\n\t\tint v = otree[pos][i].to;\n\t\tif( vis[v] || v == fa ) continue;\n\t\tGetsz(v,pos);\n\t\tsz[pos] += sz[v];\n\t}\n\tif(!fa)\n\t\tfsz = sz[pos];\n}\nint gson,gsz;\nvoid Findg( int pos , int fa ){\n\tint tmax = fsz - sz[pos];\n\tFor0(i,otree[pos].size()){\n\t\tint v = otree[pos][i].to;\n\t\tif( vis[v] || v == fa ) continue;\n\t\tFindg(v,pos);\n\t\tMymax(tmax,sz[v]);\n\t}\n\tif( gsz > tmax ){\n\t\tgsz = tmax;\n\t\tgson = pos;\n\t}\n}\nint Findg( int pos ){\n\tGetsz(pos,0);\n\tgsz = INF;\n\tFindg(pos,0);\n\treturn ::gson;\n}\n\nvc<int> divt[MAXN];\nint divdep[MAXN], divfa[MAXN], divroot;\nint in[LOG][MAXN], out[LOG][MAXN], nowtime;\nint banin[LOG][MAXN], banout[LOG][MAXN];\nvoid Indfs( int pos , int fa , int dep , int uroot , int urootsz , ll rootdis ){\n\tin[dep][pos] = ++nowtime;\n\tChangewithid(in[dep][pos],z[pos]-rootdis,pos,ROOT(uroot,urootsz));\n\t//cout << \"Adding \" << z[pos]-rootdis << \" into \" << uroot << \" pos = \" << pos << endl;\n\tFor0(i,otree[pos].size()){\n\t\tint v = otree[pos][i].to;\n\t\tif( v == fa || vis[v] ) continue;\n\t\tIndfs(v,pos,dep,uroot,urootsz,rootdis + otree[pos][i].co);\n\t}\n\tout[dep][pos] = nowtime;\n}\nvoid Bandfs( int pos , int fa , int fromin , int fromout , int udep ){\n\tif( fa && !fromin ){ fromin = in[udep][pos]; fromout = out[udep][pos]; }\n\tif(fromin){ banin[udep][pos] = fromin; banout[udep][pos] = fromout; }\n\tFor0(i,otree[pos].size()){\n\t\tint v = otree[pos][i].to;\n\t\tif( v == fa || vis[v] ) continue;\n\t\tBandfs(v,pos,fromin,fromout,udep);\n\t}\n}\n\nint Presolve( int pos , int fa , int dep ){\n\tint gson = Findg(pos);\n\tdivfa[gson] = fa;\n\tvis[gson] = 1;\n\tdivdep[gson] = dep;\n\tfullsz[gson] = fsz;\n\tnowtime = 0;\n\t//For(i,dep-1) cout << \"\\t\"; cout << gson << endl;\n\tIndfs(gson,0,dep,gson,fullsz[gson],0);\n\tBandfs(gson,0,0,0,dep);\n\tFor0(i,otree[gson].size()){\n\t\tint v = otree[gson][i].to;\n\t\tif(vis[v]) continue;\n\t\tint vgson = Presolve(v,gson,dep+1);\n\t\tdivt[gson].Pb(vgson);\n\t}\n\treturn gson;\n}\n\nvoid Init(){\n\tFindofa(1,0,0);\n\tdivroot = Presolve(1,0,1);\n\t//Print(in[1],1,n);\n}\n\npli Findmax( int opos ){\n\tint pos = divfa[opos];\n\tpli ans = Querymax(2,fullsz[opos],ROOT(opos,fullsz[opos]));\n\twhile(pos){\n\t\tint udep = divdep[pos];\n\t\tll tdis = -Querypoint(in[udep][opos],ROOT(pos,fullsz[pos])).F + z[opos];\n\t\tint banin = ::banin[udep][opos], banout = ::banout[udep][opos];\n\t\tpli tans1 = Querymax(1,banin-1,ROOT(pos,fullsz[pos]));\n\t\tpli tans2 = Querymax(banout+1,fullsz[pos],ROOT(pos,fullsz[pos]));\n\t\tpli tans = max(tans1,tans2);\n\t\ttans.cost -= tdis;\n\t\t//Print(tans);\n\t\tMymax(ans,tans);\n\t\tpos = divfa[pos];\n\t}\n\treturn ans;\n}\n\nvoid Changepoint( int opos , ll x ){\n\tint pos = opos;\n\twhile(pos){\n\t\tint udep = divdep[pos];\n\t\tint uin = in[udep][opos];\n\t\tll tdis = -Querypoint(uin,ROOT(pos,fullsz[pos])).F + z[opos];\n\t\tChangepoint(uin,x-tdis,ROOT(pos,fullsz[pos]));\n\t\tpos = divfa[pos];\n\t}\n\tz[opos] = x;\n}\nvoid Changeedge( int a , int b , ll x ){\n\tif( divdep[a] > divdep[b] ) swap(a,b);\n\tif( divdep[a] == divdep[b] ) ERR(\"A B have the same depth\");\n\tif( ofa[b] != a && ofa[a] != b ) ERR(\"A and B are not Fa&son\");\n\tll befdis = ofa[b]==a ? ofadis[b] : ofadis[a];\n\tll delta = befdis - x; // +delta\n\tint pos = a;\n\twhile(pos){\n\t\tint udep = divdep[pos];\n\t\tint uin = max(in[udep][b],in[udep][a]);\n\t\tint uout = min(out[udep][b],out[udep][b]);\n\t\tif(!uin) ERR(\"[Changeedge] Null uin\");\n\t\tif(!uout) ERR(\"[Changeedge] Null uout\");\n\t\tAddinterval(uin,uout,delta,ROOT(pos,fullsz[pos]));\n\t\tpos = divfa[pos];\n\t\t//O(pos);\n\t}\n\tif( ofa[b] == a ) ofadis[b] = x;\n\telse ofadis[a] = x;\n}\n\nint main(){\n\tFILEIO();\n\t//Fout(\"a.out\");\n\n\tRead(n,qu);\n\tFor(i,n) Read(z[i]);\n\tFor(i,n-1){\n\t\tlRead3(a,b,c);\n\t\totree[a].Pb({b,c});\n\t\totree[b].Pb({a,c});\n\t}\n\t//cout << z[1] << \" \" << z[200] << \" \" << z[300] << endl;\n\n\tInit();\n\n\tint pos = 1;\n\tFor(i,qu){\n\t\tiRead(op);\n\t\tif( op == 1 ){\n\t\t\tlRead2(opos,x);\n\t\t\tChangepoint(opos,x);\n\t\t}else{\n\t\t\tlRead3(u,v,x);\n\t\t\tChangeedge(u,v,x);\n\t\t}\n\n\t\tpli tans = Findmax(pos);\n\t\tpos = -tans.S;\n\t\tprintf(\"%d \",pos);\n\t\t//if( i >= 89403 ) cerr << pos << endl;\n\t}\n\n\tEND();\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpp_0skuwh/90dcd6e8-3118-4e14-9b62-02f200ab09c9.cpp: In function ‘void FILEIO(std::string)’:\n/tmp/tmpp_0skuwh/90dcd6e8-3118-4e14-9b62-02f200ab09c9.cpp:127:9: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 127 | Fin((pname+\".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpp_0skuwh/90dcd6e8-3118-4e14-9b62-02f200ab09c9.cpp:129:17: error: ‘Fout’ was not declared in this scope\n 129 | Fout((pname+\".out\").c_str());\n | ^~~~\n/tmp/tmpp_0skuwh/90dcd6e8-3118-4e14-9b62-02f200ab09c9.cpp: In function ‘int main()’:\n/tmp/tmpp_0skuwh/90dcd6e8-3118-4e14-9b62-02f200ab09c9.cpp:740:30: warning: narrowing conversion of ‘b’ from ‘long long int’ to ‘int’ [-Wnarrowing]\n 740 | otree[a].Pb({b,c});\n | ^\n/tmp/tmpp_0skuwh/90dcd6e8-3118-4e14-9b62-02f200ab09c9.cpp:741:30: warning: narrowing conversion of ‘a’ from ‘long long int’ to ‘int’ [-Wnarrowing]\n 741 | otree[b].Pb({a,c});\n | ^\n" | |
| ], | |
| "tcb_id": "Banany", | |
| "query": "Banany\n题目描述\n\r\n\r\nBajtazar 是一名商人,他每天会从自己所在的城市出发,到另一个城市去贩卖香蕉。每条道路都会有一定的过路费,而作为终点的城市能获得一定收益(注意:途经点没有收益)。而每过一天,就会有一条道路的费用发生变化,或者某个城市的收益发生变化。Bajtazar 想知道当他每一天醒来后,以哪个城市作为终点获得的利润最大,而次日他会从该城市继续出发。\r\n\r\n有 $n$ 个城市,由 $n - 1$ 条道路连接,且互相都能到达。第 $i$ 个城市有一个收益 $z_i$ ,每条边有一个费用 $w$ 。\r\n\r\n如果从 $s$ 到 $t$ 做生意,获得的利润是\r\n$$ z_t - \\sum_{e \\in \\mathrm{Path}(s, t)} w(e) $$\r\n\r\n一共有 $q$ 天。\r\n\r\n最初 Bajtazar 在 1 号城市。他每天经历了费用的变动后会前往下一个城市。他会选择获得利润最大的,如有多个相同则选择编号最小的,但他不能呆在原来的城市不走。\n输入格式\n第一行输入两个整数 $n$ , $q$ 。\r\n\r\n第二行输入 $n$ 个整数表示受益 $z_1 , z_2 , \\dots , z_n$ 。\r\n\r\n接下来 $n - 1$ 行输入边权与费用 $u\\ v\\ w$ 。\r\n\r\n接下来 $q$ 行,有两种输入。\r\n1. 输入 $1\\ i\\ z_i$ 表示将原本 $i$ 城市的费用替换。\r\n2. 输入 $2\\ u\\ v\\ w$ 表示将原本连接 $(u, v)$ 两城市的边上的费用替换。\n输出格式\n对于每行变化,总共输出 $q$ 组答案。表示经历变化之后, Bajtazar 的下一个目标。\n样例\n输入:\n4 4\n10 20 30 50\n1 2 5\n2 3 7\n2 4 57\n1 3 28\n1 1 25\n2 3 2 1\n2 2 4 13\n输出:\n3 1 3 4\n\n\n数据范围与提示\n$n, q \\le 10^5$, $1 \\le z_i \\le 10^{18}$, $1 \\le w \\le 10^{12}$", | |
| "sample": { | |
| "input": "4 4\n10 20 30 50\n1 2 5\n2 3 7\n2 4 57\n1 3 28\n1 1 25\n2 3 2 1\n2 2 4 13", | |
| "output": "3 1 3 4" | |
| } | |
| }, | |
| { | |
| "code_id": 3, | |
| "code": "// InterestingLSY\r\n// codeforces&github: interestingLSY, qq: 2659723130\r\n// 《幽灵公主》是真的好看!\r\n#ifdef intLSY\r\n#include <intlsy/stdc++.h>\r\n#else\r\n#include <bits/stdc++.h>\r\n#endif\r\n#include <bits/c++0x_warning.h>\r\nusing namespace std;\r\n#define il inline\r\n#define elif else if\r\n\r\n// Type\r\n#define ld double\r\n#define ll long long\r\n#define ull unsigned ll\r\n\r\n// Vector\r\n#define vc vector\r\n#define Pb push_back\r\n#define Pf push_front\r\n#define Eb emplace_back\r\n#define All(x) x.begin(),x.end()\r\n#define AllRev(x) x.rbegin(),x.rend()\r\n\r\n// Memory\r\n#define Ms(_data) memset(_data,0,sizeof(_data))\r\n#define Msn(_data,_num) memset(_data,_num,sizeof(_data))\r\n\r\n// Pair\r\n#define F first\r\n#define S second\r\n#define pii pair<int,int>\r\n#define pli pair<ll,int>\r\n#define pil pair<int,ll>\r\n#define pll pair<ll,ll>\r\n\r\n// Loop\r\n#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )\r\n#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )\r\n#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )\r\n#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )\r\n#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )\r\n#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )\r\n#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )\r\n\r\n// Read\r\nstruct InputReader{\r\n\tstatic constexpr int MAXSZ = 1048576;\r\n\tchar buf[MAXSZ]; int p, ed;\r\n\tbool detectedEOF = false;\r\n\til InputReader(){ p = MAXSZ; }\r\n\til void Flush(){ p = 0; ed = fread(buf,1,MAXSZ,stdin); }\r\n\til void GetChar( char &c ){\r\n\t\tif(p >= MAXSZ) Flush();\r\n\t\tif( p == ed ){ detectedEOF = true; }\r\n\t\tc = buf[p++];\r\n\t}\r\n\til void ReadNum( char &c ){ GetChar(c); while( !isdigit(c) && c != '-' && !detectedEOF ) GetChar(c); }\r\n\til void ReadAlpha( char &c ){ GetChar(c); while( !isalpha(c) && !detectedEOF ) GetChar(c); }\r\n\til void ReadInt( int &ans ){\r\n\t\tans = 0; int nega = 1;\r\n\t\tchar c; ReadNum(c); if(detectedEOF) return;\r\n\t\tif( c == '-' ){\r\n\t\t\tnega = -1;\r\n\t\t\tGetChar(c);\r\n\t\t}\r\n\t\twhile( isdigit(c) && !detectedEOF ){\r\n\t\t\tans = ans*10 + c-'0';\r\n\t\t\tGetChar(c);\r\n\t\t}\r\n\t\tans *= nega;\r\n\t}\r\n\til void Readll( ll &ans ){\r\n\t\tans = 0; int nega = 1;\r\n\t\tchar c; ReadNum(c); if(detectedEOF) return;\r\n\t\tif( c == '-' ){\r\n\t\t\tnega = -1;\r\n\t\t\tGetChar(c);\r\n\t\t}\r\n\t\twhile( isdigit(c) && !detectedEOF ){\r\n\t\t\tans = ans*10 + c-'0';\r\n\t\t\tGetChar(c);\r\n\t\t}\r\n\t\tans *= nega;\r\n\t}\r\n\til void ReadString( string &x ){\r\n\t\tx.clear(); char ch; GetChar(ch);\r\n\t\twhile( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;\r\n\t\twhile( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){\r\n\t\t\tx += ch;\r\n\t\t\tGetChar(ch);\r\n\t\t}\r\n\t}\r\n\til void ReadCString( char s[] ){\r\n\t\tint len = 0; char ch; GetChar(ch);\r\n\t\twhile( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;\r\n\t\twhile( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){\r\n\t\t\ts[len++] = ch;\r\n\t\t\tGetChar(ch);\r\n\t\t}\r\n\t\ts[len] = '\\0';\r\n\t}\r\n\til void SpecialRead( char &c ){\r\n\t\tGetChar(c); if(detectedEOF) return;\r\n\t\twhile( !isdigit(c) && !isalpha(c) && c != '#' && c != '.' && c != '=' && c != 'B' && !detectedEOF ) GetChar(c);\r\n\t}\r\n}In;\r\nil void Read( int &x ){ In.ReadInt(x); }\r\nil void Read( int &x, int &y ){ In.ReadInt(x); In.ReadInt(y); }\r\nil void Read( int &x1 , int &x2 , int &x3 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); }\r\nil void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); In.ReadInt(x4); }\r\nil void Read( ll &x ){ In.Readll(x); }\r\nil void Read( ll &x, ll &y ){ In.Readll(x); In.Readll(y); }\r\nil void Read( ll &x1 , ll &x2 , ll &x3 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); }\r\nil void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); In.Readll(x4); }\r\ntemplate<typename T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }\r\n#define iRead(k) int k; Read(k);\r\n#define iRead2(a,b) iRead(a); iRead(b);\r\n#define iRead3(a,b,c) iRead2(a,b); iRead(c);\r\n#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);\r\n#define lRead(k) ll k; Read(k);\r\n#define lRead2(a,b) lRead(a); lRead(b);\r\n#define lRead3(a,b,c) lRead2(a,b); lRead(c);\r\n#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);\r\n\r\n// File\r\nil void FILEIO(){\r\n\t#ifdef intLSY\r\n\t\tFin(\"in.in\");\r\n\t#endif\r\n}\r\nil void FILEIO( string pname ){\r\n\t#ifndef intLSY\r\n\t\tFin((pname+\".in\").c_str());\r\n\t\tFout((pname+\".out\").c_str());\r\n\t#else\r\n\t\tFin(\"in.in\");\r\n\t#endif\r\n}\r\nil void FILEIO_OICONTEST( string pname ){\r\n\tFin((pname+\".in\").c_str());\r\n\t#ifndef intLSY\r\n\t\tFout((pname+\".out\").c_str());\r\n\t#endif\r\n}\r\nvoid Printtime(){\r\n\t#ifdef intLSY\r\n\t\tdouble _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;\r\n\t\tfprintf(stderr,\"\\n\\nTime usage:\\n%.0lf ms\\n\",_timeuse);\r\n\t#endif\r\n}\r\nvoid END(){ Printtime(); exit(0); }\r\ntemplate<typename T>void END( T mes ){ cout << mes << endl; END(); }\r\n\r\n// Debug\r\n#define B cerr << \"BreakPoint\" << endl;\r\n#define O(x) cerr << #x << \" \" << (x) << endl;\r\n#define o(x) cerr << #x << \" \" << (x) << \" \";\r\ntemplate<typename T0>\r\nvoid P( T0 t0 ){\r\n\tcerr << t0 << endl;\r\n}\r\ntemplate<typename T0, typename... Ts>\r\nvoid P( T0 t0 , Ts... ts ){\r\n\tcerr << t0 << \" \";\r\n\tP(ts...);\r\n}\r\n#define Msz(x) cerr << \"Sizeof \" << #x << \" \" << sizeof(x)/1024/1024 << \" MB\" << endl;\r\ntemplate<typename T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\\n' ){\r\n\tif( s > t ) return;\r\n\tfor( int i = s ; i < t ; i++ )\r\n\t\tcout << a[i] << sp;\r\n\tcout << a[t] << ed;\r\n\tcout.flush();\r\n}\r\ntemplate<typename T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\\n' ){\r\n\tif( t == -1 ) t = a.size()-1;\r\n\tfor( int i = s ; i <= t ; i++ )\r\n\t\tcout << a[i] << sp;\r\n\tcout << ed;\r\n\tcout.flush();\r\n}\r\n\r\n// Optimize\r\n#define Max(a,b) ((a)>(b)?(a):(b))\r\n#define Min(a,b) ((a)<(b)?(a):(b))\r\n#define Mymax(a,b) (a) = max((a),(b))\r\n#define Mymin(a,b) (a) = min((a),(b))\r\n#define MyMax(a,b) (a) = Max((a),(b))\r\n#define MyMin(a,b) (a) = Min((a),(b))\r\n#define INF (0x3f3f3f3f)\r\n#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))\r\n#define Sqr(x) ((x)*(x))\r\n#define Lowbit(a) ((a)&(-(a)))\r\n///////////////////////////////////////////////////////////////////////////////////////\r\n///////////////////////////////////////////////////////////////////////////////////////\r\nconstexpr int MAXN = 131072;\r\n\r\nint n,m;\r\nvc<int> e[MAXN];\r\n\r\nint in[MAXN], out[MAXN];\r\nvoid InitDfs( int pos , int fa ){\r\n\tstatic int nowTime = 0;\r\n\tin[pos] = ++nowTime;\r\n\tfor( auto v : e[pos] ){\r\n\t\tif( v == fa ) continue;\r\n\t\tInitDfs(v,pos);\r\n\t}\r\n\tout[pos] = nowTime;\r\n}\r\n\r\nstruct FenwickTree{\r\n\tll di[MAXN], idi[MAXN];\r\n\til void Add( int pos , ll diAdd ){\r\n\t\tll idiAdd = pos*diAdd;\r\n\t\tfor( ; pos <= n ; pos += Lowbit(pos) ){\r\n\t\t\tdi[pos] += diAdd;\r\n\t\t\tidi[pos] += idiAdd;\r\n\t\t}\r\n\t}\r\n\til void Add( int l , int r , ll x ){\r\n\t\t// P(\"Add\",l,r,x);\r\n\t\tAdd(l,x); Add(r+1,-x);\r\n\t}\r\n\til ll Sum( int pos ){\r\n\t\tint oPos = pos;\r\n\t\tll diSum = 0, idiSum = 0;\r\n\t\tfor( ; pos ; pos -= Lowbit(pos) ){\r\n\t\t\tdiSum += di[pos];\r\n\t\t\tidiSum += idi[pos];\r\n\t\t}\r\n\t\treturn (oPos+1)*diSum - idiSum;\r\n\t}\r\n\til ll Sum( int l , int r ){\r\n\t\treturn Sum(r) - Sum(l-1);\r\n\t}\r\n}bit;\r\n\r\nstruct ColorKeeper{\r\n\tset<pii> intervals;\r\n\tvoid Color( int l , int r ){\r\n\t\tstatic const auto nullP = intervals.end();\r\n\t\tauto nxtP = intervals.upper_bound(pii{l,r});\r\n\t\tauto preP = nxtP == intervals.begin() ? nullP : prev(nxtP);\r\n\t\tnxtP = nxtP == intervals.end() ? nullP : nxtP;\r\n\t\tif( preP != nullP and preP->S >= r ) return;\r\n\r\n\t\tif( preP != nullP and preP->S < l-1 ) preP = nullP;\r\n\t\tif( nxtP != nullP and nxtP->F > r+1 ) nxtP = nullP;\r\n\r\n\t\tbit.Add(\r\n\t\t\tpreP != nullP ? preP->S+1 : l,\r\n\t\t\tnxtP != nullP ? nxtP->F-1 : r,\r\n\t\t\t1\r\n\t\t);\r\n\t\tif( preP != nullP ){ l = preP->F; intervals.erase(preP); }\r\n\t\tif( nxtP != nullP ){ r = nxtP->S; intervals.erase(nxtP); }\r\n\r\n\t\tintervals.insert({l,r});\r\n\t}\r\n}colorKeepers[MAXN];\r\n\r\nint main(){\r\n\tFILEIO();\r\n\r\n\tRead(n,m);\r\n\tFor(i,n-1){\r\n\t\tiRead2(a,b);\r\n\t\te[a].Eb(b);\r\n\t\te[b].Eb(a);\r\n\t}\r\n\r\n\tInitDfs(1,0);\r\n\r\n\tFor(i,m){\r\n\t\tiRead(op);\r\n\t\tif( op == 1 ){\r\n\t\t\tiRead2(pos,c);\r\n\t\t\tcolorKeepers[c].Color(in[pos],out[pos]);\r\n\t\t}else{\r\n\t\t\tiRead(pos);\r\n\t\t\tll ans = bit.Sum(in[pos],out[pos]);\r\n\t\t\tprintf(\"%lld\\n\",ans);\r\n\t\t}\r\n\t}\r\n\r\n\tEND();\r\n}\r\n", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpcfagxndk/db18de84-f9b3-49dd-891c-b9c1c204b516.cpp: In function ‘void FILEIO(std::string)’:\n/tmp/tmpcfagxndk/db18de84-f9b3-49dd-891c-b9c1c204b516.cpp:136:17: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 136 | Fin((pname+\".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpcfagxndk/db18de84-f9b3-49dd-891c-b9c1c204b516.cpp:137:17: error: ‘Fout’ was not declared in this scope\n 137 | Fout((pname+\".out\").c_str());\n | ^~~~\n/tmp/tmpcfagxndk/db18de84-f9b3-49dd-891c-b9c1c204b516.cpp: In function ‘void FILEIO_OICONTEST(std::string)’:\n/tmp/tmpcfagxndk/db18de84-f9b3-49dd-891c-b9c1c204b516.cpp:143:9: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 143 | Fin((pname+\".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpcfagxndk/db18de84-f9b3-49dd-891c-b9c1c204b516.cpp:145:17: error: ‘Fout’ was not declared in this scope\n 145 | Fout((pname+\".out\").c_str());\n | ^~~~\n" | |
| ], | |
| "tcb_id": "Bessie's Snow Cow", | |
| "query": "# Bessie's Snow Cow\n## 题目描述\n**题目译自 [USACO 2019 December Contest, Platinum](http://usaco.org/index.php?page=dec19results) Problem 2. [Bessie's Snow Cow](http://usaco.org/index.php?page=viewproblem2&cpid=973)**\r\n\r\n农场下雪啦!Bessie 和往年开冬一样在堆雪牛。她之前是个写实派,总是想把他的雪牛堆得和个真牛一样。但今年不一样,受到来自东方的神秘力量的影响,他想来点抽象艺术,因此他想堆成一棵树的样子。这棵树由 $N$ 个雪球,$N-1$ 根树枝构成,每根树枝连接两个雪球,并且每两个雪球之间路径唯一。\r\n\r\nBessie 要给他的雪牛来点细节。因此他给其中一个雪球加了个鼻子,来表示这是他那抽象的牛的头,并且把它称作雪球 $1$。为了让雪牛更好看,他还要给某些雪球来点不同的颜色。于是,他用旧牛奶桶装满了颜料泼到雪牛上。这些颜料分别被编号为 $1\\ldots 10^5$,且每种颜色都无限量供应。\r\n\r\n当 Bessie 把一桶颜料泼到一个雪球上时,这个雪球子树上的所有雪球也会被染色(我们称雪球 $y$ 在雪球 $x$ 的子树里当且仅当雪球 $x$ 处在雪球 $y$ 到雪球 $1$ 的路径上)。Bessie 有着精确的泼颜料技术,因此在泼完一种颜料后,一个雪球上之前被染过的所有颜色依然清晰可见。例如,一个雪球之前显现出来颜色 $[1,2,3]$,然后 Bessie 把装有 $4$ 号颜色的牛奶桶泼上去,那么这个雪球将显现出来颜色 $[1,2,3,4]$。\r\n在泼了几桶颜料以后,Bessie 可能想要了解它的雪牛有多五彩斑斓。令雪球 $x$ 的『颜色丰富度』为这个雪球被染上的不同颜色总数 $c$,当 Bessie 想了解雪球 $x$ 的相关信息时,你应该回答他雪球 $x$ 的子树中所有的雪球的颜色丰富度之和。\r\n\r\n救救孩子吧!\n## 输入格式\n第一行,$N$ 和询问数 $Q$。\r\n\r\n接下来 $N-1$ 行每行两个用空格隔开的数 $a$ 和 $b$,表示雪球 $a$ 和 $b$ 中间有一根树枝相连。\r\n\r\n最后 $Q$ 行每行一个请求,格式及对应含义如下:\r\n- `1 x c`(修改):表示 Bessie 把一桶装有颜色 $c$ 的颜料泼到雪球 $x$ ,使得其子树上所有雪球被染色。\r\n- `2 x`(询问):询问雪球 $x$ 的子树的颜色丰富度之和。\n## 输出格式\n对于每个询问,输出所询问子树的颜色丰富度之和。**为了防止溢出,你需要使用 64 位整数。**\n## 样例\n输入:\n5 18\n1 2\n1 3\n3 4\n3 5\n1 4 1\n2 1\n2 2\n2 3\n2 4\n2 5\n1 5 1\n2 1\n2 2\n2 3\n2 4\n2 5\n1 1 1\n2 1\n2 2\n2 3\n2 4\n2 5\n输出:\n1\n0\n1\n1\n0\n2\n0\n2\n1\n1\n5\n1\n3\n1\n1\n\n执行完第一个修改后雪球 $4$ 被染上了颜色 $1$。\n\n执行完第二个修改后雪球 $4$ 和雪球 $5$ 被染上了颜色 $2$。\n\n执行完第三个修改后所有雪球都被染上了颜色 $1$。\n## 数据范围与提示\n对于 $100\\%$ 的数据,$1\\le N,\\ Q,\\ c \\le 10^5,\\ $$1\\le a,\\ b,\\ x \\le N$", | |
| "sample": { | |
| "input": "5 18\n1 2\n1 3\n3 4\n3 5\n1 4 1\n2 1\n2 2\n2 3\n2 4\n2 5\n1 5 1\n2 1\n2 2\n2 3\n2 4\n2 5\n1 1 1\n2 1\n2 2\n2 3\n2 4\n2 5", | |
| "output": "1\n0\n1\n1\n0\n2\n0\n2\n1\n1\n5\n1\n3\n1\n1" | |
| } | |
| }, | |
| { | |
| "code_id": 0, | |
| "code": "#include<bits/stdc++.h>\nusing namespace std;\nchar s[1000015];\nint main()\n{\nios::sync_with_stdio(0),cin.tie(0),cout.tie(0);\nwhile(cin>>s+1){\n\tif(s[1]=='.')break;\n\tint next[1000015];\n\tint len=strlen(s+1);\n\tint j=0;\n\tfor(int i=2;i<=len;i++){\n\t\twhile(s[i]!=s[j+1]&&j)j--;\n\t\tif(s[i]==s[j+1])j++;\n\t\tnext[i]=j;\n\t}\n\tcout<<len/(len-next[len])<<'\\n';\n}\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp: In function ‘int main()’:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:10: error: no match for ‘operator>>’ (operand types are ‘std::istream’ {aka ‘std::basic_istream<char>’} and ‘char*’)\n 7 | while(cin>>s+1){\n | ~~~^~~~~\n | | |\n | | char*\n | std::istream {aka std::basic_istream<char>}\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:168:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)\n 168 | operator>>(bool& __n)\n | ^~~~~~~~\n/usr/include/c++/11/istream:168:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘char*’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)\n 172 | operator>>(short& __n);\n | ^~~~~~~~\n/usr/include/c++/11/istream:172:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: invalid conversion from ‘char*’ to ‘short int’ [-fpermissive]\n 7 | while(cin>>s+1){\n | ~^~\n | |\n | char*\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind rvalue ‘(short int)(((char*)(& s)) + 1)’ to ‘short int&’\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:175:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)\n 175 | operator>>(unsigned short& __n)\n | ^~~~~~~~\n/usr/include/c++/11/istream:175:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: invalid conversion from ‘char*’ to ‘short unsigned int’ [-fpermissive]\n 7 | while(cin>>s+1){\n | ~^~\n | |\n | char*\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind rvalue ‘(short unsigned int)(((char*)(& s)) + 1)’ to ‘short unsigned int&’\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)\n 179 | operator>>(int& __n);\n | ^~~~~~~~\n/usr/include/c++/11/istream:179:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: invalid conversion from ‘char*’ to ‘int’ [-fpermissive]\n 7 | while(cin>>s+1){\n | ~^~\n | |\n | char*\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind rvalue ‘(int)(((char*)(& s)) + 1)’ to ‘int&’\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:182:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)\n 182 | operator>>(unsigned int& __n)\n | ^~~~~~~~\n/usr/include/c++/11/istream:182:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: invalid conversion from ‘char*’ to ‘unsigned int’ [-fpermissive]\n 7 | while(cin>>s+1){\n | ~^~\n | |\n | char*\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind rvalue ‘(unsigned int)(((char*)(& s)) + 1)’ to ‘unsigned int&’\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:186:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)\n 186 | operator>>(long& __n)\n | ^~~~~~~~\n/usr/include/c++/11/istream:186:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: invalid conversion from ‘char*’ to ‘long int’ [-fpermissive]\n 7 | while(cin>>s+1){\n | ~^~\n | |\n | char*\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind rvalue ‘(long int)(((char*)(& s)) + 1)’ to ‘long int&’\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:190:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)\n 190 | operator>>(unsigned long& __n)\n | ^~~~~~~~\n/usr/include/c++/11/istream:190:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: invalid conversion from ‘char*’ to ‘long unsigned int’ [-fpermissive]\n 7 | while(cin>>s+1){\n | ~^~\n | |\n | char*\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind rvalue ‘(long unsigned int)(((char*)(& s)) + 1)’ to ‘long unsigned int&’\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:195:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)\n 195 | operator>>(long long& __n)\n | ^~~~~~~~\n/usr/include/c++/11/istream:195:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: invalid conversion from ‘char*’ to ‘long long int’ [-fpermissive]\n 7 | while(cin>>s+1){\n | ~^~\n | |\n | char*\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind rvalue ‘(long long int)(((char*)(& s)) + 1)’ to ‘long long int&’\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:199:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)\n 199 | operator>>(unsigned long long& __n)\n | ^~~~~~~~\n/usr/include/c++/11/istream:199:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: invalid conversion from ‘char*’ to ‘long long unsigned int’ [-fpermissive]\n 7 | while(cin>>s+1){\n | ~^~\n | |\n | char*\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind rvalue ‘(long long unsigned int)(((char*)(& s)) + 1)’ to ‘long long unsigned int&’\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:235:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)\n 235 | operator>>(void*& __p)\n | ^~~~~~~~\n/usr/include/c++/11/istream:235:7: note: conversion of argument 1 would be ill-formed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: error: cannot bind non-const lvalue reference of type ‘void*&’ to an rvalue of type ‘void*’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:120:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’\n 120 | operator>>(__istream_type& (*__pf)(__istream_type&))\n | ^~~~~~~~\n/usr/include/c++/11/istream:120:36: note: no known conversion for argument 1 from ‘char*’ to ‘std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)’ {aka ‘std::basic_istream<char>& (*)(std::basic_istream<char>&)’}\n 120 | operator>>(__istream_type& (*__pf)(__istream_type&))\n | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/istream:124:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__ios_type& (*)(std::basic_istream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>; std::basic_istream<_CharT, _Traits>::__ios_type = std::basic_ios<char>]’\n 124 | operator>>(__ios_type& (*__pf)(__ios_type&))\n | ^~~~~~~~\n/usr/include/c++/11/istream:124:32: note: no known conversion for argument 1 from ‘char*’ to ‘std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)’ {aka ‘std::basic_ios<char>& (*)(std::basic_ios<char>&)’}\n 124 | operator>>(__ios_type& (*__pf)(__ios_type&))\n | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/istream:131:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’\n 131 | operator>>(ios_base& (*__pf)(ios_base&))\n | ^~~~~~~~\n/usr/include/c++/11/istream:131:30: note: no known conversion for argument 1 from ‘char*’ to ‘std::ios_base& (*)(std::ios_base&)’\n 131 | operator>>(ios_base& (*__pf)(ios_base&))\n | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~\n/usr/include/c++/11/istream:214:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’\n 214 | operator>>(float& __f)\n | ^~~~~~~~\n/usr/include/c++/11/istream:214:25: note: no known conversion for argument 1 from ‘char*’ to ‘float&’\n 214 | operator>>(float& __f)\n | ~~~~~~~^~~\n/usr/include/c++/11/istream:218:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’\n 218 | operator>>(double& __f)\n | ^~~~~~~~\n/usr/include/c++/11/istream:218:26: note: no known conversion for argument 1 from ‘char*’ to ‘double&’\n 218 | operator>>(double& __f)\n | ~~~~~~~~^~~\n/usr/include/c++/11/istream:222:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’\n 222 | operator>>(long double& __f)\n | ^~~~~~~~\n/usr/include/c++/11/istream:222:31: note: no known conversion for argument 1 from ‘char*’ to ‘long double&’\n 222 | operator>>(long double& __f)\n | ~~~~~~~~~~~~~^~~\n/usr/include/c++/11/istream:259:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]’\n 259 | operator>>(__streambuf_type* __sb);\n | ^~~~~~~~\n/usr/include/c++/11/istream:259:36: note: no known conversion for argument 1 from ‘char*’ to ‘std::basic_istream<char>::__streambuf_type*’ {aka ‘std::basic_streambuf<char>*’}\n 259 | operator>>(__streambuf_type* __sb);\n | ~~~~~~~~~~~~~~~~~~^~~~\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:45,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/cstddef:132:5: note: candidate: ‘template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(std::byte, _IntegerType)’\n 132 | operator>>(byte __b, _IntegerType __shift) noexcept\n | ^~~~~~~~\n/usr/include/c++/11/cstddef:132:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:7: note: cannot convert ‘std::cin’ (type ‘std::istream’ {aka ‘std::basic_istream<char>’}) to type ‘std::byte’\n 7 | while(cin>>s+1){\n | ^~~\nIn file included from /usr/include/c++/11/string:56,\n from /usr/include/c++/11/bits/locale_classes.h:40,\n from /usr/include/c++/11/bits/ios_base.h:41,\n from /usr/include/c++/11/ios:42,\n from /usr/include/c++/11/istream:38,\n from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/basic_string.tcc:1485:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::__cxx11::basic_string<_CharT, _Traits, _Allocator>&)’\n 1485 | operator>>(basic_istream<_CharT, _Traits>& __in,\n | ^~~~~~~~\n/usr/include/c++/11/bits/basic_string.tcc:1485:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::__cxx11::basic_string<_CharT, _Traits, _Allocator>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/istream:1016,\n from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/istream.tcc:958:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&)’\n 958 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)\n | ^~~~~~~~\n/usr/include/c++/11/bits/istream.tcc:958:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: deduced conflicting types for parameter ‘_CharT’ (‘char’ and ‘char*’)\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:756:5: note: candidate: ‘template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char&)’\n 756 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)\n | ^~~~~~~~\n/usr/include/c++/11/istream:756:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: note: cannot convert ‘(((char*)(& s)) + 1)’ (type ‘char*’) to type ‘unsigned char&’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:761:5: note: candidate: ‘template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char&)’\n 761 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)\n | ^~~~~~~~\n/usr/include/c++/11/istream:761:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: note: cannot convert ‘(((char*)(& s)) + 1)’ (type ‘char*’) to type ‘signed char&’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:859:5: note: candidate: ‘template<class _CharT, class _Traits, long unsigned int _Num> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT (&)[_Num])’\n 859 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT (&__s)[_Num])\n | ^~~~~~~~\n/usr/include/c++/11/istream:859:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘_CharT [_Num]’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:868:5: note: candidate: ‘template<class _Traits, long unsigned int _Num> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, unsigned char (&)[_Num])’\n 868 | operator>>(basic_istream<char, _Traits>& __in, unsigned char (&__s)[_Num])\n | ^~~~~~~~\n/usr/include/c++/11/istream:868:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘unsigned char [_Num]’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:873:5: note: candidate: ‘template<class _Traits, long unsigned int _Num> std::basic_istream<char, _Traits>& std::operator>>(std::basic_istream<char, _Traits>&, signed char (&)[_Num])’\n 873 | operator>>(basic_istream<char, _Traits>& __in, signed char (&__s)[_Num])\n | ^~~~~~~~\n/usr/include/c++/11/istream:873:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘signed char [_Num]’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/istream:1006:5: note: candidate: ‘template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)’\n 1006 | operator>>(_Istream&& __is, _Tp&& __x)\n | ^~~~~~~~\n/usr/include/c++/11/istream:1006:5: note: template argument deduction/substitution failed:\n/usr/include/c++/11/istream: In substitution of ‘template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_istream<char>&; _Tp = char*]’:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: required from here\n/usr/include/c++/11/istream:1006:5: error: template constraint failure for ‘template<class _Is, class _Tp> requires (__derived_from_ios_base<_Is>) && requires(_Is& __is, _Tp&& __t) {__is >> (forward<_Tp>)(__t);} using __rvalue_stream_extraction_t = _Is&&’\n/usr/include/c++/11/istream:1006:5: note: constraints not satisfied\nIn file included from /usr/include/c++/11/istream:39,\n from /usr/include/c++/11/sstream:38,\n from /usr/include/c++/11/complex:45,\n from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/ostream: In substitution of ‘template<class _Is, class _Tp> requires (__derived_from_ios_base<_Is>) && requires(_Is& __is, _Tp&& __t) {__is >> (forward<_Tp>)(__t);} using __rvalue_stream_extraction_t = _Is&& [with _Is = std::basic_istream<char>&; _Tp = char*]’:\n/usr/include/c++/11/istream:1006:5: required by substitution of ‘template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_istream<char>&; _Tp = char*]’\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: required from here\n/usr/include/c++/11/ostream:717:13: required for the satisfaction of ‘__derived_from_ios_base<_Is>’ [with _Is = std::basic_istream<char, std::char_traits<char> >&]\n/usr/include/c++/11/ostream:717:39: note: the expression ‘is_class_v<_Tp> [with _Tp = std::basic_istream<char, std::char_traits<char> >&]’ evaluated to ‘false’\n 717 | concept __derived_from_ios_base = is_class_v<_Tp>\n | ^~~~~~~~~~~~~~~\nIn file included from /usr/include/c++/11/ccomplex:39,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/complex:501:5: note: candidate: ‘template<class _Tp, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::complex<_Tp>&)’\n 501 | operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)\n | ^~~~~~~~\n/usr/include/c++/11/complex:501:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::complex<_Tp>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:66,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bitset:1472:5: note: candidate: ‘template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::bitset<_Nb>&)’\n 1472 | operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)\n | ^~~~~~~~\n/usr/include/c++/11/bitset:1472:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::bitset<_Nb>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/iomanip:71:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Resetiosflags)’\n 71 | operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f)\n | ^~~~~~~~\n/usr/include/c++/11/iomanip:71:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: note: cannot convert ‘(((char*)(& s)) + 1)’ (type ‘char*’) to type ‘std::_Resetiosflags’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/iomanip:101:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setiosflags)’\n 101 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f)\n | ^~~~~~~~\n/usr/include/c++/11/iomanip:101:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: note: cannot convert ‘(((char*)(& s)) + 1)’ (type ‘char*’) to type ‘std::_Setiosflags’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/iomanip:132:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setbase)’\n 132 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f)\n | ^~~~~~~~\n/usr/include/c++/11/iomanip:132:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: note: cannot convert ‘(((char*)(& s)) + 1)’ (type ‘char*’) to type ‘std::_Setbase’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/iomanip:170:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setfill<_CharT>)’\n 170 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f)\n | ^~~~~~~~\n/usr/include/c++/11/iomanip:170:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::_Setfill<_CharT>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/iomanip:200:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setprecision)’\n 200 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f)\n | ^~~~~~~~\n/usr/include/c++/11/iomanip:200:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: note: cannot convert ‘(((char*)(& s)) + 1)’ (type ‘char*’) to type ‘std::_Setprecision’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/iomanip:230:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Setw)’\n 230 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f)\n | ^~~~~~~~\n/usr/include/c++/11/iomanip:230:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: note: cannot convert ‘(((char*)(& s)) + 1)’ (type ‘char*’) to type ‘std::_Setw’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/iomanip:264:5: note: candidate: ‘template<class _CharT, class _Traits, class _MoneyT> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Get_money<_MoneyT>)’\n 264 | operator>>(basic_istream<_CharT, _Traits>& __is, _Get_money<_MoneyT> __f)\n | ^~~~~~~~\n/usr/include/c++/11/iomanip:264:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::_Get_money<_MoneyT>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:72,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/iomanip:418:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::_Get_time<_CharT>)’\n 418 | operator>>(basic_istream<_CharT, _Traits>& __is, _Get_time<_CharT> __f)\n | ^~~~~~~~\n/usr/include/c++/11/iomanip:418:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::_Get_time<_CharT>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/valarray:603,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: candidate: ‘template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__shift_right, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__shift_right, typename _Dom1::value_type>::result_type> std::operator>>(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::_Expr<_Dom2, typename _Dom2::value_type>&)’\n 414 | _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right)\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/valarray:603,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: candidate: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__shift_right, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__shift_right, typename _Dom1::value_type>::result_type> std::operator>>(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)’\n 414 | _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right)\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/valarray:603,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: candidate: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__shift_right, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__shift_right, typename _Dom1::value_type>::result_type> std::operator>>(const typename _Dom::value_type&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)’\n 414 | _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right)\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/valarray:603,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: candidate: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__shift_right, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__shift_right, typename _Dom1::value_type>::result_type> std::operator>>(const std::_Expr<_Dom1, typename _Dom1::value_type>&, const std::valarray<typename _Dom::value_type>&)’\n 414 | _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right)\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/valarray:603,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: candidate: ‘template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__shift_right, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__shift_right, typename _Dom1::value_type>::result_type> std::operator>>(const std::valarray<typename _Dom::value_type>&, const std::_Expr<_Dom1, typename _Dom1::value_type>&)’\n 414 | _DEFINE_EXPR_BINARY_OPERATOR(>>, struct std::__shift_right)\n | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/bits/valarray_after.h:414:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘const std::_Expr<_Dom1, typename _Dom1::value_type>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/valarray:1195:1: note: candidate: ‘template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__shift_right, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__shift_right, _Tp>::result_type> std::operator>>(const std::valarray<_Tp>&, const std::valarray<_Tp>&)’\n 1195 | _DEFINE_BINARY_OPERATOR(>>, __shift_right)\n | ^~~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/valarray:1195:1: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘const std::valarray<_Tp>’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/valarray:1195:1: note: candidate: ‘template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__shift_right, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__shift_right, _Tp>::result_type> std::operator>>(const std::valarray<_Tp>&, const typename std::valarray<_Tp>::value_type&)’\n 1195 | _DEFINE_BINARY_OPERATOR(>>, __shift_right)\n | ^~~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/valarray:1195:1: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: ‘std::istream’ {aka ‘std::basic_istream<char>’} is not derived from ‘const std::valarray<_Tp>’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/valarray:1195:1: note: candidate: ‘template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__shift_right, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__shift_right, _Tp>::result_type> std::operator>>(const typename std::valarray<_Tp>::value_type&, const std::valarray<_Tp>&)’\n 1195 | _DEFINE_BINARY_OPERATOR(>>, __shift_right)\n | ^~~~~~~~~~~~~~~~~~~~~~~\n/usr/include/c++/11/valarray:1195:1: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘const std::valarray<_Tp>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:921:5: note: candidate: ‘template<class _IntType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::uniform_int_distribution<_IntType>&)’\n 921 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:921:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::uniform_int_distribution<_IntType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:982:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::uniform_real_distribution<_IntType>&)’\n 982 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:982:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::uniform_real_distribution<_IntType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2167:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::cauchy_distribution<_RealType>&)’\n 2167 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2167:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::cauchy_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:49,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.h:3722:5: note: candidate: ‘template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::bernoulli_distribution&)’\n 3722 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.h:3722:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:13: note: cannot convert ‘(((char*)(& s)) + 1)’ (type ‘char*’) to type ‘std::bernoulli_distribution&’\n 7 | while(cin>>s+1){\n | ~^~\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:1124:5: note: candidate: ‘template<class _IntType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::geometric_distribution<_IntType>&)’\n 1124 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:1124:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::geometric_distribution<_IntType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:1775:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::exponential_distribution<_RealType>&)’\n 1775 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:1775:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::exponential_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2561:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::weibull_distribution<_RealType>&)’\n 2561 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2561:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::weibull_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2635:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::extreme_value_distribution<_RealType>&)’\n 2635 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2635:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::extreme_value_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:175:5: note: candidate: ‘template<class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::linear_congruential_engine<_UIntType, __a, __c, __m>&)’\n 175 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:175:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::linear_congruential_engine<_UIntType, __a, __c, __m>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:501:5: note: candidate: ‘template<class _UIntType1, long unsigned int __w1, long unsigned int __n1, long unsigned int __m1, long unsigned int __r1, _UIntType1 __a1, long unsigned int __u1, _UIntType1 __d1, long unsigned int __s1, _UIntType1 __b1, long unsigned int __t1, _UIntType1 __c1, long unsigned int __l1, _UIntType1 __f1, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>&)’\n 501 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:501:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:652:5: note: candidate: ‘template<class _UIntType, long unsigned int __w, long unsigned int __s, long unsigned int __r, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::subtract_with_carry_engine<_UIntType, __w, __s, __r>&)’\n 652 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:652:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::subtract_with_carry_engine<_UIntType, __w, __s, __r>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:718:5: note: candidate: ‘template<class _RandomNumberEngine, long unsigned int __p, long unsigned int __r, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::discard_block_engine<_RandomNumberEngine, __p, __r>&)’\n 718 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:718:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::discard_block_engine<_RandomNumberEngine, __p, __r>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:881:5: note: candidate: ‘template<class _RandomNumberEngine, long unsigned int __k, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::shuffle_order_engine<_RandomNumberEngine, __k>&)’\n 881 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:881:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::shuffle_order_engine<_RandomNumberEngine, __k>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:1239:5: note: candidate: ‘template<class _IntType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::negative_binomial_distribution<_IntType>&)’\n 1239 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:1239:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::negative_binomial_distribution<_IntType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:1449:5: note: candidate: ‘template<class _IntType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::poisson_distribution<_IntType>&)’\n 1449 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:1449:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::poisson_distribution<_IntType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:1716:5: note: candidate: ‘template<class _IntType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::binomial_distribution<_IntType>&)’\n 1716 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:1716:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::binomial_distribution<_IntType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:1945:5: note: candidate: ‘template<class _RealType1, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::normal_distribution<_RealType>&)’\n 1945 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:1945:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::normal_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2010:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::lognormal_distribution<_RealType>&)’\n 2010 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2010:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::lognormal_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2081:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::chi_squared_distribution<_RealType>&)’\n 2081 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2081:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::chi_squared_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2243:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::fisher_f_distribution<_RealType>&)’\n 2243 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2243:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::fisher_f_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2316:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::student_t_distribution<_RealType>&)’\n 2316 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2316:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::student_t_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2486:5: note: candidate: ‘template<class _RealType1, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::gamma_distribution<_RealType>&)’\n 2486 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2486:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::gamma_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:2794:5: note: candidate: ‘template<class _IntType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::discrete_distribution<_IntType>&)’\n 2794 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:2794:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::discrete_distribution<_IntType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:3001:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::piecewise_constant_distribution<_RealType>&)’\n 3001 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:3001:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::piecewise_constant_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\nIn file included from /usr/include/c++/11/random:51,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:108,\n from /tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:1:\n/usr/include/c++/11/bits/random.tcc:3207:5: note: candidate: ‘template<class _RealType, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, std::piecewise_linear_distribution<_RealType>&)’\n 3207 | operator>>(std::basic_istream<_CharT, _Traits>& __is,\n | ^~~~~~~~\n/usr/include/c++/11/bits/random.tcc:3207:5: note: template argument deduction/substitution failed:\n/tmp/tmp9jj49rr3/fe80fd48-9abe-4a68-a532-68eb78ebdbad.cpp:7:14: note: mismatched types ‘std::piecewise_linear_distribution<_RealType>’ and ‘char*’\n 7 | while(cin>>s+1){\n | ^\n" | |
| ], | |
| "tcb_id": "Power Strings", | |
| "query": "# Power Strings\n题目描述\r\n\r\n给定若干个长度 $ \\le 10^6 $ 的字符串,询问每个字符串最多是由多少个相同的子字符串重复连接而成的。如:`ababab` 则最多有 $3$ 个 `ab` 连接而成。\n## 输入格式\n输入若干行,每行有一个字符串。特别的,字符串可能为 `.` 即一个半角句号,此时输入结束。\n## 样例\n输入:\nabcd\naaaa\nababab\n.\n输出:\n1\n4\n3\n\n\n## 数据范围与提示\n字符串长度 $ \\le 10^6 $。", | |
| "sample": { | |
| "input": "abcd\naaaa\nababab\n.", | |
| "output": "1\n4\n3" | |
| } | |
| }, | |
| { | |
| "code_id": 6, | |
| "code": "#include <bits/stdc++.h>\nusing namespace std;\n\n#define fopen \\\n#define ios \\\n ios::sync_with_stdio(0); \\\n cin.tie(0);\n\n#define i64 long long\n#define pii pair<int, int>\n#define pdd pair<double, double>\n#define ld long double\n#define ls(x) (x << 1)\n#define rs(x) (x << 1 | 1)\n#define lowbit(x) (x & -x)\n#define de(x) cout << #x << \" = \" << x << '\\n'\n#define MAXP 20\n\n#define int i64\n\nconst int N = 1e6 + 10, M = 4e5 + 10, base = 29, mod = 1e9 + 7;\nconst double eps = 1e-12;\nconst double PI = acos(-1);\n\nchar s[N];\nint n;\n\nint qsm(int a, int b)\n{\n int res = 1;\n while (b)\n {\n if (b & 1)\n res = 1ll * res * a % mod;\n a = 1ll * a * a % mod;\n b >>= 1;\n }\n return res;\n}\n\nint pre[N], powb[N];\nint pri[N], cnt;\nbool vis[N];\nvoid init()\n{\n powb[0] = 1;\n for (int i = 1; i <= n; i++)\n {\n pre[i] = (1ll * pre[i - 1] * base + s[i] - 'a' + 1) % mod;\n powb[i] = 1ll * powb[i - 1] * base % mod;\n }\n for (int i = 2; i < N; i++)\n {\n if (!vis[i])\n pri[++cnt] = i;\n for (int j = 1; j <= cnt && i * pri[j] < N; j++)\n {\n int p = pri[j], t = i * p;\n vis[t] = 1;\n if (i % p == 0)\n break;\n }\n }\n}\n\nint getVAl(int l, int r)\n{\n int res = (pre[r] - 1ll * pre[l - 1] * powb[r - l + 1] % mod + mod) % mod;\n return res;\n}\n\nint len, ps[N];\nvoid getPris(int x)\n{\n len = 0;\n for (int i = 1; i <= cnt && pri[i] * pri[i] <= x; i++)\n {\n int p = pri[i];\n if (x % p == 0)\n ps[++len] = p;\n while (x % p == 0)\n x /= p;\n }\n if (x > 1)\n ps[++len] = x;\n}\n\nbool check(int l, int r, int len)\n{\n return getVAl(l, r - len) == getVAl(l + len, r);\n}\n\nvoid solve()\n{\n cin >> n >> s + 1;\n init();\n int q;\n cin >> q;\n while (q--)\n {\n int a, b;\n cin >> a >> b;\n int x = b - a + 1;\n getPris(x);\n for (int i = 1; i <= len; i++)\n {\n while (x > 1 && check(a, b, x / ps[i]))\n x /= ps[i];\n }\n cout << x << '\\n';\n }\n}\n\nsigned main()\n{\n ios;\n // fopen;\n\n int t = 1;\n srand(time(0));\n // cout << fixed << setprecision(12);\n\n // cin >> t;\n for (int i = 1; i <= t; i++)\n {\n solve();\n }\n\n return 0;\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpi72itvgr/ab030dea-885b-4f8b-ae9c-1d516f1abbaf.cpp: In function ‘int main()’:\n/tmp/tmpi72itvgr/ab030dea-885b-4f8b-ae9c-1d516f1abbaf.cpp:116:5: error: declaration does not declare anything [-fpermissive]\n 116 | ios;\n | ^~~\n" | |
| ], | |
| "tcb_id": "可怕的诗 A Horrible Poem", | |
| "query": "# 可怕的诗 A Horrible Poem\n## 题目描述\n给定由小写英文字母组成的字符串 $S$,有 $q$ 个询问,每次询问给定 $S$ 的一个子串,求其最短循环节。\r\n\r\n如果字符串 $A$ 可以由字符串 $B$ 重复若干次得到,则字符串 $B$ 是字符串 $A$ 的一个循环节。\n## 输入格式\n第一行一个正整数 $n (n \\le 500\\ 000)$,表示字符串 $S$ 的长度。\r\n\r\n接下来一行 $n$ 个小写英文字母,表示字符串 $S$.\r\n\r\n接下来一行一个正整数 $q (q \\le 2\\ 000\\ 000)$,表示询问个数。\r\n\r\n接下来 $q$ 行每行两个正整数 $a,b (1 \\le a \\le b \\le n)$,表示询问字符串 $S$ 从第 $a$ 个字母到第 $b$ 个字母组成的子串的最短循环节长度。\n## 输出格式\n输出 $q$ 行,每行一个正整数,表示询问的答案。\n## 样例\n输入:\n8\naaabcabc\n3\n1 3\n3 8\n4 8\n输出:\n1\n3\n5\n\n", | |
| "sample": { | |
| "input": "8\naaabcabc\n3\n1 3\n3 8\n4 8", | |
| "output": "1\n3\n5" | |
| } | |
| }, | |
| { | |
| "code_id": 2, | |
| "code": "#include<bits/stdc++.h>\nusing namespace std;\nconst int maxn=200100;\nchar s[maxn];int n,na,nb,m,la[maxn],ra[maxn],lb[maxn],rb[maxn];\nint ch[maxn<<1][26],link[maxn<<1],len[maxn<<1],lst,samtot,fa[maxn<<1][20],pos[maxn];\ninline void extend(int x)\n{\n\tint cur=++samtot,p=lst;\n\tlen[cur]=len[p]+1;\n\twhile(p&&ch[p][x]==0) ch[p][x]=cur,p=link[p];\n\tif(!p) link[cur]=1;\n\telse\n\t{\n\t\tint q=ch[p][x];\n\t\tif(len[q]==len[p]+1) link[cur]=q;\n\t\telse\n\t\t{\n\t\t\tint clone=++samtot;\n\t\t\tmemcpy(ch[clone],ch[q],sizeof(ch[q]));\n\t\t\tlink[clone]=link[q];\n\t\t\tlen[clone]=len[p]+1;\n\t\t\twhile(p&&ch[p][x]==q) ch[p][x]=clone,p=link[p];\n\t\t\tlink[cur]=link[q]=clone;\n\t\t}\n\t}\n\tlst=cur;\n}\nstruct Node {int len,id,isa;};\nvector<Node> V[maxn<<1];\ninline int cmp(const Node &a,const Node &b){return a.len<b.len;}\nint head[maxn*5],nxt[maxn*20],ver[maxn*20],tot,q[maxn*4],he,ta,ind[maxn*5];long long val[maxn*5];\ninline void addedge(int a,int b){nxt[++tot]=head[a];ver[tot]=b;head[a]=tot;ind[b]++;}\ninline int getv(int id)\n{\n\tif(id<=samtot+na+nb) return 0;\n\treturn ra[id-samtot-na-nb]-la[id-samtot-na-nb]+1;\n}\nint tlen[maxn],tid[maxn];\ninline void solve()\n{\n\tscanf(\"%s\",s+1);n=strlen(s+1);\n\treverse(s+1,s+n+1);\n\tfor(int i=1;i<=n*5;i++) head[i]=ind[i]=val[i]=0;tot=0;\n\tfor(int i=1;i<=n+n;i++) memset(ch[i],0,sizeof(ch[i])),link[i]=len[i]=0;\n\tsamtot=lst=1;\n\tfor(int i=1;i<=n;i++) extend(s[i]-'a'),pos[i]=lst;\n\tfor(int i=1;i<=samtot;i++) fa[i][0]=link[i];\n\tfor(int j=1;j<20;j++) for(int i=1;i<=samtot;i++) fa[i][j]=fa[fa[i][j-1]][j-1];\n\tfor(int i=1;i<=n+n;i++) V[i].clear();\n\tscanf(\"%d\",&na);\n\tfor(int i=1;i<=na;i++)\n\t{\n\t\tscanf(\"%d%d\",la+i,ra+i),la[i]=n-la[i]+1,ra[i]=n-ra[i]+1;\n\t\tswap(la[i],ra[i]);int now=pos[ra[i]];\n\t\tfor(int j=19;j>=0;j--) if(len[fa[now][j]]>=ra[i]-la[i]+1) now=fa[now][j];\n\t\tV[now].push_back((Node){ra[i]-la[i]+1,i,1});\n\t}\n\tscanf(\"%d\",&nb);\n\tfor(int i=1;i<=nb;i++)\n\t{\n\t\tscanf(\"%d%d\",lb+i,rb+i),lb[i]=n-lb[i]+1,rb[i]=n-rb[i]+1;\n\t\tswap(lb[i],rb[i]);int now=pos[rb[i]];\n\t\tfor(int j=19;j>=0;j--) if(len[fa[now][j]]>=rb[i]-lb[i]+1) now=fa[now][j];\n\t\tV[now].push_back((Node){rb[i]-lb[i]+1,i,0});\n\t}\n\tfor(int i=2;i<=samtot;i++)\n\t{\n\t\tsort(V[i].begin(),V[i].end(),cmp);\n\t\tint lstv=link[i],ttt=0;\n\t\tfor(int j=0;j<(int)V[i].size();j++) if(V[i][j].isa)\n\t\t{\n\t\t\taddedge(lstv,V[i][j].id+samtot);\n\t\t\tttt++;tlen[ttt]=V[i][j].len;tid[ttt]=lstv=V[i][j].id+samtot;\n\t\t}\n\t\tttt++;tlen[ttt]=1000000000;tid[ttt]=i;\n\t\tint nowpos=1;\n\t\taddedge(lstv,i);\n\t\tfor(int j=0;j<(int)V[i].size();j++) if(!V[i][j].isa)\n\t\t{\n\t\t\tint nowlen=V[i][j].len;\n\t\t\twhile(tlen[nowpos]<nowlen) nowpos++;\n\t\t\taddedge(V[i][j].id+samtot+na,tid[nowpos]);\n\t\t}\n\t}\n\tscanf(\"%d\",&m);\n\tfor(int i=1,a,b;i<=m;i++) scanf(\"%d%d\",&a,&b),addedge(samtot+na+nb+a,samtot+na+b);\n\tfor(int i=1;i<=na;i++) addedge(samtot+i,samtot+na+nb+i);\n\the=1;ta=0;\n\tfor(int i=1;i<=samtot+na+na+nb;i++) if(!ind[i]) q[++ta]=i,val[i]=getv(i);\n\twhile(he<=ta)\n\t{\n\t\tint x=q[he++];\n\t\tfor(int i=head[x];i;i=nxt[i])\n\t\t{\n\t\t\tint y=ver[i];\n\t\t\tval[y]=max(val[y],getv(y)+val[x]);\n\t\t\tif(--ind[y]==0) q[++ta]=y;\n\t\t}\n\t}\n\tfor(int i=samtot+na+nb+1;i<=samtot+na+na+nb;i++) if(ind[i]) return (void)puts(\"-1\");\n\tlong long ans=0;\n\tfor(int i=1;i<=samtot+na+na+nb;i++) ans=max(ans,val[i]);\n\tprintf(\"%lld\\n\",ans);\n}\nint main()\n{\n\tint T;scanf(\"%d\",&T);\n\twhile(T--) solve();\n\treturn 0;\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:5:33: error: ‘int link [400200]’ redeclared as different kind of entity\n 5 | int ch[maxn<<1][26],link[maxn<<1],len[maxn<<1],lst,samtot,fa[maxn<<1][20],pos[maxn];\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,\n from /usr/include/signal.h:328,\n from /usr/include/c++/11/csignal:42,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:43,\n from /tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:1:\n/usr/include/unistd.h:819:12: note: previous declaration ‘int link(const char*, const char*)’\n 819 | extern int link (const char *__from, const char *__to)\n | ^~~~\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp: In function ‘void extend(int)’:\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:10:52: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 10 | while(p&&ch[p][x]==0) ch[p][x]=cur,p=link[p];\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:10:52: error: invalid conversion from ‘int (*)(const char*, const char*) throw ()’ {aka ‘int (*)(const char*, const char*)’} to ‘int’ [-fpermissive]\n 10 | while(p&&ch[p][x]==0) ch[p][x]=cur,p=link[p];\n | ~~~~~~^\n | |\n | int (*)(const char*, const char*) throw () {aka int (*)(const char*, const char*)}\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:11:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 11 | if(!p) link[cur]=1;\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:11:25: error: assignment of read-only location ‘*(link + ((sizetype)cur))’\n 11 | if(!p) link[cur]=1;\n | ~~~~~~~~~^~\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:15:46: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 15 | if(len[q]==len[p]+1) link[cur]=q;\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:15:47: error: assignment of read-only location ‘*(link + ((sizetype)cur))’\n 15 | if(len[q]==len[p]+1) link[cur]=q;\n | ~~~~~~~~~^~\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:20:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 20 | link[clone]=link[q];\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:20:43: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 20 | link[clone]=link[q];\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:20:36: error: assignment of read-only location ‘*(link + ((sizetype)clone))’\n 20 | link[clone]=link[q];\n | ~~~~~~~~~~~^~~~~~~~\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:22:70: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 22 | while(p&&ch[p][x]==q) ch[p][x]=clone,p=link[p];\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:22:70: error: invalid conversion from ‘int (*)(const char*, const char*) throw ()’ {aka ‘int (*)(const char*, const char*)’} to ‘int’ [-fpermissive]\n 22 | while(p&&ch[p][x]==q) ch[p][x]=clone,p=link[p];\n | ~~~~~~^\n | |\n | int (*)(const char*, const char*) throw () {aka int (*)(const char*, const char*)}\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:23:33: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 23 | link[cur]=link[q]=clone;\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:23:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 23 | link[cur]=link[q]=clone;\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:23:42: error: assignment of read-only location ‘*(link + ((sizetype)q))’\n 23 | link[cur]=link[q]=clone;\n | ~~~~~~~^~~~~~\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp: In function ‘void solve()’:\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:44:69: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 44 | for(int i=1;i<=n+n;i++) memset(ch[i],0,sizeof(ch[i])),link[i]=len[i]=0;\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:44:70: error: assignment of read-only location ‘*(link + ((sizetype)i))’\n 44 | for(int i=1;i<=n+n;i++) memset(ch[i],0,sizeof(ch[i])),link[i]=len[i]=0;\n | ~~~~~~~^~~~~~~~~\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:47:51: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 47 | for(int i=1;i<=samtot;i++) fa[i][0]=link[i];\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:47:51: error: invalid conversion from ‘int (*)(const char*, const char*) throw ()’ {aka ‘int (*)(const char*, const char*)’} to ‘int’ [-fpermissive]\n 47 | for(int i=1;i<=samtot;i++) fa[i][0]=link[i];\n | ~~~~~~^\n | |\n | int (*)(const char*, const char*) throw () {aka int (*)(const char*, const char*)}\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:69:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 69 | int lstv=link[i],ttt=0;\n | ^\n/tmp/tmpqlfqjo9e/0a5ddd62-3c4e-4078-9308-4d0605bfa7ed.cpp:69:32: error: invalid conversion from ‘int (*)(const char*, const char*) throw ()’ {aka ‘int (*)(const char*, const char*)’} to ‘int’ [-fpermissive]\n 69 | int lstv=link[i],ttt=0;\n | ^\n | |\n | int (*)(const char*, const char*) throw () {aka int (*)(const char*, const char*)}\n" | |
| ], | |
| "tcb_id": "字符串问题", | |
| "query": "字符串问题\n题目描述\n#### 题目背景\r\nYazid 和 Tiffany 喜欢字符串问题。在这里,我们将给你介绍一些关于字符串的基本概念。\r\n\r\n对于一个字符串 $S$, 我们定义 $\\lvert S\\rvert$ 表示 $S$ 的长度。\r\n\r\n接着,我们定义该串的子串 $S\\left( {L,R}\\right)$ 表示由 $S$ 中从左往右数,第 $L$ 个字符到第 $R$ 个字符依次连接形成的字符串,特别地,如果 $L < 1$ 或 $R > \\lvert S\\rvert$ 或 $L > R$,则 $S\\left( {L,R}\\right)$ 表示空串。\r\n\r\n我们说两个字符串相等,当且仅当它们的长度相等,且从左至右各位上的字符依次相同。\r\n\r\n我们说一个字符串 $T$ 是 $S$ 的**前缀**,当且仅当 $S\\left( 1,\\lvert T\\rvert\\right)=T$。\r\n\r\n两个字符串 $S,T$ 相加 $S+T$ 表示的是在 $S$ 后紧挨着写下 $T$ 得到的长度为 $\\lvert S\\rvert+\\lvert T\\rvert$ 的字符串。\r\n\r\n#### 题目描述\r\n现有一个字符串 $S$。\r\n\r\nTiffany 将从中划出 $n_a$ 个子串作为 A 类串,第 $i$ 个($1\\leq i\\leq n_a$)为 $A_i = S\\left( la_i, ra_i\\right)$。\r\n\r\n类似地,Yazid 将划出 $n_b$ 个子串作为 B 类串,第 $i$ 个($1\\leq i\\leq n_b$)为 $B_i = S\\left( lb_i, rb_i\\right)$。\r\n\r\n现额外给定 $m$ 组支配关系,每组支配关系 $\\left( x,y\\right)$ 描述了第 $x$ 个 A 类串**支配**第 $y$ 个 B 类串。\r\n\r\n求一个**长度最大**的目标串 $T$,使得存在一个串 $T$ 的分割 $T=t_1 + t_2 +\\dots +t_k$($k\\geq 0$)满足:\r\n\r\n- 分割中的每个串 $t_i$ 均为 A 类串:即存在一个与其相等的 A 类串,不妨假设其为 $t_i = A_{id_i}$。\r\n- 对于分割中所有相邻的串 $t_i , t_{i+1}$($1\\leq i < k$),都有存在一个 $A_{id_i}$ 支配的 B 类串,使得该 B 类串为 $t_{i+1}$ 的前缀。\r\n\r\n方便起见,你只需要输出这个最大的长度即可。\r\n\r\n特别地,如果存在无限长的目标串(即对于任意一个正整数 $n$,都存在一个满足限制的长度超过 $n$ 的串),请输出 $-1$。\n输入格式\n从标准输入读入数据。\r\n\r\n单个测试点中包含多组数据,输入的第一行包含一个非负整数 $T$ 表示数据组数。接下来依次描述每组数据,对于每组数据:\r\n\r\n- 第 $1$ 行一个只包含小写字母的字符串 $S$。\r\n- 第 $2$ 行一个非负整数 $n_a$,表示 A 类串的数目。接下来 $n_a$ 行,每行 $2$ 个用空格隔开的整数。\r\n - 这部分中第 $i$ 行的两个数分别为 $la_i,ra_i$,描述第 $i$ 个 A 类串。\r\n - 保证 $1\\leq la_i\\leq ra_i\\leq \\lvert S\\rvert$。\r\n- 接下来一行一个非负整数 $n_b$,表示 B 类串的数目。接下来 $n_b$ 行,每行 $2$ 个用空格隔开的整数。\r\n - 这部分中第 $i$ 行的两个数分别为 $lb_i,rb_i$,描述第 $i$ 个 B 类串。\r\n - 保证 $1\\leq lb_i\\leq rb_i\\leq \\lvert S\\rvert$。\r\n- 接下来一行一个非负整数 $m$,表示支配关系的组数。接下来 $m$ 行,每行 $2$ 个用空格隔开的整数。\r\n - 这部分中每行的两个整数 $x,y$,描述一对 $\\left( x,y\\right)$ 的支配关系,具体意义见「题目描述」。\r\n - 保证 $1\\leq x\\leq n_a$,$1\\leq y\\leq n_b$。保证所有支配关系两两不同,即不存在两组支配关系的 $x,y$ **均**相同。\n输出格式\n输出到标准输出。\r\n\r\n依次输出每组数据的答案,对于每组数据:\r\n\r\n- 一行一个整数表示最大串长。特别地,如果满足限制的串可以是无限长的,则请输出 $-1$。\n样例\n输入:\n3\nabaaaba\n2\n4 7\n1 3\n1\n3 4\n1\n2 1\nabaaaba\n2\n4 7\n1 3\n1\n7 7\n1\n2 1\nabbaabbaab\n4\n1 5\n4 7\n6 9\n8 10\n3\n1 6\n10 10\n4 6\n5\n1 2\n1 3\n2 1\n3 3\n4 1\n输出:\n7\n-1\n13\n\n对于第 $1$ 组数据,A 类串有 `aaba` 与 `aba`,B 类串有 `aa`,且 $A_2$ 支配 $B_1$。我们可以找到串 `abaaaba`,它可以拆分成 $A_2 + A_1$,且 $A_1$ 包含由 $A_2$ 所支配的 $B_1$ 作为前缀。可以证明不存在长度更大的满足限制的串。\n\n对于第 $2$ 组数据,与第 $1$ 组数据唯一不同的是,唯一的 B 类串为 `a`。容易证明存在无限长的满足限制的串。\n\n对于第 $3$ 组数据,容易证明 `abbaabbaaaabb` 是最长的满足限制的串。数据范围与提示\n|$n_a$|$n_b$|$\\lvert S\\rvert$|测试点|$m$|$\\lvert A_i\\rvert \\geq \\lvert B_j\\rvert$|其他限制|\r\n|:-:|:-:|:-:|:-:|:-:|:-:|:-:|\r\n|$\\leq 100$|$\\leq 100$|$\\leq 10^4$|$1$|$\\leq 10^4$|保证|保证所有 $\\lvert A_i\\rvert,\\lvert B_j\\rvert\\leq 100$|\r\n|$\\leq 1000$|$\\leq 1000$|$\\leq 2\\times 10^5$|$2\\sim 3$|$\\leq 2\\times 10^5$|保证|无|\r\n|$=1$|$\\leq 2\\times 10^5$|$\\leq 2\\times 10^5$|$4$|$=n_b$|保证|无|\r\n|$\\leq 2\\times 10^5$|$\\leq 2\\times 10^5$|$\\leq 2\\times 10^5$|$5\\sim 6$|$\\leq 2\\times 10^5$|保证|保证所有 $ra_i +1=la_{i+1}$|\r\n|$\\leq 2\\times 10^5$|$\\leq 2\\times 10^5$|$\\leq 2\\times 10^5$|$7\\sim 8$|$\\leq 2\\times 10^5$|保证|无|\r\n|$\\leq 2\\times 10^5$|$\\leq 2\\times 10^5$|$\\leq 2\\times 10^5$|$9\\sim 10$|$\\leq 2\\times 10^5$|不保证|无|\r\n\r\n为了方便你的阅读,我们把**测试点编号**放在了表格的中间,请你注意这一点。\r\n\r\n表格中的 $\\lvert A_i\\rvert \\ge \\lvert B_j\\rvert$ 指的是**任意** B 类串的长度不超过**任意** A 类串的长度。\r\n\r\n对于所有测试点,保证:$T\\leq 100$,且对于测试点内所有数据,$\\lvert S\\rvert,n_a,n_b,m$ 的**总和**分别不会超过**该测试点中对应**的**单组数据的限制**的 $10$ 倍。比如,对于第 1 组测试点,就有 $\\sum n_a\\leq 10\\times 100=1000$ 等。特别地,我们规定对于测试点 4,有 $T\\leq 10$。\r\n\r\n对于所有测试点中的每一组数据,保证:$1\\leq \\lvert S\\rvert\\leq 2\\times 10^5$,$n_a , n_b\\leq 2\\times 10^5$,$m\\leq 2\\times 10^5$。\r\n\r\n#### 提示\r\n十二省联考命题组温馨提醒您:\r\n\r\n**数据千万条,清空第一条。**\r\n\r\n**多测不清空,爆零两行泪。**", | |
| "sample": { | |
| "input": "3\nabaaaba\n2\n4 7\n1 3\n1\n3 4\n1\n2 1\nabaaaba\n2\n4 7\n1 3\n1\n7 7\n1\n2 1\nabbaabbaab\n4\n1 5\n4 7\n6 9\n8 10\n3\n1 6\n10 10\n4 6\n5\n1 2\n1 3\n2 1\n3 3\n4 1", | |
| "output": "7\n-1\n13" | |
| } | |
| }, | |
| { | |
| "code_id": 4, | |
| "code": "// InterestingLSY\n\n// codeforces&github: interestingLSY, qq: 2659723130\n\n// 《幽灵公主》是真的好看?\n\n#ifdef intLSY\n\n#include <intlsy/stdc++.h>\n\n#else\n\n#include <bits/stdc++.h>\n\n#endif\n\n#include <bits/c++0x_warning.h>\n\nusing namespace std;\n\n#define il inline\n\n#define elif else if\n\n\n\n// Type\n\n#define ld double\n\n#define ll long long\n\n#define ull unsigned ll\n\n\n\n// Vector\n\n#define vc vector\n\n#define Pb push_back\n\n#define Pf push_front\n\n#define Eb emplace_back\n\n#define All(x) x.begin(),x.end()\n\n#define AllRev(x) x.rbegin(),x.rend()\n\n\n\n// Memory\n\n#define Ms(_data) memset(_data,0,sizeof(_data))\n\n#define Msn(_data,_num) memset(_data,_num,sizeof(_data))\n\n\n\n// Pair\n\n#define F first\n\n#define S second\n\n#define pii pair<int,int>\n\n#define pli pair<ll,int>\n\n#define pil pair<int,ll>\n\n#define pll pair<ll,ll>\n\n\n\n// Loop\n\n#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )\n\n#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )\n\n#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )\n\n#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )\n\n#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )\n\n#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )\n\n#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )\n\n\n\n// Read\n\nstruct InputReader{\n\n\tstatic constexpr int MAXSZ = 1048576;\n\n\tchar buf[MAXSZ]; int p, ed;\n\n\tbool detectedEOF = false;\n\n\til InputReader(){ p = MAXSZ; }\n\n\til void Flush(){ p = 0; ed = fread(buf,1,MAXSZ,stdin); }\n\n\til void GetChar( char &c ){\n\n\t\tif(p >= MAXSZ) Flush();\n\n\t\tif( p == ed ){ detectedEOF = true; }\n\n\t\tc = buf[p++];\n\n\t}\n\n\til void ReadNum( char &c ){ GetChar(c); while( !isdigit(c) && c != '-' && !detectedEOF ) GetChar(c); }\n\n\til void ReadAlpha( char &c ){ GetChar(c); while( !isalpha(c) && !detectedEOF ) GetChar(c); }\n\n\til void ReadInt( int &ans ){\n\n\t\tans = 0; int nega = 1;\n\n\t\tchar c; ReadNum(c); if(detectedEOF) return;\n\n\t\tif( c == '-' ){\n\n\t\t\tnega = -1;\n\n\t\t\tGetChar(c);\n\n\t\t}\n\n\t\twhile( isdigit(c) && !detectedEOF ){\n\n\t\t\tans = ans*10 + c-'0';\n\n\t\t\tGetChar(c);\n\n\t\t}\n\n\t\tans *= nega;\n\n\t}\n\n\til void Readll( ll &ans ){\n\n\t\tans = 0; int nega = 1;\n\n\t\tchar c; ReadNum(c); if(detectedEOF) return;\n\n\t\tif( c == '-' ){\n\n\t\t\tnega = -1;\n\n\t\t\tGetChar(c);\n\n\t\t}\n\n\t\twhile( isdigit(c) && !detectedEOF ){\n\n\t\t\tans = ans*10 + c-'0';\n\n\t\t\tGetChar(c);\n\n\t\t}\n\n\t\tans *= nega;\n\n\t}\n\n\til void ReadString( string &x ){\n\n\t\tx.clear(); char ch; GetChar(ch);\n\n\t\twhile( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;\n\n\t\twhile( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){\n\n\t\t\tx += ch;\n\n\t\t\tGetChar(ch);\n\n\t\t}\n\n\t}\n\n\til void ReadCString( char s[] ){\n\n\t\tint len = 0; char ch; GetChar(ch);\n\n\t\twhile( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;\n\n\t\twhile( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){\n\n\t\t\ts[len++] = ch;\n\n\t\t\tGetChar(ch);\n\n\t\t}\n\n\t\ts[len] = '\\0';\n\n\t}\n\n\til void SpecialRead( char &c ){\n\n\t\tGetChar(c); if(detectedEOF) return;\n\n\t\twhile( !isdigit(c) && !isalpha(c) && c != '#' && c != '.' && c != '=' && c != 'B' && !detectedEOF ) GetChar(c);\n\n\t}\n\n}In;\n\nil void Read( int &x ){ In.ReadInt(x); }\n\nil void Read( int &x, int &y ){ In.ReadInt(x); In.ReadInt(y); }\n\nil void Read( int &x1 , int &x2 , int &x3 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); }\n\nil void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); In.ReadInt(x4); }\n\nil void Read( ll &x ){ In.Readll(x); }\n\nil void Read( ll &x, ll &y ){ In.Readll(x); In.Readll(y); }\n\nil void Read( ll &x1 , ll &x2 , ll &x3 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); }\n\nil void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); In.Readll(x4); }\n\ntemplate<typename T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }\n\n#define iRead(k) int k; Read(k);\n\n#define iRead2(a,b) iRead(a); iRead(b);\n\n#define iRead3(a,b,c) iRead2(a,b); iRead(c);\n\n#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);\n\n#define lRead(k) ll k; Read(k);\n\n#define lRead2(a,b) lRead(a); lRead(b);\n\n#define lRead3(a,b,c) lRead2(a,b); lRead(c);\n\n#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);\n\n\n\n// File\n\nil void FILEIO(){\n\n\t#ifdef intLSY\n\n\t\tFin(\"in.in\");\n\n\t#endif\n\n}\n\nil void FILEIO( string pname ){\n\n\t#ifndef intLSY\n\n\t\tFin((pname+\".in\").c_str());\n\n\t\tFout((pname+\".out\").c_str());\n\n\t#else\n\n\t\tFin(\"in.in\");\n\n\t#endif\n\n}\n\nil void FILEIO_OICONTEST( string pname ){\n\n\tFin((pname+\".in\").c_str());\n\n\t#ifndef intLSY\n\n\t\tFout((pname+\".out\").c_str());\n\n\t#endif\n\n}\n\nvoid Printtime(){\n\n\t#ifdef intLSY\n\n\t\tdouble _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;\n\n\t\tfprintf(stderr,\"\\n\\nTime usage:\\n%.0lf ms\\n\",_timeuse);\n\n\t#endif\n\n}\n\nvoid END(){ Printtime(); exit(0); }\n\ntemplate<typename T>void END( T mes ){ cout << mes << endl; END(); }\n\n\n\n// Debug\n\n#define B cerr << \"BreakPoint\" << endl;\n\n#define O(x) cerr << #x << \" \" << (x) << endl;\n\n#define o(x) cerr << #x << \" \" << (x) << \" \";\n\ntemplate<typename T0>\n\nvoid P( T0 t0 ){\n\n\tcerr << t0 << endl;\n\n}\n\ntemplate<typename T0, typename... Ts>\n\nvoid P( T0 t0 , Ts... ts ){\n\n\tcerr << t0 << \" \";\n\n\tP(ts...);\n\n}\n\n#define Msz(x) cerr << \"Sizeof \" << #x << \" \" << sizeof(x)/1024/1024 << \" MB\" << endl;\n\ntemplate<typename T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\\n' ){\n\n\tif( s > t ) return;\n\n\tfor( int i = s ; i < t ; i++ )\n\n\t\tcout << a[i] << sp;\n\n\tcout << a[t] << ed;\n\n\tcout.flush();\n\n}\n\ntemplate<typename T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\\n' ){\n\n\tif( t == -1 ) t = a.size()-1;\n\n\tfor( int i = s ; i <= t ; i++ )\n\n\t\tcout << a[i] << sp;\n\n\tcout << ed;\n\n\tcout.flush();\n\n}\n\n\n\n// Optimize\n\n#define Max(a,b) ((a)>(b)?(a):(b))\n\n#define Min(a,b) ((a)<(b)?(a):(b))\n\n#define Mymax(a,b) (a) = max((a),(b))\n\n#define Mymin(a,b) (a) = min((a),(b))\n\n#define MyMax(a,b) (a) = Max((a),(b))\n\n#define MyMin(a,b) (a) = Min((a),(b))\n\n#define INF (0x3f3f3f3f)\n\n#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))\n\n#define Sqr(x) ((x)*(x))\n\n#define Lowbit(a) ((a)&(-(a)))\n\n#define Equ(a,b) (fabs((a)-(b))<Eps)\n\nconstexpr ld Eps = 1e-8;\n\nconstexpr ld PI = 3.141592653589793238462643383279502884197169399;\n\nstruct Point{\n\n\tld x,y;\n\n\til ld Len2(){ return x*x+y*y; }\n\n\til ld Len(){ return sqrt(x*x+y*y); }\n\n};\n\nil Point operator+( const Point &a , const Point &b ){ return {a.x+b.x,a.y+b.y}; }\n\nil Point operator-( const Point &a , const Point &b ){ return {a.x-b.x,a.y-b.y}; }\n\nil ld operator%( const Point &a , const Point &b ){ return a.x*b.x + a.y*b.y; }\n\nil ld operator*( const Point &a , const Point &b ){ return a.x*b.y - b.x*a.y; }\n\nil Point operator*( const Point &a , const ld &b ){ return {a.x*b,a.y*b}; }\n\nil Point operator/( const Point &a , const ld &b ){ return {a.x/b,a.y/b}; }\n\nil bool operator==( const Point &a , const Point &b ){ return fabs(a.x-b.x)<Eps and fabs(a.y-b.y)<Eps; }\n\nil ld Dis( const Point &a , const Point &b ){ return sqrt((ld)Sqr(a.x-b.x)+Sqr(a.y-b.y)); }\n\nil ld Dis2( const Point &a , const Point &b ){ return Sqr(a.x-b.x)+Sqr(a.y-b.y); }\n\nostream& operator<<( ostream &out , const Point &p ){\n\n\tout << p.x << \" \" << p.y << \" \";\n\n\treturn out;\n\n}\n\nil bool TurnLeft( const Point &a , const Point &b , const Point &c ){ return (b-a)*(c-b) > Eps; }\n\nil bool TurnRight( const Point &a , const Point &b , const Point &c ){ return (b-a)*(c-b) < -Eps; }\n\n///////////////////////////////////////////////////////////////////////////////////////\n\n///////////////////////////////////////////////////////////////////////////////////////\n\nconstexpr int MAXN = 524288;\n\n#define arg dklfhanuvbkudakufnshvakdgs\n\n\n\nstruct Manacher{\n\n\tint n;\n\n\tld a[MAXN*2];\n\n\tint p[MAXN*2];\n\n\tvoid DoManacher(){\n\n\t\tint mxright = 0, mxpos = 0;\n\n\t\tp[0] = 1;\n\n\t\tFor(i,n){\n\n\t\t\tint oppo = 2*mxpos - i;\n\n\t\t\tif( mxright > i ) p[i] = min( p[oppo] , mxright-i+1 );\n\n\t\t\telse p[i] = 1;\n\n\t\t\twhile( i-p[i] >= 0 and i+p[i] <= n and Equ(a[i-p[i]],a[i+p[i]]) )\n\n\t\t\t\t++p[i];\n\n\t\t\tif( i+p[i]-1 > mxright ){\n\n\t\t\t\tmxpos = i;\n\n\t\t\t\tmxright = i+p[i]-1;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tvoid Process( ld data[] , int originLen ){\n\n\t\tn = 0;\n\n\t\tMs(p);\n\n\n\n\t\ta[0] = -INF;\n\n\t\tFor(i,originLen){\n\n\t\t\ta[++n] = data[i];\n\n\t\t\ta[++n] = -INF;\n\n\t\t}\n\n\t\tDoManacher();\n\n\t\t// Print(a,0,n);\n\n\t\t// Print(p,0,n);\n\n\t}\n\n};\n\n\n\nint n;\n\nPoint a[MAXN];\n\n\n\nld dis[MAXN];\n\nld arg[MAXN];\n\nvoid CalcData(){\n\n\ta[0] = a[n];\n\n\ta[n+1] = a[1];\n\n\tFor(i,n){\n\n\t\tdis[i] = Dis2(a[i],a[i+1]);\n\n\t\tPoint v1 = a[i]-a[i-1];\n\n\t\tPoint v2 = a[i+1]-a[i];\n\n\t\targ[i] = (v1%v2) / v1.Len() / v2.Len();\n\n\t\tdis[i+n] = dis[i+n+n] = dis[i+n+n+n] = dis[i];\n\n\t\targ[i+n] = arg[i+n+n] = arg[i+n+n+n] = arg[i];\n\n\t}\n\n\t// Print(dis,1,n);\n\n\t// Print(arg,1,n);\n\n}\n\n\n\nManacher disMan, argMan;\n\n\n\nint Solve(){\n\n\tCalcData();\n\n\tdisMan.Process(dis,n+n+n+n);\n\n\targMan.Process(arg,n+n+n+n);\n\n\tint ans1 = 0;\n\n\tForx(i,n+1+2,n+n+2){\n\n\t\tassert( Equ(disMan.a[2*i-2],-INF) );\n\n\t\tassert( Equ(argMan.a[2*i-1],arg[i]) );\n\n\t\t// P(disMan.p[2*i-2],argMan.p[2*i-1]);\n\n\t\tif( (disMan.p[2*i-2]/2)*2 >= n and (argMan.p[2*i-1]/2)*2 >= n )\n\n\t\t\t++ans1;\n\n\t}\n\n\tans1 /= 2;\n\n\tint ans2 = 0;\n\n\tForx(i,n+1+2,n+n+2){\n\n\t\tassert( Equ(disMan.a[2*i-1],dis[i]) );\n\n\t\tassert( Equ(argMan.a[2*i],-INF) );\n\n\t\t// P(disMan.p[2*i-1],argMan.p[2*i]);\n\n\t\tif( (disMan.p[2*i-1]/2)*2 >= n and (argMan.p[2*i]/2)*2 >= n )\n\n\t\t\t++ans2;\n\n\t}\n\n\tans2 /= 2;\n\n\treturn ans1 + ans2;\n\n}\n\n\n\nint main(){\n\n\tiRead(T);\n\n\tFor(TwT,T){\n\n\t\tRead(n);\n\n\t\tFor(i,n){\n\n\t\t\tiRead2(x,y);\n\n\t\t\ta[i] = {x,y};\n\n\t\t}\n\n\t\tint ans = Solve();\n\n\t\tcout << ans << endl;\n\n\t}\n\n\n}\n\n", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp: In function ‘void FILEIO(std::string)’:\n/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp:271:17: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 271 | Fin((pname+\".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp:273:17: error: ‘Fout’ was not declared in this scope\n 273 | Fout((pname+\".out\").c_str());\n | ^~~~\n/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp: In function ‘void FILEIO_OICONTEST(std::string)’:\n/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp:285:9: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 285 | Fin((pname+\".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp:289:17: error: ‘Fout’ was not declared in this scope\n 289 | Fout((pname+\".out\").c_str());\n | ^~~~\n/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp: In function ‘int main()’:\n/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp:623:33: warning: narrowing conversion of ‘x’ from ‘int’ to ‘double’ [-Wnarrowing]\n 623 | a[i] = {x,y};\n | ^\n/tmp/tmpub9ltjfh/884473ee-4e75-4e00-9ada-f575e7694106.cpp:623:35: warning: narrowing conversion of ‘y’ from ‘int’ to ‘double’ [-Wnarrowing]\n 623 | a[i] = {x,y};\n | ^\n" | |
| ], | |
| "tcb_id": "对称轴 Axes of Symmetry", | |
| "query": "# 对称轴 Axes of Symmetry\n题目描述\r\n\r\n给定一个多边形,不一定是凸多边形,但没有自交,即除了相邻的边在顶点上相交外没有两条边有公共点。\r\n\r\n求多边形的对称轴个数。\n## 输入格式\n第一行一个整数 $t (1 \\le t \\le 10)$,表示测试点个数。\r\n\r\n接下来有 $t$ 组数据,每组数据第一行有一个整数 $n (3 \\le n \\le 100\\ 000)$,表示多边形的点数。\r\n\r\n接下来 $n$ 行每行有两个整数 $x$ 和 $y$ ($-100\\ 000\\ 000 \\le x \\le 100\\ 000\\ 000$,$-100\\ 000\\ 000 \\le y \\le 100\\ 000\\ 000$),表示多边形的点。保证相邻边不共线。\n## 输出格式\n输出 $t$ 行,对每个多边形输出一个整数表示对称轴的个数。\n## 样例\n输入:\n2\n12\n1 -1\n2 -1\n2 1\n1 1\n1 2\n-1 2\n-1 1\n-2 1\n-2 -1\n-1 -1\n-1 -2\n1 -2\n6\n-1 1\n-2 0\n-1 -1\n1 -1\n2 0\n1 1\n输出:\n4\n2\n\n", | |
| "sample": { | |
| "input": "2\n12\n1 -1\n2 -1\n2 1\n1 1\n1 2\n-1 2\n-1 1\n-2 1\n-2 -1\n-1 -1\n-1 -2\n1 -2\n6\n-1 1\n-2 0\n-1 -1\n1 -1\n2 0\n1 1", | |
| "output": "4\n2" | |
| } | |
| }, | |
| { | |
| "code_id": 10, | |
| "code": "// #define ONLINE_JUDGE\n#include <bits/stdc++.h>\nusing namespace std;\nconst int M = 8e5 + 5;\nconst int Inf = 0x3f3f3f3f;\ntypedef long long ll;\ntypedef std::string str;\ntypedef double db;\n#define IL inline\n#define REP(i, lim) for (int i = 1; i <= lim; ++i)\n#define MST(a, b) memset(a, b, sizeof(a))\n\ntemplate <class T>\nvoid Max(T &x, T y) {\n x = max(x, y);\n}\n\ntemplate <class T>\nvoid Min(T &x, T y) {\n x = min(x, y);\n}\nint t;\nvoid Read() {\n ios::sync_with_stdio(false);\n cin.tie(0);\n cout.tie(0);\n cin >> t;\n}\nstruct Vec {\n db x, y;\n db len() const;\n Vec(db x_ = 0, db y_ = 0) : x(x_), y(y_){};\n Vec operator-(const Vec &b) { return Vec(x - b.x, y - b.y); }\n};\n\nconst db Eps = 1e-8;\n\nint Dcmp(db x, db y) {\n if (fabs(x - y) < Eps) {\n return 0;\n }\n return x < y ? -1 : 1;\n}\n\nstruct Node {\n int sgn;\n db v;\n Node(int s_ = 0, db v_ = 0) : sgn(s_), v(v_){};\n bool operator==(const Node &b) { return sgn == b.sgn && !Dcmp(v, b.v); }\n};\n\nVec v[M];\nNode m[M];\n\ndb Dis(const Vec &a, const Vec &b) { return hypot(a.x - b.x, a.y - b.y); }\ndb Dot(const Vec &a, const Vec &b) { return a.x * b.x + a.y * b.y; }\ndb Vec::len() const { return sqrt(Dot(*this, *this)); }\ndb Angle(const Vec &a, const Vec &b) {\n return acos(Dot(a, b) / a.len() / b.len());\n}\n\nint n;\nint Manacher(int len) {\n int p[M];\n int ret = 0;\n MST(p, 0);\n int r = 0, l = 0;\n for (int i = 1; i <= len; ++i) {\n p[i] = (i < r) ? min(p[(l << 1) - i], p[l] + l - i) : 1;\n while (/* p[i] < i && i + p[i] <= len && */ m[i + p[i]] ==\n m[i - p[i]]) {\n ++p[i];\n }\n if (p[i] + i > r) {\n r = p[i] + i;\n l = i;\n }\n if (p[i] >> 1 >= n) {\n ++ret;\n }\n int cur = p[i];\n DBG(i) DBG(l) DBG(r) DBG(cur) ETR;\n }\n return ret / 2;\n}\nvoid Solve() {\n while (t--) {\n cin >> n;\n REP(i, n) { cin >> v[i].x >> v[i].y; }\n v[0] = v[n];\n v[n + 1] = v[1];\n int tot = 0;\n REP(i, n) {\n m[++tot] = Node();\n m[++tot] = Node(1, Angle(v[i] - v[i - 1], v[i + 1] - v[i]));\n m[++tot] = Node();\n m[++tot] = Node(2, Dis(v[i + 1], v[i]));\n }\n // for (int i = 1; i <= tot; ++i) {\n // cerr << m[i].sgn << ' ' << m[i].v << '\\n';\n // }\n REP(i, tot) { m[i + tot] = m[i]; }\n tot = (tot << 1) | 1;\n m[tot] = Node();\n cout << Manacher(tot) << '\\n';\n }\n}\n\nsigned main() {\n Read();\n Solve();\n return 0;\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpca3cnoyb/68470042-b9ca-46aa-88f4-f1a3b10f0423.cpp: In function ‘int Manacher(int)’:\n/tmp/tmpca3cnoyb/68470042-b9ca-46aa-88f4-f1a3b10f0423.cpp:82:9: error: ‘DBG’ was not declared in this scope\n 82 | DBG(i) DBG(l) DBG(r) DBG(cur) ETR;\n | ^~~\n" | |
| ], | |
| "tcb_id": "对称轴 Axes of Symmetry", | |
| "query": "# 对称轴 Axes of Symmetry\n题目描述\r\n\r\n给定一个多边形,不一定是凸多边形,但没有自交,即除了相邻的边在顶点上相交外没有两条边有公共点。\r\n\r\n求多边形的对称轴个数。\n## 输入格式\n第一行一个整数 $t (1 \\le t \\le 10)$,表示测试点个数。\r\n\r\n接下来有 $t$ 组数据,每组数据第一行有一个整数 $n (3 \\le n \\le 100\\ 000)$,表示多边形的点数。\r\n\r\n接下来 $n$ 行每行有两个整数 $x$ 和 $y$ ($-100\\ 000\\ 000 \\le x \\le 100\\ 000\\ 000$,$-100\\ 000\\ 000 \\le y \\le 100\\ 000\\ 000$),表示多边形的点。保证相邻边不共线。\n## 输出格式\n输出 $t$ 行,对每个多边形输出一个整数表示对称轴的个数。\n## 样例\n输入:\n2\n12\n1 -1\n2 -1\n2 1\n1 1\n1 2\n-1 2\n-1 1\n-2 1\n-2 -1\n-1 -1\n-1 -2\n1 -2\n6\n-1 1\n-2 0\n-1 -1\n1 -1\n2 0\n1 1\n输出:\n4\n2\n\n", | |
| "sample": { | |
| "input": "2\n12\n1 -1\n2 -1\n2 1\n1 1\n1 2\n-1 2\n-1 1\n-2 1\n-2 -1\n-1 -1\n-1 -2\n1 -2\n6\n-1 1\n-2 0\n-1 -1\n1 -1\n2 0\n1 1", | |
| "output": "4\n2" | |
| } | |
| }, | |
| { | |
| "code_id": 4, | |
| "code": "#include<bits/stdc++.h>\nusing namespace std;\ntypedef long long LL;\nconst LL N = 500;\n#define PII pair<LL,LL>\n#define X(x) x.first\n#define Y(x) x.second\n#define mk(x,y) make_pair(x,y)\nconst LL INF = 1e15+7;\nvoid ckmin(PII &a,PII b)\n{\n\tif(X(a)<X(b)) return;\n\tif(X(a)>X(b))\n\t{\n\t\ta=b;\n\t\treturn;\n\t}\n\tY(a)=min(Y(a),Y(b));\n} \nLL n,m,k;\nLL Make()\n{\n\treturn rand()%k+1;\n}\nLL Id(LL i,LL j)\n{\n\treturn (i-1)*m+j;\n}\nLL c[N][N],a[N],w[N][N];\nLL h[N][N];\nLL Ans1,Ans2;\nint t[N];\nLL p[N];\nLL col[N];\nPII f[N][1<<6];\nbool vis[N];\nPII operator +( PII a,PII b)\n{\n\treturn mk(X(a)+X(b),Y(a)+Y(b));\n}\nPII operator -(PII a,PII b)\n{\n\treturn mk(X(a)-X(b),Y(a)-Y(b));\n}\nbool operator >(PII a,PII b)\n{\n\tif(X(a)>X(b)) return 1;\n\tif(X(a)<X(b)) return 0;\n\treturn Y(a)>Y(b); \n}\nstruct edge\n{\n\tLL y,next;\n}e[8*N];\nLL link[N],tt=0;\nvoid add(LL x,LL y)\n{\n\te[++tt].y=y;\n\te[tt].next=link[x];\n\tlink[x]=tt;\n}\nvoid put(LL s)\n{\n\tfor(LL i=1;i<=k;i++)\n\tif((s>>(i-1))&1) cout<<1;\n\telse cout<<0;\n\tcout<<endl; \n}\nqueue<int> q;\nvoid dij(LL s)\n{\n\tfor(LL i=1;i<=n*m;i++)\n\tvis[i]=0;\n\twhile(!q.empty())\n\t{\n\t\tint x=q.front();\n\t\tq.pop();\n\t\tvis[x]=0;\n\t\tfor(LL i=link[x];i;i=e[i].next)\n\t\t{\n\t\t\tLL y=e[i].y;\n\t\t\tif(vis[y]) continue;\n\t\t\tif(f[y][s]>f[x][s]+mk(1,a[y]))\n\t\t\t{\n\t\t\t\tvis[y]=1;\n\t\t\t\tf[y][s]=f[x][s]+mk(1,a[y]);\n\t\t\t\tq.push(y);\n\t\t\t}\n\t\t}\n\t}\n}\nPII check(LL mid)\n{\n\tfor(LL i=1;i<=n;i++)\n\tfor(LL j=1;j<=m;j++)\n\t{\n\t\tif(w[i][j]>mid) a[Id(i,j)]=1;\n\t\telse a[Id(i,j)]=-1;\n\t}\n\tfor(LL i=1;i<=n*m;i++)\n\tfor(LL j=0;j<(1<<k);j++)\n\tf[i][j]=mk(INF,INF); \n\tfor(LL i=1;i<=n;i++)\n\tfor(LL j=1;j<=m;j++)\n\t{\n\t\tLL x=Id(i,j);\n\t\tif(h[i][j]==-1) continue;\n\t\tf[x][(1<<(h[i][j]-1))]=mk(1,a[x]); \n\t}\n\tfor(LL s=1;s<(1<<k);s++)\n\t{\n\t\tfor(LL i=1;i<=n*m;i++)\n\t\t{\n\t\t\tfor(LL t=s;t;t=(t-1)&s)\n\t\t\t{\n\t\t\t\tckmin(f[i][s],f[i][t]+f[i][s-t]-mk(1,a[i]));\n\t\t\t}\n\t\t\tif(f[i][s]!=mk(INF,INF)) q.push(i);\n\t\t}\n\t\tdij(s);\t\n\t}\n\tPII ans(INF,INF);\n\tfor(LL i=1;i<=n*m;i++)\n\tckmin(ans,f[i][(1<<k)-1]);\n\tif(Y(ans)<=0) Y(ans)=1;\n\telse Y(ans)=-1;\n\treturn ans; \n}\nPII Doit()\n{\n\tLL l=INF,r=-INF; \n\tfor(LL i=1;i<=n;i++)\n\t{\n\t\tfor(LL j=1;j<=m;j++)\n\t\t{\n\t\t\tl=min(l,w[i][j]);\n\t\t\tr=max(r,w[i][j]);\n\t\t\tif(c[i][j]==-1) h[i][j]=-1;\n\t\t\telse h[i][j]=col[t[c[i][j]]];\n\t\t}\t\n\t}\n\tLL cnt=X(check(0));\n\tif(cnt==INF) return\tmk(INF,INF);\n\tLL mid,ans=-1;\n\twhile(l<=r)\n\t{\n\t\tmid=(l+r)>>1;\n\t\tPII res=check(mid);\n\t\tif(Y(res)!=-1) \n\t\t{\n\t\t\tans=mid;\n\t\t\tr=mid-1;\n\t\t}\n\t\telse l=mid+1;\n\t}\n\tif(ans==-1) ans=INF;\n\treturn mk(cnt,ans);\n}\n\nvoid solve()\n{\n\tscanf(\"%lld %lld %lld\",&n,&m,&k);\n\tLL cnt=0;\n\ttt=0;\n\tfor(LL i=1;i<=n;i++)\n\tfor(LL j=1;j<=m;j++)\n\t{\n\t\tscanf(\"%lld\",&c[i][j]);\t\n\t\tlink[Id(i,j)]=0;\n\t\tif(t[c[i][j]]||c[i][j]==-1) continue;\n\t\tp[++cnt]=c[i][j];\n\t\tt[c[i][j]]=cnt;\t\n\t}\n\tfor(LL i=1;i<=n;i++)\n\tfor(LL j=1;j<=m;j++)\n\t{\n\t\tif(c[i][j]==-1) continue;\n\t\tif(i+1<=n&&c[i+1][j]!=-1) add(Id(i,j),Id(i+1,j));\n\t\tif(i-1>=1&&c[i-1][j]!=-1) add(Id(i,j),Id(i-1,j));\n\t\tif(j+1<=m&&c[i][j+1]!=-1) add(Id(i,j),Id(i,j+1));\n\t\tif(j-1>=1&&c[i][j-1]!=-1) add(Id(i,j),Id(i,j-1));\n\t}\n\tfor(LL i=1;i<=n;i++)\n\tfor(LL j=1;j<=m;j++)\n\tscanf(\"%lld\",&w[i][j]);\t\n\tLL T=100;\n\tPII ans(INF,INF);\n\twhile(T--)\n\t{\n\t\tfor(LL i=1;i<=cnt;i++)\n\t\tcol[i]=Make();\n\t\tckmin(ans,Doit());\n\t}\n\tif(X(ans)==INF||Y(ans)==INF) printf(\"-1\\n\");\n\telse \n\t{\n\t\tprintf(\"%lld %lld\\n\",X(ans),Y(ans));\n\t}\n\tfor(int i=1;i<=cnt;i++)\n\tt[p[i]]=0;\n}\nint main()\n{\n\tsrand(time(0));\n\tLL T;\n\tcin>>T;\n\twhile(T--)\n\t{\n\t\tsolve();\n\t}\n\treturn 0;\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:55:10: error: ‘LL link [500]’ redeclared as different kind of entity\n 55 | LL link[N],tt=0;\n | ^\nIn file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,\n from /usr/include/signal.h:328,\n from /usr/include/c++/11/csignal:42,\n from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:43,\n from /tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:1:\n/usr/include/unistd.h:819:12: note: previous declaration ‘int link(const char*, const char*)’\n 819 | extern int link (const char *__from, const char *__to)\n | ^~~~\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp: In function ‘void add(LL, LL)’:\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:59:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 59 | e[tt].next=link[x];\n | ^\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:59:26: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ {aka ‘int (*)(const char*, const char*)’} to ‘LL’ {aka ‘long long int’} [-fpermissive]\n 59 | e[tt].next=link[x];\n | ~~~~~~^\n | |\n | int (*)(const char*, const char*) noexcept {aka int (*)(const char*, const char*)}\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:60:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 60 | link[x]=tt;\n | ^\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:60:16: error: assignment of read-only location ‘*(link + ((sizetype)x))’\n 60 | link[x]=tt;\n | ~~~~~~~^~~\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp: In function ‘void dij(LL)’:\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:79:32: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 79 | for(LL i=link[x];i;i=e[i].next)\n | ^\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:79:32: error: invalid conversion from ‘int (*)(const char*, const char*) noexcept’ {aka ‘int (*)(const char*, const char*)’} to ‘LL’ {aka ‘long long int’} [-fpermissive]\n 79 | for(LL i=link[x];i;i=e[i].next)\n | ^\n | |\n | int (*)(const char*, const char*) noexcept {aka int (*)(const char*, const char*)}\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp: In function ‘void solve()’:\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:169:29: warning: pointer to a function used in arithmetic [-Wpointer-arith]\n 169 | link[Id(i,j)]=0;\n | ^\n/tmp/tmpxs8f0_a0/9c5f420f-40ad-45d2-a34b-40e27c98fb78.cpp:169:30: error: assignment of read-only location ‘*(link + ((sizetype)Id(i, j)))’\n 169 | link[Id(i,j)]=0;\n | ~~~~~~~~~~~~~^~\n" | |
| ], | |
| "tcb_id": "巧克力", | |
| "query": "巧克力\n题目描述\n「人生就像一盒巧克力,你永远不知道吃到的下一块是什么味道。」\r\n\r\n明明收到了一大块巧克力,里面有若干小块,排成 $n$ 行 $m$ 列。每一小块都有自己特别的图案 $c_{i,j}$,它们有的是海星,有的是贝壳,有的是海螺……其中还有一些因为挤压,已经分辨不出是什么图案了。明明给每一小块巧克力标上了一个美味值 $a_{i,j}$($0\\leq a_{i,j} \\leq 10^6$),这个值越大,表示这一小块巧克力越美味。\r\n\r\n正当明明咽了咽口水,准备享用美味时,舟舟神奇地出现了。看到舟舟恳求的目光,明明决定从中选出一些小块与舟舟一同分享。\r\n\r\n舟舟希望这些被选出的巧克力是连通的(两块巧克力连通当且仅当他们有公共边),而且这些巧克力要包含至少 $k$($1\\leq k\\leq 5$)种。而那些被挤压过的巧克力则是不能被选中的。\r\n\r\n明明想满足舟舟的愿望,但他又有点「抠」,想将美味尽可能多地留给自己。所以明明希望选出的巧克力块数能够尽可能地少。如果在选出的块数最少的前提下,美味值的中位数(我们定义 $n$ 个数的中位数为第 $\\left \\lfloor \\frac{n+1}{2}\\right\\rfloor$ 小的数)能够达到最小就更好了。\r\n\r\n你能帮帮明明吗?\n输入格式\n每个测试点包含多组测试数据。\r\n\r\n输入第一行包含一个正整数 $T$($1\\leq T \\leq 5$),表示测试数据组数。\r\n\r\n对于每组测试数据:\r\n\r\n输入第一行包含三个正整数 $n,m$ 和 $k$;\r\n\r\n接下来 $n$ 行,每行 $m$ 个整数,表示每小块的图案 $c_{i,j}$。若 $c_{i,j}=-1$ 表示这一小块受到过挤压,不能被选中;\r\n\r\n接下来 $n$ 行,每行 $m$ 个整数,表示每个小块的美味值 $a_{i,j}$。\n输出格式\n输出共包括 $T$ 行,每行包含两个整数,用空格隔开,即最少的块数和最小的美味值中位数。\r\n\r\n若对于某组测试数据,不存在任意一种合法的选取方案,请在对应行输出两个 $-1$。\n样例\n输入:\n1\n5 4 5\n3 4 3 4\n5 5 -1 5\n-1 4 5 5\n5 5 4 2\n1 -1 2 4\n1 3 1 1\n3 2 3 3\n4 4 4 5\n8 9 9 5\n7 2 6 3\n\n输出:\n9 5\n\n\n\n数据范围与提示 针对所有的数据 1 ≤ n×m ≤ 233, c_{i,j} = -1 或 1 ≤ c_{i,j} ≤ n×m", | |
| "sample": { | |
| "input": "1\n5 4 5\n3 4 3 4\n5 5 -1 5\n-1 4 5 5\n5 5 4 2\n1 -1 2 4\n1 3 1 1\n3 2 3 3\n4 4 4 5\n8 9 9 5\n7 2 6 3\n", | |
| "output": "9 5\n" | |
| } | |
| }, | |
| { | |
| "code_id": 1, | |
| "code": "#include<bits/stdc++.h>\n#include<sys/mman.h>\n#include<fcntl.h>\nusing namespace std;\nusing llt=long long;\nusing llf=long double;\nusing ull=unsigned long long;\n#define Ct const\n#define Il __always_inline\n#define For(i,a,b,c) for(int i=(a);i<=(b);i+=(c))\n#define For_(i,a,b,c) for(int i=(a);i>=(b);i-=(c))\n#define For_it(i,a,b) for(auto i=(a);i!=(b);++i)\n\nnamespace IO{\n#ifdef ONLINE_JUDGE\n\tint Fin=fileno(stdin); FILE* Fout=stdout;\n#elif defined(UN_FAST)\n#else\n#endif // file\n#ifdef UN_FAST\n\tchar cc;\n\t#define G (cc=getchar())\n\t#define C cc\n#else\n\tconst char *I=(char*)mmap(0,1<<24,1,2,Fin,0)-1; \n\t#define G (*++I)\n\t#define C (*I)\n#endif // fast (mmap)\n#define P(x) putc_unlocked(x,Fout)\n\ttemplate<class T> Il void read(T &x){x=0;bool f=0; while(f|=G==45,C<48); while(x=x*10+(C&15),G>47); f?x=-x:0;}\n\ttemplate<class T> void write(T x){if(x<0) P('-'),x=-x; if(x/10) write(x/10); P('0'+x%10);}\n\tIl void read(char &c){while(G<33); c=C;} void read(char *s){char *p=s-1; while(G<33); while(*++p=C,G>32); *++p='\\0';}\n\tIl void read(string &s){s.clear(); while(G<33); while(s.push_back(C),G>32);}\n\ttemplate<class T=int> Il T read(){T a; return read(a),a;}\n\ttemplate<class T,class ...Argc> Il void read(T &x,Argc &...argc){read(x),read(argc...);}\n\tIl void write(const char &c){P(c);} Il void write(const char *s){for(const char *c=s;*c!='\\0';++c) P(*c);}\n\tIl void write(const string &s){for(const char &c:s) P(c);}\n\ttemplate<class T,class ...Argc> Il void write(const T &x,const Argc &...argc){write(x),write(argc...);}\n\ttemplate<class T> Il void Write(const T &x){write(x),P(' ');} Il void Write(const char &c){P(c); if(c>32) P(' ');}\n\ttemplate<class T,class ...Argc> Il void Write(const T &x,const Argc &...argc){Write(x),Write(argc...);}\n#undef G\n#undef C\n#undef P\n}using IO::read; using IO::write; using IO::Write;\n\nconstexpr int N=2e5+3,Inf=0x3f3f3f3f;\n\nint n,m,cl,cr,wt[N];\nint __cnt,__cnt2;\nstruct Graph{\n\tint hd[N],to[N<<1],nt[N<<1],col[N<<1],tot=1;\n\tIl void Add(Ct int &u,Ct int &v,Ct int &w){col[++tot]=w,to[tot]=v,nt[tot]=hd[u],hd[u]=tot;}\n#define For_to(i,u,v,g) for(int i=g.hd[u],v=g.to[i];i;i=g.nt[i],v=g.to[i])\n}g;\nclass PDIV{\nprivate:\n\tint sz[N],mav[N],rt,dis[N],dep[N],mdp[N],ans;\n\tbool vis[N];\n\tvoid Root(Ct int &u,Ct int &fa,int usz){\n\t\tsz[u]=1,mav[u]=0;\n\t\tFor_to(i,u,v,g) if(v!=fa&&!vis[v]) Root(v,u,usz),sz[u]+=sz[v],mav[u]=max(mav[u],sz[v]);\n\t\tmav[u]=max(mav[u],usz-sz[u]);\n\t\tif(mav[rt]>mav[u]) rt=u;\n\t}\n\tvoid Size(Ct int &u,Ct int &fa){sz[u]=1; For_to(i,u,v,g) if(v!=fa&&!vis[v]) Size(v,u),sz[u]+=sz[v];}\n\tvoid Getu(Ct int &u,Ct int &fa,Ct int &la){\n\t\tFor_to(i,u,v,g) if(v!=fa&&!vis[v]){\n\t\t\tdep[v]=dep[u]+1,dis[v]=dis[u]+(g.col[i]==la?0:wt[g.col[i]]);\n\t\t\tGetu(v,u,g.col[i]); mdp[u]=max(mdp[v]+1,mdp[u]);\n\t\t}\n\t}\n\t\n\tvector<int> ord,cld[N];\n\tclass SORT{\n\tprivate:\n\t\tPDIV *F;\n\t\tbool vis[N]; int ma[N];\n\tpublic:\n\t\tSORT(PDIV *_):F(_){};\n\t\tIl void operator()(){\n\t\t\tFor_to(i,F->rt,v,g) if(!F->vis[v]){\n\t\t\t\tint col=g.col[i];\n\t\t\t\tF->cld[col].push_back(v),ma[col]=max(ma[col],F->mdp[v]);\n\t\t\t\tif(!vis[col]) F->ord.push_back(col),vis[col]=1;\n\t\t\t}\n\t\t\tsort(F->ord.begin(),F->ord.end(),[this](Ct int &a,Ct int &b){return this->ma[a]<this->ma[b];});\n\t\t\tfor(Ct int &c:F->ord)\n\t\t\t\tsort(F->cld[c].begin(),F->cld[c].end(),[this](Ct int &a,Ct int &b){return this->F->mdp[a]<this->F->mdp[b];});\n\t\t\tFor_to(i,F->rt,v,g) if(!F->vis[v]) ma[g.col[i]]=vis[g.col[i]]=0;\n\t\t}\n\t}Sort=SORT(this);\n\n\tclass CALC{\n\tprivate:\n\t\tint mad[N],mas[N],lend,lens,posd,poss;\n\t\tqueue<pair<int,int>> que; PDIV *F;\n\t\tclass Mque{\n\t\tprivate: int que[N],*hd=que+1,*tl=que;\n\t\tpublic:\n\t\t\tIl bool Empty(){return hd>tl;} Il void Clear(){hd=que+1,tl=que;}\n\t\t\tIl void Push(Ct int &p,Ct int *pd){while(!Empty()&&pd[*tl]<=pd[p]) --tl,++__cnt; *++tl=p;}\n\t\t\tIl int Front(Ct int &lim){while(!Empty()&&*hd>lim) ++hd,++__cnt; return Empty()?N-1:*hd;}\n\t\t}qd,qs;\n\t\tIl int Get(Ct int &u,Ct int &col){\n\t\t\tint l=max(0,cl-F->dep[u]);\n\t\t\twhile(posd>=l) qd.Push(posd,mad),--posd;\n\t\t\twhile(poss>=l) qs.Push(poss,mas),--poss;\n\t\t\treturn max(mad[qd.Front(cr-F->dep[u])],mas[qs.Front(cr-F->dep[u])]-wt[col])+F->dis[u];\n\t\t}\n\tpublic:\n\t\tCALC(PDIV *_):F(_){memset(mad,-0x3f,sizeof(mad)),memset(mas,-0x3f,sizeof(mas)),mad[0]=0;}\n\t\tIl void Clr(){For(i,1,lend,1) mad[i]=-Inf; posd=lend=0;}\n\t\tIl void operator()(Ct int &nwc){\n\t\t\t__cnt=0;\n\t\t\tfor(int nw:F->cld[nwc]){\n\t\t\t\tque.emplace(nw,F->rt);\n\t\t\t\twhile(!que.empty()){\n\t\t\t\t\tauto tmp=que.front(); que.pop();\n\t\t\t\t\tint u=tmp.first,fa=tmp.second;\n\t\t\t\t\tF->ans=max(F->ans,Get(u,nwc));\n\t\t\t\t\tFor_to(i,u,v,g) if(!F->vis[v]&&fa!=v) que.emplace(v,u);\n\t\t\t\t\t++__cnt;\n\t\t\t\t}\n\t\t\t\tque.emplace(nw,F->rt);\n\t\t\t\twhile(!que.empty()){\n\t\t\t\t\tauto tmp=que.front(); que.pop();\n\t\t\t\t\tint u=tmp.first,fa=tmp.second;\n\t\t\t\t\tmas[F->dep[u]]=max(mas[F->dep[u]],F->dis[u]),lens=max(lens,F->dep[u]);\n\t\t\t\t\tFor_to(i,u,v,g) if(!F->vis[v]&&fa!=v) que.emplace(v,u);\n\t\t\t\t\t++__cnt;\n\t\t\t\t}\n\t\t\t\tposs=lens,qd.Clear(),qs.Clear();\n\t\t\t}\n\t\t\tlend=max(lend,lens),posd=lend;\n\t\t\tFor(i,1,lens,1) mad[i]=max(mas[i],mad[i]),mas[i]=-Inf; poss=lens=0;\n\t\t}\n\t}Calc=CALC(this);\n\n\tvoid Div(){\n\t\tvis[rt]=1;\n\t\tdis[rt]=dep[rt]=0,Getu(rt,0,0);\n\t\tSort();\n\t\tint pos=0;\n\t\tfor(Ct int &c:ord) Calc(c),cld[c].clear(); Calc.Clr(); ord.clear();\n\t\tSize(rt,0); int u=rt;\n\t\tFor_to(i,u,v,g) if(!vis[v]) rt=0,Root(v,u,sz[v]),Div();\n\t}\npublic:\n\tPDIV(){mav[0]=0x3f3f3f3f,ans=-Inf;}\n\tIl int operator()(){Root(1,0,n),Div(); return ans;}\n}Pdiv;\n\nint main(){\n\tread(n,m,cl,cr);\n\tFor(i,1,m,1) read(wt[i]);\n\tFor(i,1,n-1,1){int u,v,c; read(u,v,c); g.Add(u,v,c),g.Add(v,u,c);}\n\twrite(Pdiv());\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:25:47: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 25 | const char *I=(char*)mmap(0,1<<24,1,2,Fin,0)-1;\n | ^~~\n | sin\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp: In function ‘void IO::write(T)’:\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:29:30: error: ‘Fout’ was not declared in this scope\n 29 | #define P(x) putc_unlocked(x,Fout)\n | ^~~~\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:31:51: note: in expansion of macro ‘P’\n 31 | template<class T> void write(T x){if(x<0) P('-'),x=-x; if(x/10) write(x/10); P('0'+x%10);}\n | ^\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:29:30: error: ‘Fout’ was not declared in this scope\n 29 | #define P(x) putc_unlocked(x,Fout)\n | ^~~~\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:31:86: note: in expansion of macro ‘P’\n 31 | template<class T> void write(T x){if(x<0) P('-'),x=-x; if(x/10) write(x/10); P('0'+x%10);}\n | ^\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp: In function ‘void IO::write(const char&)’:\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:29:30: error: ‘Fout’ was not declared in this scope\n 29 | #define P(x) putc_unlocked(x,Fout)\n | ^~~~\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:36:38: note: in expansion of macro ‘P’\n 36 | Il void write(const char &c){P(c);} Il void write(const char *s){for(const char *c=s;*c!='\\0';++c) P(*c);}\n | ^\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp: In function ‘void IO::write(const char*)’:\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:29:30: error: ‘Fout’ was not declared in this scope\n 29 | #define P(x) putc_unlocked(x,Fout)\n | ^~~~\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:36:108: note: in expansion of macro ‘P’\n 36 | Il void write(const char &c){P(c);} Il void write(const char *s){for(const char *c=s;*c!='\\0';++c) P(*c);}\n | ^\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp: In function ‘void IO::write(const string&)’:\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:29:30: error: ‘Fout’ was not declared in this scope\n 29 | #define P(x) putc_unlocked(x,Fout)\n | ^~~~\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:37:61: note: in expansion of macro ‘P’\n 37 | Il void write(const string &s){for(const char &c:s) P(c);}\n | ^\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp: In function ‘void IO::Write(const T&)’:\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:29:30: error: ‘Fout’ was not declared in this scope\n 29 | #define P(x) putc_unlocked(x,Fout)\n | ^~~~\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:39:62: note: in expansion of macro ‘P’\n 39 | template<class T> Il void Write(const T &x){write(x),P(' ');} Il void Write(const char &c){P(c); if(c>32) P(' ');}\n | ^\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp: In function ‘void IO::Write(const char&)’:\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:29:30: error: ‘Fout’ was not declared in this scope\n 29 | #define P(x) putc_unlocked(x,Fout)\n | ^~~~\n/tmp/tmp35koic6o/54a7768f-e073-4e02-94b7-ba9d57c01898.cpp:39:100: note: in expansion of macro ‘P’\n 39 | template<class T> Il void Write(const T &x){write(x),P(' ');} Il void Write(const char &c){P(c); if(c>32) P(' ');}\n | ^\n" | |
| ], | |
| "tcb_id": "树的难题", | |
| "query": "# 树的难题\n## 题目描述\n给你一棵 $n$ 个点的无根树。\r\n\r\n树上的每条边具有颜色。一共有 $m$ 种颜色,编号为 $1$ 到 $m$,第 $i$ 种颜色的权值为 $c_i$。\r\n\r\n对于一条树上的简单路径,路径上经过的所有边按顺序组成一个颜色序列,序列可以划分成若干个相同颜色段。定义路径权值为颜色序列上每个同颜色段的颜色权值之和。\r\n\r\n请你计算,经过边数在 $l$ 到 $r$ 之间的所有简单路径中,路径权值的最大值。\n## 输入格式\n第一行,四个整数 $n, m, l, r$。 \r\n第二行,$m$ 个整数 $c_1, c_2, \\ldots, c_m$,由空格隔开,依次表示每个颜色的权值。 \r\n接下来 $n-1$ 行,每行三个整数 $u, v, c$,表示点 $u$ 和点 $v$ 之间有一条颜色为 $c$ 的边。\n## 输出格式\n输出一行,一个整数,表示答案。\n## 样例\n### 样例 1\n输入:\n5 3 1 4\n-1 -5 -2\n1 2 1\n1 3 1\n2 4 2\n2 5 3\n输出:\n-1\n\n颜色权值均为负,最优路径为 $(1, 2)$ 或 $(1, 3)$。\n### 样例 2\n输入:\n8 4 3 4\n-7 9 6 1\n1 2 1\n1 3 2\n1 4 1\n2 5 1\n5 6 2\n3 7 1\n3 8 3\n输出:\n11\n\n最优路径为 $(3, 1, 2, 5, 6)$,其颜色序列为 $(2, 1, 1, 2)$。\n## 数据范围与提示\n$ n\\leq 2\times10^5, m\\leq n $", | |
| "sample": { | |
| "input": "5 3 1 4\n-1 -5 -2\n1 2 1\n1 3 1\n2 4 2\n2 5 3", | |
| "output": "-1" | |
| } | |
| }, | |
| { | |
| "code_id": 3, | |
| "code": "#ifndef _MENCI_AVL_TREE_H\n\n#define _MENCI_AVL_TREE_H\n\n\n\n#include <stdbool.h>\n\n#include <stddef.h>\n\n\n\ntypedef int (*compare_function_t)(void *, void *);\n\ntypedef void (*destruct_function_t)(void *);\n\ntypedef struct _avl_node_t *avl_node_t;\n\ntypedef struct _avl_tree_t *avl_tree_t;\n\n\n\navl_tree_t avl_create(compare_function_t compare_function, destruct_function_t destruct_function);\n\nvoid avl_destroy(avl_tree_t tree);\n\nsize_t avl_size(avl_tree_t tree);\n\navl_node_t avl_insert(avl_tree_t tree, void *data);\n\nvoid *avl_get_data(avl_node_t node);\n\navl_node_t avl_find(avl_tree_t tree, void *data);\n\navl_node_t avl_find_by_order(avl_tree_t tree, int order);\n\nint avl_get_order(avl_tree_t tree, void *data);\n\nint avl_get_order_of_node(avl_node_t node);\n\nvoid avl_delete_node(avl_node_t node);\n\nbool avl_delete_data(avl_tree_t tree, void *data);\n\n\n\navl_node_t avl_lower_bound(avl_tree_t tree, void *data);\n\navl_node_t avl_upper_bound(avl_tree_t tree, void *data);\n\navl_node_t avl_node_predecessor(avl_node_t node);\n\navl_node_t avl_node_successor(avl_node_t node);\n\n\n\n#endif // _MENCI_AVL_TREE_H\n\n#ifndef _MENCI_AVL_TREE_INTERNEL_H\n\n#define _MENCI_AVL_TREE_INTERNEL_H\n\n\n\n// #include \"avl-tree.h\"\n\n\n\nstruct _avl_node_t {\n\n struct _avl_node_t *left_child;\n\n struct _avl_node_t *right_child;\n\n struct _avl_node_t *parent;\n\n\n\n // The data field.\n\n void *data;\n\n\n\n // The height of the subtree with this node as its root.\n\n int height;\n\n\n\n // The count of nodes in this subtree.\n\n size_t size;\n\n\n\n // The reference to its tree, to replace the root node when rotated to root.\n\n struct _avl_tree_t *tree;\n\n};\n\n\n\nstruct _avl_tree_t {\n\n // The root node of the tree.\n\n avl_node_t root;\n\n\n\n // The compare function, to determine the order of nodes' data.\n\n compare_function_t compare_function;\n\n\n\n // The destruct function, to destruct and free nodes' data.\n\n destruct_function_t destruct_function;\n\n};\n\n\n\ntypedef enum {\n\n LEFT = 0, RIGHT = 1\n\n} _avl_which_child_t;\n\n\n\n// Validate and print a subtree, for debugging.\n\nvoid _avl_debug(avl_node_t node, bool print, int depth);\n\n\n\n// Compare two data or node's data, compare by unsigned long if\n\n// compare_function is NULL or call the compare_function if non-NULL.\n\nint _avl_compare_data(compare_function_t compare_function, void *a, void *b);\n\nint _avl_compare_node(avl_node_t a, avl_node_t b);\n\n\n\n// Destroy a node or a subtree.\n\nvoid _avl_destroy_node(avl_node_t node);\n\nvoid _avl_destroy_subtree(avl_node_t node);\n\n\n\n// Recalculate a node's height and size after rotating, rebalancing, insertion\n\n// or deletion.\n\nvoid _avl_recalculate(avl_node_t node);\n\n\n\n// Rotate a node up, to take its parent's place.\n\n// e.g. Left rotate will let one's right-child take its place of subtree root.\n\nvoid _avl_rotate(avl_node_t node);\n\n\n\n// Do a rebalance on a subtree's root level, used when abs(balance factor) = 2.\n\nvoid _avl_rebalance(avl_node_t subtree_root, avl_node_t new_node);\n\n\n\n// Insert a node to a node's subtree.\n\nvoid _avl_insert_node(avl_node_t *subtree_root,\n\n avl_node_t parent,\n\n avl_node_t new_node);\n\n\n\ntypedef enum {\n\n // Doing a lower_bound binary search means skip all nodes less than specfied data.\n\n // So skip all nodes that compare(node->data, data) <= -1.\n\n // For the same reason, doing a upper_bound binary search skips all nodes that\n\n // compare() <= 0.\n\n // So skip nodes that compare() <= search_type will do the magic.\n\n LOWER_BOUND = -1,\n\n UPPER_BOUND = 0\n\n} _avl_search_type_t;\n\n\n\n// Binary Search a data, return found node according to search_type.\n\navl_node_t _avl_binary_search(avl_node_t root,\n\n void *data,\n\n _avl_search_type_t search_type);\n\n\n\n// Get a node's in-order predecessor or successor.\n\n// direction = LEFT means predecessor, RIGHT means successor.\n\navl_node_t _avl_neighbour(avl_node_t node, _avl_which_child_t direction);\n\n\n\n// Swap two node's position.\n\nvoid _avl_swap(avl_node_t a, avl_node_t b);\n\n\n\n// Delete a node, while maintaining the balance.\n\nvoid _avl_delete_rebalance(avl_node_t node);\n\nvoid _avl_delete(avl_node_t node);\n\n\n\nint _avl_get_order(avl_node_t node);\n\n\n\n#endif // _MENCI_AVL_TREE_INTERNEL_H\n\n// #include \"avl-tree-internel.h\"\n\n\n\n#include <assert.h>\n\n#include <stdlib.h>\n\n#include <stdio.h>\n\n\n\n#define _avl_which_child(node) \\\n\n ((node) == (node)->parent->left_child ? LEFT : RIGHT)\n\n#define _avl_get_child(node, which) \\\n\n (*((which) == LEFT ? (&(node)->left_child) : (&(node)->right_child)))\n\n#define _avl_subtree_height(node) ((node) ? ((node)->height) : 0)\n\n\n\nvoid _avl_debug(avl_node_t node, bool print, int depth) {\n\n if (!node) return;\n\n\n\n if (print && !depth) puts(\"-------------------\");\n\n\n\n int right_height = 0;\n\n size_t right_size = 0;\n\n if (node->right_child) {\n\n assert(node->right_child->parent == node);\n\n _avl_debug(node->right_child, print, depth + 1);\n\n right_height = node->right_child->height;\n\n right_size = node->right_child->size;\n\n }\n\n\n\n if (print) {\n\n for (int i = 0; i < depth; i++) fputs(\" \", stdout);\n\n printf(\"%lu\\n\", (unsigned long)node->data);\n\n }\n\n\n\n int left_height = 0;\n\n size_t left_size = 0;\n\n if (node->left_child) {\n\n assert(node->left_child->parent == node);\n\n _avl_debug(node->left_child, print, depth + 1);\n\n left_height = node->left_child->height;\n\n left_size = node->left_child->size;\n\n }\n\n\n\n\n\n if (print && !depth) puts(\"-------------------\");\n\n\n\n int max = left_height < right_height ? right_height : left_height;\n\n assert(node->height == max + 1);\n\n assert(node->size == left_size + right_size + 1);\n\n assert(abs(left_height - right_height) < 2);\n\n}\n\n\n\nint _avl_compare_data(compare_function_t compare_function, void *a, void *b) {\n\n if (a == b) return 0;\n\n if (compare_function) {\n\n return compare_function(a, b);\n\n }\n\n\n\n return (unsigned long)a < (unsigned long)b ? -1 : 1;\n\n}\n\n\n\nint _avl_compare_node(avl_node_t a, avl_node_t b) {\n\n assert(a && b && a->tree == b->tree);\n\n if (a == b) return 0;\n\n return _avl_compare_data(a->tree->compare_function, a->data, b->data);\n\n}\n\n\n\nvoid _avl_destroy_node(avl_node_t node) {\n\n if (node->tree->destruct_function) {\n\n node->tree->destruct_function(node->data);\n\n }\n\n\n\n free(node);\n\n}\n\n\n\nvoid _avl_destroy_subtree(avl_node_t node) {\n\n if (node->left_child) _avl_destroy_subtree(node->left_child);\n\n if (node->right_child) _avl_destroy_subtree(node->right_child);\n\n _avl_destroy_node(node);\n\n}\n\n\n\nvoid _avl_recalculate(avl_node_t node) {\n\n assert(node);\n\n\n\n int max_height = 0;\n\n node->size = 1;\n\n\n\n if (node->left_child) {\n\n if (node->left_child->height > max_height)\n\n max_height = node->left_child->height;\n\n node->size += node->left_child->size;\n\n }\n\n if (node->right_child) {\n\n if (node->right_child->height > max_height)\n\n max_height = node->right_child->height;\n\n node->size += node->right_child->size;\n\n }\n\n \n\n node->height = max_height + 1;\n\n}\n\n\n\nvoid _avl_rotate(avl_node_t node) {\n\n assert(node && node->parent);\n\n\n\n avl_node_t old_parent = node->parent;\n\n\n\n _avl_which_child_t which = _avl_which_child(node), another = !which;\n\n\n\n // Connect self to old parent's parent.\n\n node->parent = old_parent->parent;\n\n if (old_parent->parent)\n\n _avl_get_child(old_parent->parent, _avl_which_child(old_parent)) = node;\n\n \n\n // Connect self's another child to old parent\n\n if (_avl_get_child(node, another)) {\n\n _avl_get_child(node, another)->parent = old_parent;\n\n }\n\n _avl_get_child(old_parent, which) = _avl_get_child(node, another);\n\n\n\n // Connect old parent to self\n\n old_parent->parent = node;\n\n _avl_get_child(node, another) = old_parent;\n\n\n\n // Notice that the ancestors of old_parent's height are NOT recalculated.\n\n _avl_recalculate(old_parent);\n\n _avl_recalculate(node);\n\n\n\n // Check if rotated to root.\n\n if (!node->parent) {\n\n node->tree->root = node;\n\n }\n\n}\n\n\n\nvoid _avl_insert_node(avl_node_t *subtree_root,\n\n avl_node_t parent,\n\n avl_node_t new_node) {\n\n if (!*subtree_root) {\n\n new_node->parent = parent;\n\n *subtree_root = new_node;\n\n return;\n\n }\n\n\n\n avl_node_t current = *subtree_root;\n\n\n\n if (_avl_compare_node(new_node, current) <= 0) {\n\n // new data <= current node's data\n\n _avl_insert_node(¤t->left_child, current, new_node);\n\n\n\n // Check balance.\n\n if (_avl_subtree_height(current->left_child) - \n\n _avl_subtree_height(current->right_child) == 2) {\n\n // The balance has been broken, rebalance it.\n\n // Check which child of left-child it's inserted to.\n\n if (_avl_compare_node(new_node, current->left_child) <= 0) {\n\n // The Left-Left case.\n\n _avl_rotate(current->left_child);\n\n } else {\n\n // The Left-Right case.\n\n _avl_rotate(current->left_child->right_child);\n\n _avl_rotate(current->left_child);\n\n }\n\n }\n\n } else {\n\n // new data > current node's data\n\n _avl_insert_node(¤t->right_child, current, new_node);\n\n\n\n // Check balance.\n\n if (_avl_subtree_height(current->right_child) - \n\n _avl_subtree_height(current->left_child) == 2) {\n\n // The balance has been broken, rebalance it.\n\n // Check which child of right-child it's inserted to.\n\n if (_avl_compare_node(new_node, current->right_child) <= 0) {\n\n // The Right-Left case.\n\n _avl_rotate(current->right_child->left_child);\n\n _avl_rotate(current->right_child);\n\n } else {\n\n // The Right-Right case.\n\n _avl_rotate(current->right_child);\n\n }\n\n }\n\n }\n\n\n\n _avl_recalculate(*subtree_root);\n\n}\n\n\n\navl_node_t _avl_binary_search(avl_node_t root,\n\n void *data,\n\n _avl_search_type_t search_type) {\n\n if (!root) return NULL;\n\n\n\n int compare_result = _avl_compare_data(root->tree->compare_function,\n\n root->data,\n\n data);\n\n\n\n // Since we should find the first satisfied node, search in the left\n\n // subtree if satisfied.\n\n bool satisfied = compare_result > search_type;\n\n if (satisfied) {\n\n avl_node_t left_subtree_result = _avl_binary_search(root->left_child,\n\n data,\n\n search_type);\n\n // If a more left satisfied node was found, return it.\n\n if (left_subtree_result) return left_subtree_result;\n\n else return root;\n\n } else {\n\n return _avl_binary_search(root->right_child,\n\n data,\n\n search_type);\n\n }\n\n}\n\n\n\navl_node_t _avl_neighbour(avl_node_t node, _avl_which_child_t direction) {\n\n assert(node);\n\n\n\n // Imagine a traversal on the tree. We are on the node now and willing to\n\n // move to the in-order (or reversed in-order) next node.\n\n // e.g. find one's successor, with direction = RIGHT.\n\n if (_avl_get_child(node, direction)) {\n\n // If RIGHT subtree, find in the subtree.\n\n // Find the LEFT-most descendant of node's RIGHT subtree.\n\n node = _avl_get_child(node, direction);\n\n while (_avl_get_child(node, !direction)) {\n\n node = _avl_get_child(node, !direction);\n\n }\n\n return node;\n\n } else {\n\n // The RIGHT subtree doesn't exist, backtraces will occur.\n\n if (!node->parent) {\n\n // Backtrace reaches root. No successor found!\n\n return NULL;\n\n }\n\n\n\n while (_avl_which_child(node) == direction) {\n\n // If node is its parent's RIGHT child, after backtracing to parent,\n\n // another backtrace will occur to parent's parent.\n\n if (!node->parent->parent) {\n\n // Backtrace reaches root. No successor found!\n\n return NULL;\n\n }\n\n\n\n node = node->parent;\n\n }\n\n\n\n // If node is its parent's LEFT child, the next to be printed in the\n\n // traversal is just its parent!\n\n return node->parent;\n\n }\n\n}\n\n\n\nvoid _avl_swap(avl_node_t a, avl_node_t b) {\n\n assert(a && b);\n\n\n\n#define _avl_reconnect(parent_node, child, which) { \\\n\n if (parent_node) { \\\n\n _avl_get_child((parent_node), (which)) = (child); \\\n\n } else { \\\n\n assert(child); \\\n\n (child)->tree->root = (child); \\\n\n } \\\n\n if (child) (child)->parent = (parent_node); \\\n\n }\n\n\n\n // If one is another's parent, assume a is b's parent.\n\n if (a->parent == b) {\n\n _avl_swap(b, a);\n\n }\n\n\n\n _avl_which_child_t which_a = a->parent ? _avl_which_child(a) : LEFT,\n\n which_b = b->parent ? _avl_which_child(b) : LEFT;\n\n\n\n if (a == b->parent) {\n\n // If a is b's parent.\n\n avl_node_t c1 = _avl_get_child(b, which_b),\n\n c2 = _avl_get_child(b, !which_b),\n\n c3 = _avl_get_child(a, !which_b);\n\n \n\n _avl_reconnect(a->parent, b, which_a);\n\n\n\n _avl_reconnect(a, c1, which_b);\n\n _avl_reconnect(a, c2, !which_b);\n\n\n\n _avl_reconnect(b, a, which_b);\n\n _avl_reconnect(b, c3, !which_b);\n\n } else {\n\n avl_node_t a_l = a->left_child, a_r = a->right_child,\n\n b_l = b->left_child, b_r = b->right_child;\n\n\n\n avl_node_t a_p = a->parent, b_p = b->parent;\n\n _avl_reconnect(a_p, b, which_a);\n\n _avl_reconnect(b_p, a, which_b);\n\n\n\n _avl_reconnect(a, b_l, LEFT);\n\n _avl_reconnect(a, b_r, RIGHT);\n\n\n\n _avl_reconnect(b, a_l, LEFT);\n\n _avl_reconnect(b, a_r, RIGHT);\n\n }\n\n\n\n#undef _avl_reconnect\n\n}\n\n\n\nvoid _avl_delete_rebalance(avl_node_t node) {\n\n if (!node) return;\n\n\n\n if (_avl_subtree_height(node->left_child) - \n\n _avl_subtree_height(node->right_child) == 2) {\n\n // L - R = 2\n\n\n\n if (_avl_subtree_height(node->left_child->left_child) >=\n\n _avl_subtree_height(node->left_child->right_child)) {\n\n // The Left-Left case.\n\n _avl_rotate(node->left_child);\n\n } else {\n\n // The Left-Right case.\n\n _avl_rotate(node->left_child->right_child);\n\n _avl_rotate(node->left_child);\n\n }\n\n } else if (_avl_subtree_height(node->right_child) - \n\n _avl_subtree_height(node->left_child) == 2) {\n\n // R - L = 2\n\n\n\n if (_avl_subtree_height(node->right_child->left_child) <=\n\n _avl_subtree_height(node->right_child->right_child)) {\n\n // The Right-Right case.\n\n _avl_rotate(node->right_child);\n\n } else {\n\n // The Right-Left case.\n\n _avl_rotate(node->right_child->left_child);\n\n _avl_rotate(node->right_child);\n\n }\n\n }\n\n\n\n _avl_recalculate(node);\n\n _avl_delete_rebalance(node->parent);\n\n}\n\n\n\nvoid _avl_delete(avl_node_t node) {\n\n assert(node);\n\n\n\n while (node->left_child || node->right_child) {\n\n // Both children exist.\n\n // In this case its in-order predecessor or successor must be its descendant.\n\n // Find it's in-order predecessor or successor to take its place.\n\n avl_node_t neighbour = _avl_neighbour(node, node->left_child ? LEFT : RIGHT);\n\n\n\n // Swap the node and its neighbour.\n\n _avl_swap(node, neighbour);\n\n }\n\n\n\n // Now the node has no child, delete it.\n\n if (!node->parent) {\n\n node->tree->root = NULL;\n\n } else {\n\n _avl_get_child(node->parent, _avl_which_child(node)) = NULL;\n\n }\n\n\n\n // Since deleting a node breaks the balance, rebalance it.\n\n _avl_delete_rebalance(node->parent);\n\n\n\n _avl_destroy_node(node);\n\n}\n\n\n\nint _avl_get_order(avl_node_t node) {\n\n assert(node);\n\n \n\n int count = node->left_child ? node->left_child->size : 0;\n\n while (node->parent) {\n\n if (_avl_which_child(node) == RIGHT) {\n\n // If node is a RIGHT child, the parent and parent's LEFT subtree\n\n // is lesser than node, so add them to the count.\n\n if (node->parent->left_child) {\n\n count += node->parent->left_child->size;\n\n }\n\n count++;\n\n }\n\n\n\n node = node->parent;\n\n }\n\n\n\n return count + 1;\n\n}\n\n// #include \"avl-tree.h\"\n\n\n\n#include <stdlib.h>\n\n#include <assert.h>\n\n\n\n// #include \"avl-tree-internel.h\"\n\n\n\navl_tree_t avl_create(compare_function_t compare_function, destruct_function_t destruct_function) {\n\n avl_tree_t tree = malloc(sizeof(struct _avl_tree_t));\n\n tree->root = NULL;\n\n tree->compare_function = compare_function;\n\n tree->destruct_function = destruct_function;\n\n return tree;\n\n}\n\n\n\nvoid avl_destroy(avl_tree_t tree) {\n\n assert(tree);\n\n \n\n if (tree->root) _avl_destroy_subtree(tree->root);\n\n free(tree);\n\n}\n\n\n\nsize_t avl_size(avl_tree_t tree) {\n\n assert(tree);\n\n return tree->root ? tree->root->size : 0;\n\n}\n\n\n\navl_node_t avl_insert(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n\n\n avl_node_t new_node = malloc(sizeof(struct _avl_node_t));\n\n new_node->left_child = new_node->right_child = new_node->parent = NULL;\n\n new_node->data = data;\n\n new_node->height = 1;\n\n new_node->size = 1;\n\n new_node->tree = tree;\n\n \n\n _avl_insert_node(&tree->root, NULL, new_node);\n\n\n\n return new_node;\n\n}\n\n\n\nvoid *avl_get_data(avl_node_t node) {\n\n return node->data;\n\n}\n\n\n\navl_node_t avl_find(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n\n\n if (!tree->root) return NULL;\n\n\n\n avl_node_t node = avl_lower_bound(tree, data);\n\n if (node && node->data == data) return node;\n\n\n\n return NULL;\n\n}\n\n\n\navl_node_t avl_find_by_order(avl_tree_t tree, int order) {\n\n assert(tree);\n\n \n\n avl_node_t node = tree->root;\n\n\n\n // How many nodes should be skipped from the leftist of node's subtree.\n\n int count = order - 1;\n\n while (1) {\n\n if (!node) {\n\n // Not found - order isn't in [1, tree->root->size].\n\n return NULL;\n\n }\n\n\n\n int left_count = node->left_child ? node->left_child->size : 0;\n\n if (count < left_count) {\n\n // Skip part of the left subtree, not the whole left subtree.\n\n // So the node to find must be in the left subtree.\n\n node = node->left_child;\n\n } else if (count > left_count) {\n\n // The whole left subtree should be skipped, and node itself should\n\n // be skipped, too.\n\n // So skip them and find the node in the right subtree.\n\n count -= left_count + 1;\n\n node = node->right_child;\n\n } else {\n\n // The node to skip is exactly the whole left subtree.\n\n // So current node is what we're finding.\n\n return node;\n\n }\n\n }\n\n}\n\n\n\nint avl_get_order(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n\n\n avl_node_t node = avl_find(tree, data);\n\n if (!node) return -1;\n\n return avl_get_order_of_node(node);\n\n}\n\n\n\nint avl_get_order_of_node(avl_node_t node) {\n\n assert(node);\n\n\n\n return _avl_get_order(node);\n\n}\n\n\n\nvoid avl_delete_node(avl_node_t node) {\n\n assert(node);\n\n\n\n _avl_delete(node);\n\n}\n\n\n\nbool avl_delete_data(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n\n\n avl_node_t node = avl_find(tree, data);\n\n if (!node) return false;\n\n\n\n avl_delete_node(node);\n\n return true;\n\n}\n\n\n\navl_node_t avl_lower_bound(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n return _avl_binary_search(tree->root, data, LOWER_BOUND);\n\n}\n\n\n\navl_node_t avl_upper_bound(avl_tree_t tree, void *data) {\n\n assert(tree);\n\n return _avl_binary_search(tree->root, data, UPPER_BOUND);\n\n}\n\n\n\navl_node_t avl_node_predecessor(avl_node_t node) {\n\n assert(node);\n\n return _avl_neighbour(node, LEFT);\n\n}\n\n\n\navl_node_t avl_node_successor(avl_node_t node) {\n\n assert(node);\n\n return _avl_neighbour(node, RIGHT);\n\n}\n\n// #include \"avl-tree.h\"\n\n\n\n#include <stdio.h>\n\n#include <assert.h>\n\n\n\n#define data_type_from_int(x) ((void *)(long)(x))\n\n#define data_type_to_int(x) ((int)(long)(x))\n\n\n\nint compare(void *a, void *b) {\n\n return data_type_to_int(a) - data_type_to_int(b);\n\n}\n\n\n\nint main() {\n\n avl_tree_t tree = avl_create(&compare, NULL);\n\n\n\n int n;\n\n assert(scanf(\"%d\", &n) == 1);\n\n assert(n >= 1 && n <= (int)3e5);\n\n\n\n for (int i = 0; i < n; i++) {\n\n int option, x;\n\n assert(scanf(\"%d %d\", &option, &x) == 2);\n\n assert(option >= 0 && option <= 5);\n\n\n\n if (option == 0) {\n\n avl_insert(tree, data_type_from_int(x));\n\n } else if (option == 1) {\n\n avl_delete_data(tree, data_type_from_int(x));\n\n } else if (option == 2) {\n\n avl_node_t node = avl_find_by_order(tree, x);\n\n assert(node);\n\n printf(\"%d\\n\", data_type_to_int(avl_get_data(node)));\n\n } else if (option == 3) {\n\n avl_node_t node = avl_lower_bound(tree, data_type_from_int(x));\n\n int answer;\n\n if (node) {\n\n answer = avl_get_order_of_node(node) - 1;\n\n } else {\n\n answer = avl_size(tree);\n\n }\n\n printf(\"%d\\n\", answer);\n\n } else if (option == 4) {\n\n avl_node_t node = avl_lower_bound(tree, data_type_from_int(x)),\n\n predecessor = node ? avl_node_predecessor(node) : NULL;\n\n if (predecessor) {\n\n printf(\"%d\\n\", data_type_to_int(avl_get_data(predecessor)));\n\n } else {\n\n puts(\"-1\");\n\n }\n\n } else if (option == 5) {\n\n avl_node_t successor = avl_upper_bound(tree, data_type_from_int(x));\n\n if (successor) {\n\n printf(\"%d\\n\", data_type_to_int(avl_get_data(successor)));\n\n } else {\n\n puts(\"-1\");\n\n }\n\n }\n\n }\n\n}\n\n", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "cc1plus: warning: command-line option ‘-std=c99’ is valid for C/ObjC but not for C++\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:263:12: error: expected ‘)’ before ‘==’ token\n 263 | ((node) == (node)->parent->left_child ? LEFT : RIGHT)\n | ~ ^~~\n | )\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp: In function ‘void _avl_rotate(avl_node_t)’:\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:455:54: error: expected primary-expression before ‘,’ token\n 455 | _avl_which_child_t which = _avl_which_child(node), another = !which;\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:465:74: error: expected primary-expression before ‘=’ token\n 465 | _avl_get_child(old_parent->parent, _avl_which_child(old_parent)) = node;\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:471:38: error: expected primary-expression before ‘)’ token\n 471 | if (_avl_get_child(node, another)) {\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:473:38: error: expected primary-expression before ‘->’ token\n 473 | _avl_get_child(node, another)->parent = old_parent;\n | ^~\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:477:39: error: expected primary-expression before ‘=’ token\n 477 | _avl_get_child(old_parent, which) = _avl_get_child(node, another);\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:477:70: error: expected primary-expression before ‘;’ token\n 477 | _avl_get_child(old_parent, which) = _avl_get_child(node, another);\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:485:35: error: expected primary-expression before ‘=’ token\n 485 | _avl_get_child(node, another) = old_parent;\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp: In function ‘_avl_node_t* _avl_neighbour(avl_node_t, _avl_which_child_t)’:\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:677:40: error: expected primary-expression before ‘)’ token\n 677 | if (_avl_get_child(node, direction)) {\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:683:47: error: expected primary-expression before ‘;’ token\n 683 | node = _avl_get_child(node, direction);\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:685:48: error: expected primary-expression before ‘)’ token\n 685 | while (_avl_get_child(node, !direction)) {\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:687:52: error: expected primary-expression before ‘;’ token\n 687 | node = _avl_get_child(node, !direction);\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:707:39: error: expected primary-expression before ‘==’ token\n 707 | while (_avl_which_child(node) == direction) {\n | ^~\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp: In function ‘void _avl_swap(avl_node_t, avl_node_t)’:\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:749:13: error: ‘parent_node’ was not declared in this scope\n 749 | if (parent_node) { \\\n | ^~~~~~~~~~~\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:751:52: error: expected primary-expression before ‘=’ token\n 751 | _avl_get_child((parent_node), (which)) = (child); \\\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:751:55: error: ‘child’ was not declared in this scope\n 751 | _avl_get_child((parent_node), (which)) = (child); \\\n | ^~~~~\nIn file included from /tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:253:\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:755:20: error: ‘child’ was not declared in this scope\n 755 | assert(child); \\\n | ^~~~~\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:761:13: error: ‘child’ was not declared in this scope\n 761 | if (child) (child)->parent = (parent_node); \\\n | ^~~~~\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:761:39: error: ‘parent_node’ was not declared in this scope\n 761 | if (child) (child)->parent = (parent_node); \\\n | ^~~~~~~~~~~\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp: At global scope:\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:769:5: error: expected unqualified-id before ‘if’\n 769 | if (a->parent == b) {\n | ^~\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:777:34: error: ‘a’ was not declared in this scope\n 777 | _avl_which_child_t which_a = a->parent ? _avl_which_child(a) : LEFT,\n | ^\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:783:5: error: expected unqualified-id before ‘if’\n 783 | if (a == b->parent) {\n | ^~\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp: In function ‘_avl_node_t* _avl_neighbour(avl_node_t, _avl_which_child_t)’:\n/tmp/tmpta7fo_8e/acd44a8a-5668-4fdb-a8e2-89af7802b798.cpp:737:1: warning: control reaches end of non-void function [-Wreturn-type]\n 737 | }\n | ^\n" | |
| ], | |
| "tcb_id": "维护全序集", | |
| "query": "# 维护全序集\n## 题目描述\n\n\n如未特别说明,以下所有数据均为整数。\n\n维护一个多重集 $ S $ ,初始为空,有以下几种操作:\n\n1. 把 $ x $ 加入 $ S $\n2. 删除 $ S $ 中的一个 $ x $,保证删除的 $ x $ 一定存在\n3. 求 $ S $ 中第 $ k $ 小\n4. 求 $ S $ 中有多少个元素小于 $ x $\n5. 求 $ S $ 中小于 $ x $ 的最大数\n6. 求 $ S $ 中大于 $ x $ 的最小数\n\n操作共?$ n?$ 次。\n## 输入格式\n第一行一个整数?$ n $,表示共有?$ n $?次操作?。\n\n接下来?$ n $?行,每行为以下几种格式之一?:\n\n* `0?x`,把?$ x $?加入?$ S $\n* `1?x`,删除?$ S $?中的一个?$ x $,保证删除的数在?$ S $?中一定存在\n* `2?k`,求?$ S?$ 中第??$ k?$ 小的数,保证要求的数在?$ S $?中一定存在\n* `3?x`,求?$ S?$ 中有多少个数小于?$ x?$\n* `4?x`,求?$ S?$ 中小于?$ x?$ 的最大数,如果不存在,输出?$ -1?$\n* `5?x`,求?$ S?$ 中大于?$ x?$ 的最小数,如果不存在,输出?$ -1?$\n## 输出格式\n对于每次询问,输出单独一行表示答案。\n## 样例\n输入:\n5\n0 3\n0 4\n2 2\n1 4\n3 3\n输出:\n4\n0\n\n\n## 数据范围与提示\n$ 1 \\leq n \\leq 3 \\times 10 ^ 5, 0?\\leq x \\leq 10 ^ 9 $\n", | |
| "sample": { | |
| "input": "5\n0 3\n0 4\n2 2\n1 4\n3 3", | |
| "output": "4\n0" | |
| } | |
| }, | |
| { | |
| "code_id": 3, | |
| "code": "#include<bits/stdc++.h>\n#include<sys/mman.h>\n#include<fcntl.h>\nusing namespace std;\nusing llt=long long;\nusing llf=long double;\nusing ull=unsigned long long;\n#define Ct const\n#define For(i,a,b,c) for(int i=(a);i<=(b);i+=(c))\n#define For_(i,a,b,c) for(int i=(a);i>=(b);i-=(c))\n#define For_it(i,a,b) for(auto i=(a);i!=(b);++i)\n\nnamespace IO{\n#ifdef ONLINE_JUDGE\n\tint Fin=fileno(stdin);\n#elif defined(UN_FAST)\n#else\n#endif // file\n#ifdef UN_FAST\n\tchar cc;\n\t#define G cc=getchar()\n\t#define C cc\n#else\n\tconst char *I=(char*)mmap(0,1<<30,1,2,Fin,0)-1;\n\t#define G (++I)\n\t#define C (*I)\n#endif // fast (mmap)\n\ttemplate<class T> void read(T &x){x=0;bool f=0; do G,f|=C=='-';while(C<48); while(C>47)x=x*10+(C&15),G; if(f)x=-x;}\n\tvoid read(char& c){do G;while(C<33); c=C;} void read(char* s){int pos=0; do G;while(C<33); while(C>32) s[pos++]=C,G;}\n\tvoid read(string& s){s.clear(); do G;while(C<33); while(C>32) s.push_back(C),G;}\n\ttemplate<class T=int> T read(){T a; read(a); return a;}\n\ttemplate<class T,class... Argc> void read(T &x,Argc&... argc){read(x),read(argc...);}\n#undef G\n#undef C\n#define endl '\\n'\n}using IO::read;\n\nconstexpr int N=1e5+4,BS=N;\n\nnamespace PSTREE{\n\tconstexpr ull M=ULLONG_MAX;\n\tint ls[N<<7],rs[N<<7],nd[N<<7],tot;\n\t#define mid (l+(r-l>>1))\n\tint nnd(Ct int &pre){nd[++tot]=nd[pre],ls[tot]=ls[pre],rs[tot]=rs[pre]; return tot;}\n\tvoid pushup(Ct int &t){nd[t]=nd[ls[t]]+nd[rs[t]];}\n\tvoid add(Ct ull &p,Ct ull &l,Ct ull &r,Ct int &pre,int &t){\n\t\tt=nnd(pre);\n\t\tif(l==r) ++nd[t];\n\t\telse{\n\t\t\tif(p<=mid) add(p,l,mid,ls[pre],ls[t]);\n\t\t\telse add(p,mid+1,r,rs[pre],rs[t]);\n\t\t\tpushup(t);\n\t\t}\n\t}\n\tint get(Ct ull &p,Ct ull &l,Ct ull &r,Ct int &t){\n\t\tif(!t) return 0;\n\t\tif(l==r) return nd[t];\n\t\tif(p<=mid) return get(p,l,mid,ls[t]);\n\t\treturn get(p,mid+1,r,rs[t]);\n\t}\n\t#undef mid\n\tclass PStree{\n\tprivate: int rt[N];\n\tpublic:\n\t\tvoid Add(Ct int &p,Ct ull &v){add(v,0,M,rt[p-1],rt[p]);}\n\t\tint Get(Ct int &l,Ct int &r,Ct ull &v){return r<l?0:get(v,0,M,rt[r])-get(v,0,M,rt[l-1]);}\n\t};\n}using PSTREE::PStree;\nPStree tr;\n\null bpw[N];\n__attribute__((constructor)) void Hash_Init(){bpw[0]=1; For(i,1,N-3,1) bpw[i]=bpw[i-1]*BS;}\nclass HASH{\nprivate: ull hs[N];\npublic:\n\tvoid Init(Ct int &l){For(i,1,l,1) hs[i]=hs[i-1]*BS+read();}\n\tull Get(Ct int &l,Ct int &r){return hs[r]-hs[l-1]*bpw[r-l+1];}\n}hs;\null MkHs(Ct int &l){ull hs=0; For(i,1,l,1) hs=hs*BS+read(); return hs;}\n\nint n,m,k;\nint a[N];\nint main(){\n\tcout.tie(0)->sync_with_stdio(0);\n\tread(n,m,k); hs.Init(n);\n\tFor(i,1,n-k+1,1) tr.Add(i,hs.Get(i,i+k-1));\n\tFor(i,1,m,1){\n\t\tint l,r; read(l,r);\n\t\tif(tr.Get(l,r-k,MkHs(k))) puts(\"No\");\n\t\telse puts(\"Yes\");\n\t}\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpvy9b_scu/827b3263-1c27-4c3d-ac3c-9f83f291cbad.cpp:24:47: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 24 | const char *I=(char*)mmap(0,1<<30,1,2,Fin,0)-1;\n | ^~~\n | sin\n" | |
| ], | |
| "tcb_id": "花神的嘲讽计划", | |
| "query": "# 花神的嘲讽计划\n## 题目背景\n花神是神,一大癖好就是嘲讽大 J,举例如下:\n\n—— 哎你傻不傻的!(hqz:大笨 J)\n\n—— 这道题又被 J 屎过了!!」\n\n—— J 这程序怎么跑这么快!J 要逆袭了!\n\n—— ……\n\n这一天 DJ 在给吾等众蒟蒻讲题,花神在一边做题无聊,就跑到了一边跟吾等众蒟蒻一起听。以下是部分摘录:\n\n1. —— J 你在讲什么!\n\n —— 我在讲 XXX!\n\n —— 哎你傻不傻的!这么麻烦,直接 XXX 再 XXX 就好了!\n\n —— ……\n\n2. —— J 你 XXX 讲过了没?\n\n —— ……\n\n —— 那个都不讲你就讲这个了?哎你傻不傻的!\n\n —— ……\n\n大 J 对这种情景表示非常无语,每每出现这种情况,大 J 都是非常尴尬的。\n## 题目描述\n经过众蒟蒻研究,大 J 在讲课之前会有一个长度为 $n$ 的方案,我们可以把它看作一个数列。\n\n同样,花神在听课之前也会有一个嘲讽方案,有 $m$ 个,每次会在 $x$ 到 $y$ 的这段时间开始嘲讽,为了减少题目难度,每次嘲讽方案的长度固定为 $k$。\n\n花神嘲讽大 J 让大 J 尴尬的条件是:大 J 在 $x \\sim y$ 的时间内没有讲到花神的嘲讽方案,即大 J 的讲课方案中的 $x \\sim y$ 没有花神的嘲讽方案(这样花神会嘲讽大 J 不会,所以不讲)。\n\n经过众蒟蒻努力,在一次讲课之前得到了花神嘲讽的各次方案,大 J 得知了这个消息以后欣喜不已,大 J 想知道花神的每次嘲讽是否会让大 J 尴尬得说不出话来。\n## 输入格式\n第一行三个数 $n, m, k$。\n\n第二行 $n$ 个数,意义如上。\n\n第三行到第 $3 + m - 1$ 行,每行 $k + 2$ 个数,前两个数为 $x, y$,然后 $k$ 个数,意义如上。\n## 输出格式\n对于每一个嘲讽做出一个回答,会尴尬输出 `Yes`,否则输出 `No`。\n## 样例\n输入:\n8 5 3\n1 2 3 4 5 6 7 8\n2 5 2 3 4\n1 8 3 2 1\n5 7 4 5 6\n2 5 1 2 3\n1 7 3 4 5\n\n输出:\nNo\nYes\nYes\nYes\nNo\n\n\n- $2\\sim 5$ 中有 $2,3,4$ 的方案,输出 `No`,表示 DJ 不会尴尬;\n- $1\\sim 8$ 中没有 $3,2,1$ 的方案,输出 `Yes`,表示 DJ 会尴尬;\n- $5\\sim 7$ 中没有 $4,5,6$ 的方案,输出 `Yes`,表示 DJ 会尴尬;\n- $2\\sim 5$ 中没有 $1,2,3$ 的方案,输出 `Yes`,表示 DJ 会尴尬;\n- $1\\sim 7$ 中有 $3,4,5$ 的方案,输出 `No`,表示 DJ 不会尴尬。\n## 数据范围与提示\n题中所有数据不超过 $2 \\times 10^9$,保证方案序列的每个数字 $\\leq n$。", | |
| "sample": { | |
| "input": "8 5 3\n1 2 3 4 5 6 7 8\n2 5 2 3 4\n1 8 3 2 1\n5 7 4 5 6\n2 5 1 2 3\n1 7 3 4 5\n", | |
| "output": "No\nYes\nYes\nYes\nNo\n" | |
| } | |
| }, | |
| { | |
| "code_id": 9, | |
| "code": "#include<bits/stdc++.h>\n#include<sys/mman.h>\n#include<fcntl.h>\nusing namespace std;\nusing llt=long long;\nusing llf=long double;\nusing ull=unsigned long long;\n#define Ct const\n#define For(i,a,b,c) for(int i=(a);i<=(b);i+=(c))\n#define For_(i,a,b,c) for(int i=(a);i>=(b);i-=(c))\n#define For_it(i,a,b) for(auto i=(a);i!=(b);++i)\n\nnamespace IO{\n#ifdef ONLINE_JUDGE\n\tint Fin=fileno(stdin);\n#elif defined(UN_FAST)\n#else\n#endif // file\n#ifdef UN_FAST\n\tchar cc;\n\t#define G cc=getchar()\n\t#define C cc\n#else\n\tconst char *I=(char*)mmap(0,1<<30,1,2,Fin,0)-1;\n\t#define G (++I)\n\t#define C (*I)\n#endif // fast (mmap)\n\ttemplate<class T> void read(T &x){x=0;bool f=0; do G,f|=C=='-';while(C<48); while(C>47)x=x*10+(C&15),G; if(f)x=-x;}\n\tvoid read(char& c){do G;while(C<33); c=C;} void read(char* s){int pos=0; do G;while(C<33); while(C>32) s[pos++]=C,G;}\n\tvoid read(string& s){s.clear(); do G;while(C<33); while(C>32) s.push_back(C),G;}\n\ttemplate<class T=int> T read(){T a; read(a); return a;}\n\ttemplate<class T,class... Argc> void read(T &x,Argc&... argc){read(x),read(argc...);}\n#undef G\n#undef C\n#define endl '\\n'\n}using IO::read;\n\nconstexpr int N=1e5+4,BS=13;\n\nnamespace PSTREE{\n\tconstexpr ull M=ULLONG_MAX;\n\tint ls[N<<7],rs[N<<7],nd[N<<7],tot;\n\t#define mid (l+(r-l>>1))\n\tint nnd(Ct int &pre){nd[++tot]=nd[pre],ls[tot]=ls[pre],rs[tot]=rs[pre]; return tot;}\n\tvoid pushup(Ct int &t){nd[t]=nd[ls[t]]+nd[rs[t]];}\n\tvoid add(Ct ull &p,Ct ull &l,Ct ull &r,Ct int &pre,int &t){\n\t\tt=nnd(pre);\n\t\tif(l==r) ++nd[t];\n\t\telse{\n\t\t\tif(p<=mid) add(p,l,mid,ls[pre],ls[t]);\n\t\t\telse add(p,mid+1,r,rs[pre],rs[t]);\n\t\t\tpushup(t);\n\t\t}\n\t}\n\tint get(Ct ull &p,Ct ull &l,Ct ull &r,Ct int &t){\n\t\tif(!t) return 0;\n\t\tif(l==r) return nd[t];\n\t\tif(p<=mid) return get(p,l,mid,ls[t]);\n\t\treturn get(p,mid+1,r,rs[t]);\n\t}\n\t#undef mid\n\tclass PStree{\n\tprivate: int rt[N];\n\tpublic:\n\t\tvoid Add(Ct int &p,Ct ull &v){add(v,0,M,rt[p-1],rt[p]);}\n\t\tint Get(Ct int &l,Ct int &r,Ct ull &v){return r<l?0:get(v,0,M,rt[r])-get(v,0,M,rt[l-1]);}\n\t};\n}using PSTREE::PStree;\nPStree tr;\n\null bpw[N];\n__attribute__((constructor)) void Hash_Init(){bpw[0]=1; For(i,1,N-3,1) bpw[i]=bpw[i-1]*BS;}\nclass HASH{\nprivate: ull hs[N];\npublic:\n\tvoid Init(Ct int &l){For(i,1,l,1) hs[i]=hs[i-1]*BS+read();}\n\tull Get(Ct int &l,Ct int &r){return hs[r]-hs[l-1]*bpw[r-l+1];}\n}hs;\null MkHs(Ct int &l){ull hs=0; For(i,1,l,1) hs=hs*BS+read(); return hs;}\n\nint n,m,k;\nint a[N];\nint main(){\n\tcout.tie(0)->sync_with_stdio(0);\n\tread(n,m,k); hs.Init(n);\n\tFor(i,1,n-k+1,1) tr.Add(i,hs.Get(i,i+k-1));\n\tFor(i,1,m,1){\n\t\tint l,r; read(l,r);\n\t\tif(tr.Get(l,r-k+1,MkHs(k))) puts(\"No\");\n\t\telse puts(\"Yes\");\n\t}\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmp536c_u_i/4bea3f2d-1032-45a9-aa30-d78b10f51dbc.cpp:24:47: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 24 | const char *I=(char*)mmap(0,1<<30,1,2,Fin,0)-1;\n | ^~~\n | sin\n" | |
| ], | |
| "tcb_id": "花神的嘲讽计划", | |
| "query": "# 花神的嘲讽计划\n## 题目背景\n花神是神,一大癖好就是嘲讽大 J,举例如下:\n\n—— 哎你傻不傻的!(hqz:大笨 J)\n\n—— 这道题又被 J 屎过了!!」\n\n—— J 这程序怎么跑这么快!J 要逆袭了!\n\n—— ……\n\n这一天 DJ 在给吾等众蒟蒻讲题,花神在一边做题无聊,就跑到了一边跟吾等众蒟蒻一起听。以下是部分摘录:\n\n1. —— J 你在讲什么!\n\n —— 我在讲 XXX!\n\n —— 哎你傻不傻的!这么麻烦,直接 XXX 再 XXX 就好了!\n\n —— ……\n\n2. —— J 你 XXX 讲过了没?\n\n —— ……\n\n —— 那个都不讲你就讲这个了?哎你傻不傻的!\n\n —— ……\n\n大 J 对这种情景表示非常无语,每每出现这种情况,大 J 都是非常尴尬的。\n## 题目描述\n经过众蒟蒻研究,大 J 在讲课之前会有一个长度为 $n$ 的方案,我们可以把它看作一个数列。\n\n同样,花神在听课之前也会有一个嘲讽方案,有 $m$ 个,每次会在 $x$ 到 $y$ 的这段时间开始嘲讽,为了减少题目难度,每次嘲讽方案的长度固定为 $k$。\n\n花神嘲讽大 J 让大 J 尴尬的条件是:大 J 在 $x \\sim y$ 的时间内没有讲到花神的嘲讽方案,即大 J 的讲课方案中的 $x \\sim y$ 没有花神的嘲讽方案(这样花神会嘲讽大 J 不会,所以不讲)。\n\n经过众蒟蒻努力,在一次讲课之前得到了花神嘲讽的各次方案,大 J 得知了这个消息以后欣喜不已,大 J 想知道花神的每次嘲讽是否会让大 J 尴尬得说不出话来。\n## 输入格式\n第一行三个数 $n, m, k$。\n\n第二行 $n$ 个数,意义如上。\n\n第三行到第 $3 + m - 1$ 行,每行 $k + 2$ 个数,前两个数为 $x, y$,然后 $k$ 个数,意义如上。\n## 输出格式\n对于每一个嘲讽做出一个回答,会尴尬输出 `Yes`,否则输出 `No`。\n## 样例\n输入:\n8 5 3\n1 2 3 4 5 6 7 8\n2 5 2 3 4\n1 8 3 2 1\n5 7 4 5 6\n2 5 1 2 3\n1 7 3 4 5\n\n输出:\nNo\nYes\nYes\nYes\nNo\n\n\n- $2\\sim 5$ 中有 $2,3,4$ 的方案,输出 `No`,表示 DJ 不会尴尬;\n- $1\\sim 8$ 中没有 $3,2,1$ 的方案,输出 `Yes`,表示 DJ 会尴尬;\n- $5\\sim 7$ 中没有 $4,5,6$ 的方案,输出 `Yes`,表示 DJ 会尴尬;\n- $2\\sim 5$ 中没有 $1,2,3$ 的方案,输出 `Yes`,表示 DJ 会尴尬;\n- $1\\sim 7$ 中有 $3,4,5$ 的方案,输出 `No`,表示 DJ 不会尴尬。\n## 数据范围与提示\n题中所有数据不超过 $2 \\times 10^9$,保证方案序列的每个数字 $\\leq n$。", | |
| "sample": { | |
| "input": "8 5 3\n1 2 3 4 5 6 7 8\n2 5 2 3 4\n1 8 3 2 1\n5 7 4 5 6\n2 5 1 2 3\n1 7 3 4 5\n", | |
| "output": "No\nYes\nYes\nYes\nNo\n" | |
| } | |
| }, | |
| { | |
| "code_id": 6, | |
| "code": "#include <bits/stdc++.h>\n\nusing namespace std;\n\n#define il inline\n\n#define elif else if\n\n\n\n// Type\n\n#define ld double\n\n#define ll long long\n\n#define ull unsigned ll\n\n\n\n// Vector\n\n#define vc vector\n\n#define Pb push_back\n\n#define Pf push_front\n\n#define Eb emplace_back\n\n#define All(x) x.begin(),x.end()\n\n\n\n// Memory\n\n#define Ms(_data) memset(_data,0,sizeof(_data))\n\n#define Msn(_data,_num) memset(_data,_num,sizeof(_data))\n\n\n\n// Template\n\n#define _cl class\n\n#define _tp template\n\n#define _tyn typename\n\n\n\n// Pair\n\n#define Mp make_pair\n\n#define F first\n\n#define S second\n\n#define pii pair<int,int>\n\n#define pli pair<ll,int>\n\n#define pil pair<int,ll>\n\n#define pll pair<ll,ll>\n\n\n\n// Loop\n\n#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )\n\n#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )\n\n#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )\n\n#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )\n\n#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )\n\n#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )\n\n#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )\n\n\n\n// Read\n\nstruct InputReader{\n\n\t#define bs 1000001\n\n\tchar buf[bs]; int p;\n\n\til InputReader(){ p = bs; }\n\n\til void Flush(){ p = 0; fread(buf,1,bs,stdin); }\n\n\til char C(){ if(p >= bs) Flush(); return buf[p++]; }\n\n\til char Readnum(){ char ch = C(); while( !isdigit(ch) && ch != '-' ) ch = C(); return ch; }\n\n\til void Readalpha( char &c ){ c = C(); while( !isalpha(c) ) c = C(); }\n\n\tint operator() (){\n\n\t\tint ans = 0, fu = 1; char ch = Readnum();\n\n\t\tif( ch == '-' ) fu = -1, ch = C();\n\n\t\twhile( ch >= '0' && ch <= '9' ){\n\n\t\t\tans = ans*10 + ch-'0';\n\n\t\t\tch = C();\n\n\t\t}\n\n\t\treturn ans * fu;\n\n\t}\n\n\tll Readll(){\n\n\t\tll ans = 0LL, fu = 1LL; char ch = Readnum();\n\n\t\tif( ch == '-' ) fu = -1LL, ch = C();\n\n\t\twhile( ch >= '0' && ch <= '9' ){\n\n\t\t\tans = ans*10LL + ch-'0';\n\n\t\t\tch = C();\n\n\t\t}\n\n\t\treturn ans * fu;\n\n\t}\n\n\til void Readstring( string &x ){\n\n\t\tx.clear(); char ch = C();\n\n\t\twhile( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' ) ch = C();\n\n\t\twhile( isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.' ){\n\n\t\t\tx += ch;\n\n\t\t\tch = C();\n\n\t\t}\n\n\t}\n\n\til void Readchstring( char s[] ){\n\n\t\tint len = 0; char ch = C();\n\n\t\twhile( !isdigit(ch) && !isalpha(ch) /*&& ch != '*' && ch != '?'*/ ) ch = C();\n\n\t\twhile( isdigit(ch) || isalpha(ch) /*|| ch == '*' || ch == '?'*/ ){\n\n\t\t\ts[len++] = ch;\n\n\t\t\tch = C();\n\n\t\t}\n\n\t\ts[len] = '\\0';\n\n\t}\n\n\til void Specialread( char &c ){\n\n\t\tc = C();\n\n\t\twhile( !isdigit(c) && !isalpha(c) && c != '#' && c != '.' && c != '=' && c != 'B' ) c = C();\n\n\t}\n\n\t#undef bs\n\n}In;\n\nil void Read( int &x ){ x = In(); }\n\nil void Read( int &x, int &y ){ x = In(); y = In(); }\n\nil void Read( int &x1 , int &x2 , int &x3 ){ x1 = In(); x2 = In(); x3 = In(); }\n\nil void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ x1 = In(); x2 = In(); x3 = In(); x4 = In(); }\n\nil void Read( ll &x ){ x = In.Readll(); }\n\nil void Read( ll &x, ll &y ){ x = In.Readll(); y = In.Readll(); }\n\nil void Read( ll &x1 , ll &x2 , ll &x3 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); }\n\nil void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ x1 = In.Readll(); x2 = In.Readll(); x3 = In.Readll(); x4 = In.Readll(); }\n\n_tp<_tyn T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }\n\n#define iRead(k) int k; Read(k);\n\n#define iRead2(a,b) iRead(a); iRead(b);\n\n#define iRead3(a,b,c) iRead2(a,b); iRead(c);\n\n#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);\n\n#define lRead(k) ll k; Read(k);\n\n#define lRead2(a,b) lRead(a); lRead(b);\n\n#define lRead3(a,b,c) lRead2(a,b); lRead(c);\n\n#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);\n\n\n\n// File\n\nil void FILEIO(){\n\n\t#ifdef intLSY\n\n\t\tFin(\"in.in\");\n\n\t#endif\n\n}\n\nil void FILEIO( string pname ){\n\n\t#ifndef intLSY\n\n\t\tFin((pname+\".in\").c_str());\n\n\t\tFout((pname+\".out\").c_str());\n\n\t#else\n\n\t\tFin(\"in.in\");\n\n\t#endif\n\n}\n\nil void FILEIO_OICONTEST( string pname ){\n\n\tFin((pname+\".in\").c_str());\n\n\t#ifndef intLSY\n\n\t\tFout((pname+\".out\").c_str());\n\n\t#endif\n\n}\n\nvoid Printtime(){\n\n\t#ifdef intLSY\n\n\t\tdouble _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;\n\n\t\tfprintf(stderr,\"\\n\\nTime usage:\\n%.0lf ms\\n\",_timeuse);\n\n\t#endif\n\n}\n\nvoid END(){ Printtime(); exit(0); }\n\n_tp<_tyn T>void END( T mes ){ cout << mes << endl; END(); }\n\n\n\n// Debug\n\n#define B cerr << \"BreakPoint\" << endl;\n\n#define O(x) cerr << #x << \" \" << x << endl;\n\n#define O_(x) cerr << #x << \" \" << x << \" \";\n\n#define ERR(x) cerr << \"ERR! #\" << x << endl;\n\n#define Msz(x) cerr << \"Sizeof \" << #x << \" \" << sizeof(x)/1024/1024 << \" MB\" << endl;\n\n_tp<_tyn T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\\n' ){\n\n\tif( s > t ) return;\n\n\tfor( int i = s ; i < t ; i++ )\n\n\t\tcout << a[i] << sp;\n\n\tcout << a[t] << ed;\n\n\tcout.flush();\n\n}\n\n_tp<_tyn T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\\n' ){\n\n\tif( t == -1 ) t = a.size()-1;\n\n\tfor( int i = s ; i <= t ; i++ )\n\n\t\tcout << a[i] << sp;\n\n\tcout << ed;\n\n\tcout.flush();\n\n}\n\n\n\n// Optimize\n\n#define max(a,b) ((a)>(b)?(a):(b))\n\n#define min(a,b) ((a)<(b)?(a):(b))\n\n#define Mymax(a,b) (a) = max((a),(b))\n\n#define Mymin(a,b) (a) = min((a),(b))\n\n#define INF (0x3f3f3f3f)\n\n#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))\n\n\n\n///////////////////////////////////////////////////////////////////////////////////////\n\n///////////////////////////////////////////////////////////////////////////////////////\n\n#define MAXN 131072\n\n\n\nint n,k;\n\nll w[MAXN];\n\n\n\nnamespace SameWi{\n\n\tint depcnt[MAXN];\n\n\tvoid Solve(){\n\n\t\tint leafcnt = 1;\n\n\t\tdepcnt[1] = 1;\n\n\t\tll nowmxleaf = 1;\n\n\t\tFor(i,19){\n\n\t\t\tnowmxleaf *= k;\n\n\t\t\twhile(1){\n\n\t\t\t\tif( depcnt[i]%k == 0 ){\n\n\t\t\t\t\t--depcnt[i-1];\n\n\t\t\t\t\t--leafcnt;\n\n\t\t\t\t}\n\n\t\t\t\t++depcnt[i];\n\n\t\t\t\t++leafcnt;\n\n\t\t\t\tif( leafcnt == n ) break;\n\n\t\t\t\tif( depcnt[i] == nowmxleaf ) break;\n\n\t\t\t}\n\n\t\t\tif( leafcnt == n ) break;\n\n\t\t}\n\n\n\n\t\tll ans = 0;\n\n\t\tint mxdep = 0;\n\n\t\tFor0(i,20){\n\n\t\t\tif(depcnt[i]) Mymax(mxdep,i);\n\n\t\t\tans += 1LL*depcnt[i]*i*w[1];\n\n\t\t}\n\n\t\tcout << ans << endl << mxdep << endl;\n\n\n\n\t\tEND();\n\n\t}\n\n}\n\n\n\nint main(){\n\n\tFILEIO();\n\n\n\n\tRead(n,k);\n\n\tFor(i,n) Read(w[i]);\n\n\tif(all_of(w+1,w+1+n,[=]( ll x ){ return x == w[1]; })){\n\n\t\tSameWi::Solve();\n\n\t}\n\n\n\n\tEND();\n\n}\n\n", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpxf5pvz6k/78249a5a-5f5d-4e48-85f0-01bf702f9859.cpp: In function ‘void FILEIO(std::string)’:\n/tmp/tmpxf5pvz6k/78249a5a-5f5d-4e48-85f0-01bf702f9859.cpp:241:17: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 241 | Fin((pname+\".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpxf5pvz6k/78249a5a-5f5d-4e48-85f0-01bf702f9859.cpp:243:17: error: ‘Fout’ was not declared in this scope\n 243 | Fout((pname+\".out\").c_str());\n | ^~~~\n/tmp/tmpxf5pvz6k/78249a5a-5f5d-4e48-85f0-01bf702f9859.cpp: In function ‘void FILEIO_OICONTEST(std::string)’:\n/tmp/tmpxf5pvz6k/78249a5a-5f5d-4e48-85f0-01bf702f9859.cpp:255:9: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 255 | Fin((pname+\".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpxf5pvz6k/78249a5a-5f5d-4e48-85f0-01bf702f9859.cpp:259:17: error: ‘Fout’ was not declared in this scope\n 259 | Fout((pname+\".out\").c_str());\n | ^~~~\n" | |
| ], | |
| "tcb_id": "荷马史诗", | |
| "query": "# 荷马史诗\n## 题目描述\n> 追逐影子的人,自己就是影子。 ——荷马\r\n\r\nAllison 最近迷上了文学。她喜欢在一个慵懒的午后,细细地品上一杯卡布奇诺,静静地阅读她爱不释手的《荷马史诗》。但是由《奥德赛》和《伊利亚特》组成的鸿篇巨制《荷马史诗》实在是太长了,Allison 想通过一种编码方式使得它变得短一些。\r\n\r\n一部《荷马史诗》中有 $n$ 种不同的单词,从 $1$ 到 $n$ 进行编号。其中第 $i$ 种单词出现的总次数为 $w_i$。Allison 想要用 $k$ 进制串 $s_i$ 来替换第 $i$ 种单词,使得其满足如下要求:\r\n对于任意的 $1 \\leq i,j \\leq n, \\ i \\neq j$,都有:$s_i$ 不是 $s_j$ 的前缀。\r\n\r\n现在 Allison 想要知道,如何选择 $s_i$,才能使替换以后得到的新的《荷马史诗》长度最小。在确保总长度最小的情况下,Allison 还想知道最长的 $s_i$ 的最短长度是多少?\r\n\r\n一些定义:\r\n\r\n一个字符串被称为 $k$ 进制字符串,当且仅当它的每个字符是 $0$ 到 $k?1$ 之间(包括 $0$ 和 $k?1$)的整数。\r\n\r\n字符串 $\\text{Str}_1$ 被称为字符串 $\\text{Str}_2$ 的前缀,当且仅当:存在 $1 \\leq t \\leq m$,使得 $\\text{Str}_1=\\text{Str}_2[1 \\ldots t]$。其中,$m$ 是字符串 $\\text{Str}_2$ 的长度,$\\text{Str}_2[1 \\ldots t]$ 表示 $\\text{Str}_2$ 的前 $t$ 个字符组成的字符串。\n## 输入格式\n输入文件的第一行包含两个正整数 $n,k$,中间用单个空格隔开,表示共有 $n$ 种单词,需要使用 $k$ 进制字符串进行替换。\r\n\r\n接下来 $n$ 行,第 $i+1$ 行包含 $1$ 个非负整数 $w_i$,表示第 $i$ 种单词的出现次数。\n## 输出格式\n输出文件包括两行。\r\n\r\n第一行输出一个整数,为《荷马史诗》经过重新编码以后的最短长度。\r\n\r\n第二行输出一个整数,为保证最短总长度的情况下,最长字符串 $s_i$ 的最短长度。\n## 样例\n### 样例 1\n输入:\n4 2\n1\n1\n2\n2\n输出:\n12\n2\n\n用 $X_{(k)}$ 表示 $X$ 是以 $k$ 进制表示的字符串。\n\n一种最优方案:令 $00_{(2)}$ 替换第一种单词,$01_{(2)}$ 替换第二种单词,$10_{(2)}$ 替换第三种单词,$11_{(2)}$ 替换第四种单词。在这种方案下,编码以后的最短长度为:$1 \\times 2+1 \\times 2+2 \\times 2+2 \\times 2=12$,最长字符串 $s_i$ 的长度为 $2$。\n\n一种非最优方案:令 $000_{(2)}$ 替换第一种单词,$001_{(2)}$ 替换第二种单词,$01_{(2)}$ 替换第三种单词,$1_{(2)}$ 替换第四种单词。在这种方案下,编码以后的最短长度为:$1 \\times 3+1 \\times 3+2 \\times 2+2 \\times 1=12$,最长字符串 $s_i$ 的长度为 $3$。与最优方案相比,文章的长度相同,但是最长字符串的长度更长一些。\n### 样例 2\n输入:\n6 3\n1\n1\n3\n3\n9\n9\n输出:\n36\n3\n\n一种最优方案:令 $000_{(3)}$ 替换第 $1$ 种单词,$001_{(3)}$ 替换第 $2$ 种单词,$01_{(3)}$ 替换第 $3$ 种单词,$02_{(3)}$ 替换第 $4$ 种单词,$1_{(3)}$ 替换第 $5$ 种单词,$2_{(3)}$ 替换第 $6$ 种单词。\n## 数据范围与提示\n对于所有数据,保证 $2 \\leq n \\leq 100000, \\ 2 \\leq k \\leq 9, \\ 0 \\lt w_i \\leq 10^{11}$。选手请注意使用 $64$ 位整数进行输入输出、存储和计算。\r\n\r\n#### 评分方式\r\n对于每个测试点: \r\n若输出文件的第 $1$ 行正确,得到该测试点 $40\\%$ 的分数; \r\n若输出文件完全正确,得到该测试点 $100\\%$ 的分数。", | |
| "sample": { | |
| "input": "4 2\n1\n1\n2\n2", | |
| "output": "12\n2" | |
| } | |
| }, | |
| { | |
| "code_id": 12, | |
| "code": "#include<bits/stdc++.h>\n#define int long long\n#define INF 0x7fffffff\n#define INF64 1e18\nusing namespace std;\n\nconstexpr int N=205;\nconstexpr int p=998244353;\n\nint n[N],m,k;\n\nstruct mat{\n\tint a[N][N];\n\tint *operator[](int x){return a[x];}\n\tmat(){memset(a,0,sizeof a);}\n\tmat operator*(mat x){\n\t\tmat res;\n\t\tfor(int i=1;i<=m;i++)\n\t\t\tfor(int l=1;l<=m;l++)\n\t\t\t\tfor(int j=1;j<=m;j++)\n\t\t\t\t\tres[i][j]+=a[i][l]*x[l][j];\n\t\treturn res;\n\t}\n\tvoid clr(){\n\t\tfor(int i=1;i<=m;i++)\n\t\t\tfor(int j=1;j<=m;j++)\n\t\t\t\ta[i][j]%=p;\n\t}\n\tvoid check(){\n\t\tfor(int i=1;i<=m;i++){\n\t\t\tfor(int j=1;j<=m;j++)\n\t\t\t\tcout<<setw(3)<<a[i][j];\n\t\t\tcout<<'\\n';\n\t\t}\n\t}\n};\n\n\nint det(mat a){\n\tint res=1;\n\tfor(int i=1;i<=n[1];i++)\n\t\tfor(int j=i+1;j<=n[1];j++){\n\t\t\twhile(a[i][i]){\n\t\t\t\tint t=a[j][i]/a[i][i];\n\t\t\t\tfor(int k=i;k<=m;k++)\n\t\t\t\t\ta[j][k]=(a[j][k]-a[i][k]*t%p+p)%p;\n\t\t\t\tswap(a.a[i],a.a[j]);res=-res;\n\t\t\t}\n\t\t\tswap(a.a[i],a.a[j]);res=-res;\n\t\t}\n\tfor(int i=1;i<=n[1];i++) res=res*a[i][i]%p;\n\treturn (res+p)%p;\n}\n\n\t\n\nint cnt[N];\n\nvoid solve(){\n\tcin>>k;\n\tfor(int i=1;i<=k;i++) cin>>n[i];\n\tm=n[1]*2;\n\tmat a;\n\tfor(int i=1;i<k;i++) cin>>cnt[i];\n\tfor(int i=1;i<k;i++){\n\t\tmat b;\n\t\tfor(int j=1;j<=cnt[i];j++){\n\t\t\tint u,v;cin>>u>>v;b[u][v]=1;\n\t\t}\n\t\tif(i==1) a=b;\n\t\telse a=a*b;\n\t\tif(i%4==0) a.clr();\n\t}\n\tcout<<det(a)<<'\\n';\n}\n\nsigned main(){\n\tfile(xpath);\n\tios::sync_with_stdio(false);\n\tint t;cin>>t;\n\twhile(t--) solve();\n\t\n}\n\n", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpgpbz67bo/7b4ee37b-755e-4532-8b9e-01e58d8e231e.cpp: In function ‘int main()’:\n/tmp/tmpgpbz67bo/7b4ee37b-755e-4532-8b9e-01e58d8e231e.cpp:78:14: error: ‘xpath’ was not declared in this scope\n 78 | file(xpath);\n | ^~~~~\n/tmp/tmpgpbz67bo/7b4ee37b-755e-4532-8b9e-01e58d8e231e.cpp:78:9: error: ‘file’ was not declared in this scope\n 78 | file(xpath);\n | ^~~~\n" | |
| ], | |
| "tcb_id": "路径交点", | |
| "query": "# 路径交点\n## 题目描述\n小 L 有一个有向图,图中的顶点可以分为 $k$ 层,第 $i$ 层有 $n_i$ 个顶点,第 $1$ 层与第 $k$ 层**顶点数相同**,即 $n_1 = n_k$,且对于第 $j$($2 \\leq j \\leq k-1$)层,$n_1 \\leq n_j \\leq 2n_1$。对于第 $j$($1 \\leq j < k$)层的顶点,以它们为起点的边只会连向第 $j + 1$ 层的顶点。没有边连向第 $1$ 层的顶点,第 $k$ 层的顶点不会向其他顶点连边。\n\n现在小 L 要从这个图中选出 $n_1$ 条路径,每条路径以第 $1$ 层顶点为起点,第 $k$ 层顶点为终点,并要求**图中的每个顶点至多出现在一条路径中**。更具体地,把每一层顶点按照 $1,2,\\ldots,n_1$ 进行编号,则每条路径可以写为一个 $k$ 元组 $(p_1,p_2,\\ldots,p_k)$,表示这条路径依次经过第 $j$ 层的 $p_j$($1 \\leq p_j \\leq n_j$)号顶点,并且第 $j$($1 \\leq j < k$)层的 $p_j$ 号顶点有一条边连向第 $j+1$ 层的第 $p_{j+1}$ 号顶点。\n\n小 L 把这些路径画在了纸上,发现它们会产生若干个交点。对于两条路径 $P,Q$,分别设它们在第 $j$ 层与第 $j+1$ 层之间的连边为 $(P_j,P_{j+1})$ 与 $(Q_j,Q_{j+1})$,若,\n\n$$\n(P_j-Q_j)\\times(P_{j+1}-Q_{j+1})<0\n$$\n\n则称它们在第 $j$ 层后产生了一个交点。两条路径的交点数为它们在第 $1, 2,\\ldots,k - 1$ 层后产生的交点总数。对于整个路径方案,它的交点数为**两两不同路径间交点数之和**。\n\n\n小 L 现在想知道有偶数个交点的路径方案数比有奇数个交点的路径方案数多多少个。两个路径方案被视为相同的,当且仅当它们的 $n_1$ 条路径按第一层起点编号顺序写下的 $k$ 元组能对应相同。由于最后的结果可能很大,请你输出它对 $998244353$(一个大质数)取模后的值。\n## 输入格式。\n\n本题有多组数据,输入数据第一行一个正整数 $T$ ,表示数据组数。对于每组数据:\n\n第一行一个正整数 $k$,表示一共有 $k$ 层顶点。\n\n第二行包含 $k$ 个整数 $n_1,n_2,\\ldots,n_k$,依次表示每一层的顶点数量。保证 $n_1=n_k$,且 $n_1 \\leq n_i \\leq 2n_1$($2 \\leq i \\leq k-1$)。\n\n第三行包含 $k-1$ 个整数 $m_1,m_2,\\ldots,m_{k-1}$,依次表示第 $j$ 层顶点到第 $j+1$ 层顶点的边数。保证 $m_j \\leq n_j \\times n_{j+1}$。\n\n接下来有 $k-1$ 段输入。第 $j$($1 \\leq j < k$)段输入包含 $m_j$ 行,每一行两个整数 $u,v$,表示第 $j$ 层的 $u$ 号顶点有一条边连向第 $j+1$ 层的 $v$ 号顶点。\n\n数据保证图中不会出现重边。\n## 输出格式\n\n输出共 $T$ 行,每行一个整数,表示该组数据的答案对 $998244353$ 取模后的值。\n## 样例\n输入:\n1\n3\n2 3 2\n4 4\n1 1 \n1 2\n2 1\n2 3\n1 2\n2 1\n3 1\n3 2\n输出:\n1\n\n偶数个交点的方案有 $2$ 个,奇数个交点的方案有 $1$ 个,所以答案为 $1$。\n\n将下表中路径 $1$ 和路径 $2$ 的方案交换,将会得到相同的方案,例如路径 $1$ 为 $(2, 3, 1)$ 且路径 $2$ 为 $(1, 1, 2)$ 的方案与方案 $1$ 是相同的方案,所以不会被计入答案。\n\n| 路径方案 | 路径 $1$ | 路径 $2$ | 交点总数 |\n| :------: | :-------: | :-------: | :------: |\n| $1$ | $(1,1,2)$ | $(2,3,1)$ | $1$ |\n| $2$ | $(1,2,1)$ | $(2,1,2)$ | $2$ |\n| $3$ | $(1,2,1)$ <!-- disable merge --> | $(2,3,2)$ | $0$ |\n## 数据范围与提示\n对于所有测试数据:$2 \\leq k \\leq 100$,$2 \\leq n_1 \\leq 100$,$1 \\leq T \\leq 5$。\n\n每个测试点中,保证 $n_1 > 10$ 的数据只有 $1$ 组。", | |
| "sample": { | |
| "input": "1\n3\n2 3 2\n4 4\n1 1 \n1 2\n2 1\n2 3\n1 2\n2 1\n3 1\n3 2", | |
| "output": "1" | |
| } | |
| }, | |
| { | |
| "code_id": 1, | |
| "code": "// InterestingLSY\n\n// 2659723130\n\n// 《幽灵公主》是真的好看!\n\n#include <bits/stdc++.h>\n\nusing namespace std;\n\n#define il inline\n\n#define elif else if\n\n\n\n// Type\n\n#define ld double\n\n#define ll long long\n\n#define ull unsigned ll\n\n\n\n// Vector\n\n#define vc vector\n\n#define Pb push_back\n\n#define Pf push_front\n\n#define Eb emplace_back\n\n#define All(x) x.begin(), x.end()\n\n#define AllRev(x) x.rbegin(), x.rend()\n\n\n\n// Memory\n\n#define Ms(_data) memset(_data, 0, sizeof(_data))\n\n#define Msn(_data, _num) memset(_data, _num, sizeof(_data))\n\n\n\n// Template\n\n#define _cl class\n\n#define _tp template\n\n#define _tyn typename\n\n\n\n// Pair\n\n#define Mp make_pair\n\n#define F first\n\n#define S second\n\n#define pii pair<int, int>\n\n#define pli pair<ll, int>\n\n#define pil pair<int, ll>\n\n#define pll pair<ll, ll>\n\n\n\n// Loop\n\n#define For(i, j) for (int(i) = 1; (i) <= (j); ++(i))\n\n#define For0(i, j) for (int(i) = 0; (i) < (j); ++(i))\n\n#define Forx(i, j, k) for (int(i) = (j); (i) <= (k); ++(i))\n\n#define Forstep(i, j, k, st) for (int(i) = (j); (i) <= (k); (i) += (st))\n\n#define fOR(i, j) for (int(i) = (j); (i) >= 1; --(i))\n\n#define fOR0(i, j) for (int(i) = (j)-1; (i) >= 0; --(i))\n\n#define fORx(i, j, k) for (int(i) = (k); (i) >= (j); --(i))\n\n\n\n// Read\n\nstruct InputReader {\n\n#define bs 1048576\n\n char buf[bs];\n\n int p;\n\n il InputReader() { p = bs; }\n\n il void Flush() {\n\n p = 0;\n\n fread(buf, 1, bs, stdin);\n\n }\n\n il char C() {\n\n if (p >= bs)\n\n Flush();\n\n return buf[p++];\n\n }\n\n il char Readnum() {\n\n char ch = C();\n\n while (!isdigit(ch) && ch != '-') ch = C();\n\n return ch;\n\n }\n\n il void Readalpha(char &c) {\n\n c = C();\n\n while (!isalpha(c)) c = C();\n\n }\n\n int operator()() {\n\n int ans = 0, fu = 1;\n\n char ch = Readnum();\n\n if (ch == '-')\n\n fu = -1, ch = C();\n\n while (ch >= '0' && ch <= '9') {\n\n ans = ans * 10 + ch - '0';\n\n ch = C();\n\n }\n\n return ans * fu;\n\n }\n\n ll Readll() {\n\n ll ans = 0LL, fu = 1LL;\n\n char ch = Readnum();\n\n if (ch == '-')\n\n fu = -1LL, ch = C();\n\n while (ch >= '0' && ch <= '9') {\n\n ans = ans * 10LL + ch - '0';\n\n ch = C();\n\n }\n\n return ans * fu;\n\n }\n\n il void Readstring(string &x) {\n\n x.clear();\n\n char ch = C();\n\n while (!isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.') ch = C();\n\n while (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') {\n\n x += ch;\n\n ch = C();\n\n }\n\n }\n\n il void Readchstring(char s[]) {\n\n int len = 0;\n\n char ch = C();\n\n while (!isdigit(ch) && !isalpha(ch) /*&& ch != '*' && ch != '?'*/) ch = C();\n\n while (isdigit(ch) || isalpha(ch) /*|| ch == '*' || ch == '?'*/) {\n\n s[len++] = ch;\n\n ch = C();\n\n }\n\n s[len] = '\\0';\n\n }\n\n il void Specialread(char &c) {\n\n c = C();\n\n while (!isdigit(c) && !isalpha(c) && c != '#' && c != '.' && c != '=' && c != 'B') c = C();\n\n }\n\n#undef bs\n\n} In;\n\nil void Read(int &x) { x = In(); }\n\nil void Read(int &x, int &y) {\n\n x = In();\n\n y = In();\n\n}\n\nil void Read(int &x1, int &x2, int &x3) {\n\n x1 = In();\n\n x2 = In();\n\n x3 = In();\n\n}\n\nil void Read(int &x1, int &x2, int &x3, int &x4) {\n\n x1 = In();\n\n x2 = In();\n\n x3 = In();\n\n x4 = In();\n\n}\n\nil void Read(ll &x) { x = In.Readll(); }\n\nil void Read(ll &x, ll &y) {\n\n x = In.Readll();\n\n y = In.Readll();\n\n}\n\nil void Read(ll &x1, ll &x2, ll &x3) {\n\n x1 = In.Readll();\n\n x2 = In.Readll();\n\n x3 = In.Readll();\n\n}\n\nil void Read(ll &x1, ll &x2, ll &x3, ll &x4) {\n\n x1 = In.Readll();\n\n x2 = In.Readll();\n\n x3 = In.Readll();\n\n x4 = In.Readll();\n\n}\n\n_tp<_tyn T> void Read(T a[], int st, int ed) { Forx(i, st, ed) Read(a[i]); }\n\n#define iRead(k) \\\n\n int k; \\\n\n Read(k);\n\n#define iRead2(a, b) \\\n\n iRead(a); \\\n\n iRead(b);\n\n#define iRead3(a, b, c) \\\n\n iRead2(a, b); \\\n\n iRead(c);\n\n#define iRead4(a, b, c, d) \\\n\n iRead2(a, b); \\\n\n iRead2(c, d);\n\n#define lRead(k) \\\n\n ll k; \\\n\n Read(k);\n\n#define lRead2(a, b) \\\n\n lRead(a); \\\n\n lRead(b);\n\n#define lRead3(a, b, c) \\\n\n lRead2(a, b); \\\n\n lRead(c);\n\n#define lRead4(a, b, c, d) \\\n\n lRead2(a, b); \\\n\n lRead2(c, d);\n\n\n\n// File\n\nil void FILEIO() {\n\n#ifdef intLSY\n\n Fin(\"in.in\");\n\n#endif\n\n}\n\nil void FILEIO(string pname) {\n\n#ifndef intLSY\n\n Fin((pname + \".in\").c_str());\n\n Fout((pname + \".out\").c_str());\n\n#else\n\n Fin(\"in.in\");\n\n#endif\n\n}\n\nil void FILEIO_OICONTEST(string pname) {\n\n Fin((pname + \".in\").c_str());\n\n#ifndef intLSY\n\n Fout((pname + \".out\").c_str());\n\n#endif\n\n}\n\nvoid Printtime() {\n\n#ifdef intLSY\n\n double _timeuse = clock() * 1000.0 / CLOCKS_PER_SEC;\n\n fprintf(stderr, \"\\n\\nTime usage:\\n%.0lf ms\\n\", _timeuse);\n\n#endif\n\n}\n\nvoid END() {\n\n Printtime();\n\n exit(0);\n\n}\n\n_tp<_tyn T> void END(T mes) {\n\n cout << mes << endl;\n\n END();\n\n}\n\n\n\n// Debug\n\n#define B cerr << \"BreakPoint\" << endl;\n\n#define O(x) cerr << #x << \" \" << x << endl;\n\n#define o(x) cerr << #x << \" \" << x << \" \";\n\n#define Msz(x) cerr << \"Sizeof \" << #x << \" \" << sizeof(x) / 1024 / 1024 << \" MB\" << endl;\n\n_tp<_tyn T> void Print(T a[], int s, int t, char sp = ' ', char ed = '\\n') {\n\n if (s > t)\n\n return;\n\n for (int i = s; i < t; i++) cout << a[i] << sp;\n\n cout << a[t] << ed;\n\n cout.flush();\n\n}\n\n_tp<_tyn T> void Print(T a, int s = 0, int t = -1, char sp = ' ', char ed = '\\n') {\n\n if (t == -1)\n\n t = a.size() - 1;\n\n for (int i = s; i <= t; i++) cout << a[i] << sp;\n\n cout << ed;\n\n cout.flush();\n\n}\n\n\n\n// Optimize\n\n#define Max(a, b) ((a) > (b) ? (a) : (b))\n\n#define Min(a, b) ((a) < (b) ? (a) : (b))\n\n#define Mymax(a, b) (a) = max((a), (b))\n\n#define Mymin(a, b) (a) = min((a), (b))\n\n#define MyMax(a, b) (a) = Max((a), (b))\n\n#define MyMin(a, b) (a) = Min((a), (b))\n\n#define INF (0x3f3f3f3f)\n\n#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))\n\n#define Sqr(x) ((ull)(x) * (x))\n\n#define Lowbit(a) ((a) & (-(a)))\n\nvc<int> Range(int l, int r) {\n\n vc<int> ret{};\n\n Forx(i, l, r) ret.Pb(i);\n\n return ret;\n\n}\n\nmt19937 Rand(0xe38195e38293); // さん\n\n///////////////////////////////////////////////////////////////////////////////////////\n\n///////////////////////////////////////////////////////////////////////////////////////\n\n\n\n#define MAXN 2000010\n\n#define MAXK 10010\n\n\n\nint N, K, P;\n\nll f[MAXK], cnt[MAXK], last[MAXK];\n\n\n\nint main(void) {\n\n\n\n\tint now;\n\n ll ans = 0;\n\n int c, p;\n\n Read(N, K, P);\n\n\tFor(i, N) {\n\n\t\tRead(c, p);\n\n\t\tif(p<=P) {\n\n\t\t\tnow = i;\n\n\t\t}\n\n\t\tif(now>=last[c]) {\n\n\t\t\tf[c] = cnt[c];\n\n\t\t}\n\n\t\tans += f[c];\n\n\t\t++cnt[c];\n\n\t\tlast[c] = i;\n\n\t}\n\n\tprintf(\"%lld\\n\", ans);\n\n\treturn 0;\n\n}", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp:309:9: error: expected constructor, destructor, or type conversion before ‘(’ token\n 309 | Read(k);\n | ^\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp:331:8: error: conflicting declaration ‘long long int k’\n 331 | ll k; \\\n | ^\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp:307:9: note: previous declaration as ‘int k’\n 307 | int k; \\\n | ^\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp:333:9: error: expected constructor, destructor, or type conversion before ‘(’ token\n 333 | Read(k);\n | ^\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp: In function ‘void FILEIO(std::string)’:\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp:371:5: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 371 | Fin((pname + \".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp:373:5: error: ‘Fout’ was not declared in this scope\n 373 | Fout((pname + \".out\").c_str());\n | ^~~~\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp: In function ‘void FILEIO_OICONTEST(std::string)’:\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp:385:5: error: ‘Fin’ was not declared in this scope; did you mean ‘sin’?\n 385 | Fin((pname + \".in\").c_str());\n | ^~~\n | sin\n/tmp/tmpunesof6i/c4124081-11ed-4696-83a3-5a13f4b706d0.cpp:389:5: error: ‘Fout’ was not declared in this scope\n 389 | Fout((pname + \".out\").c_str());\n | ^~~~\n" | |
| ], | |
| "tcb_id": "选择客栈", | |
| "query": "# 选择客栈\n## 题目描述\n丽江河边有 $n$ 家很有特色的客栈,客栈按照其位置顺序从 $1$ 到 $n$ 编号。\r\n\r\n每家客栈都按照某一种色调进行装饰(总共 $k$ 种,用整数 $0$ ~ $k-1$ 表示),且每家客栈都设有一家咖啡店,每 家咖啡店均有各自的最低消费。\r\n\r\n两位游客一起去丽江旅游,他们喜欢相同的色调,又想尝试两个不同的客栈,因此决定分别住在色调相同的两家客栈中。\r\n\r\n晚上,他们打算选择一家咖啡店喝咖啡,要求咖啡店位于两人住的两家客栈之间(包括他们住的客栈),且咖啡店的最低消费不超过 $p$ 。\r\n\r\n他们想知道总共有多少种选择住宿的方案,保证晚上可以找到一家最低消费不超过 $p$ 元的咖啡店小聚。\n## 输入格式\n输入共 $n+1$ 行。\r\n\r\n第一行三个整数 $n,k,p$ ,每两个整数之间用一个空格隔开,分别表示客栈的个数,色调的数目和能接受的最低消费的最高值;\r\n\r\n接下来的 $n$ 行,第 $i+1$ 行两个整数,之间用一个空格隔开,分别表示 $i$ 号客栈的装饰色调和 $i$ 号客栈的咖啡店的最低消费。\n## 输出格式\n输出只有一行,一个整数,表示可选的住宿方案的总数。\n## 样例\n输入:\n5 2 3\n0 5\n1 3\n0 2\n1 4\n1 5\n输出:\n3\n\n$2$ 人要住同样色调的客栈,所有可选的住宿方案包括:住客栈①③,②④,②⑤,④⑤。\n\n但是若选择住④⑤号客栈的话,④⑤号客栈之间的咖啡店的最低消费是 $4$,而两人能承受的最低消费是 $3$ 元,所以不满足要求。因此只有前 $3$ 种方案可选。\n## 数据范围与提示\n对于 $100\\%$ 的数据,有 $2\\leq n\\leq2\\times 10^6$,$0<k\\leq10^4$ </font>,$0\\leq p\\leq100$,$0\\leq$ 最低消费 $\\leq100$ 。", | |
| "sample": { | |
| "input": "5 2 3\n0 5\n1 3\n0 2\n1 4\n1 5", | |
| "output": "3" | |
| } | |
| }, | |
| { | |
| "code_id": 1, | |
| "code": "#pragma GCC optimize(3)\n#pragma GCC optimize(\"Ofast\")\n#pragma GCC optimize(\"inline\")\n#pragma GCC optimize(\"-fgcse\")\n#pragma GCC optimize(\"-fgcse-lm\")\n#pragma GCC optimize(\"-fipa-sra\")\n#pragma GCC optimize(\"-ftree-pre\")\n#pragma GCC optimize(\"-ftree-vrp\")\n#pragma GCC optimize(\"-fpeephole2\")\n#pragma GCC optimize(\"-ffast-math\")\n#pragma GCC optimize(\"-fsched-spec\")\n#pragma GCC optimize(\"unroll-loops\")\n#pragma GCC optimize(\"-falign-jumps\")\n#pragma GCC optimize(\"-falign-loops\")\n#pragma GCC optimize(\"-falign-labels\")\n#pragma GCC optimize(\"-fdevirtualize\")\n#pragma GCC optimize(\"-fcaller-saves\")\n#pragma GCC optimize(\"-fcrossjumping\")\n#pragma GCC optimize(\"-fthread-jumps\")\n#pragma GCC optimize(\"-funroll-loops\")\n#pragma GCC optimize(\"-fwhole-program\")\n#pragma GCC optimize(\"-freorder-blocks\")\n#pragma GCC optimize(\"-fschedule-insns\")\n#pragma GCC optimize(\"inline-functions\")\n#pragma GCC optimize(\"-ftree-tail-merge\")\n#pragma GCC optimize(\"-fschedule-insns2\")\n#pragma GCC optimize(\"-fstrict-aliasing\")\n#pragma GCC optimize(\"-fstrict-overflow\")\n#pragma GCC optimize(\"-falign-functions\")\n#pragma GCC optimize(\"-fcse-skip-blocks\")\n#pragma GCC optimize(\"-fcse-follow-jumps\")\n#pragma GCC optimize(\"-fsched-interblock\")\n#pragma GCC optimize(\"-fpartial-inlining\")\n#pragma GCC optimize(\"no-stack-protector\")\n#pragma GCC optimize(\"-freorder-functions\")\n#pragma GCC optimize(\"-findirect-inlining\")\n#pragma GCC optimize(\"-fhoist-adjacent-loads\")\n#pragma GCC optimize(\"-frerun-cse-after-loop\")\n#pragma GCC optimize(\"inline-small-functions\")\n#pragma GCC optimize(\"-finline-small-functions\")\n#pragma GCC optimize(\"-ftree-switch-conversion\")\n#pragma GCC optimize(\"-foptimize-sibling-calls\")\n#pragma GCC optimize(\"-fexpensive-optimizations\")\n#pragma GCC optimize(\"-funsafe-loop-optimizations\")\n#pragma GCC optimize(\"inline-functions-called-once\")\n#pragma GCC optimize(\"-fdelete-null-pointer-checks\")\n#include <stdio.h>\n#include <assert.h>\n#include <dlfcn.h>\n#include <string.h>\n#include <gmp.h>\n#include <string>\n#include <unordered_map>\n\nusing namespace std;\n\nstatic_assert(sizeof(unsigned long) == 8);\n\n// dynamic loading for LOJ (useful for machine that is not Intel)\n// for Intel : use setenv(\"LD_PRELOAD\", LIB_PATH, 1) and popen+objdump (but need to access fork() / pipe() and memory allocate)\nstruct DLL \n{\n void *handle;\n unordered_map<string, void *> syms;\n DLL(const char *file) : handle(dlopen(file, RTLD_LAZY)) {}\n ~DLL() { dlclose(handle); }\n void *find_name(const char *name) \n {\n if (unordered_map<string, void *>::iterator it = syms.find(name); it != syms.end()) \n return it->second;\n else\n return syms[name] = dlsym(handle, name);\n }\n template <typename R = void, typename... T>\n R call(const char *name, T... t) \n {\n auto func = reinterpret_cast<R(*)(T...)>(find_name(name));\n return func(t...);\n };\n};\n\nDLL GMP(\"/usr/lib/x86_64-linux-gnu/libgmp.so.10\");\n\nstruct fastIO\n{\n static const int BUFF_SZ = 1 << 18;\n char inbuf[BUFF_SZ], outbuf[BUFF_SZ];\n fastIO()\n {\n setvbuf(stdin, inbuf, _IOFBF, BUFF_SZ);\n setvbuf(stdout, outbuf, _IOFBF, BUFF_SZ);\n }\n} IO;\nint radix_a, radix_b;\nint len_a, len_b;\nchar A[1000005], B[1000005];\nint main()\n{\n scanf(\"%d%d%s\", &radix_a, &radix_b, A);\n mpz_t a;\n GMP.call(\"__gmpz_init\", a);\n GMP.call(\"__gmpz_set_str\", a, A, radix_a);\n GMP.call(\"__gmpz_get_str\", B, radix_b, a);\n puts(B);\n GMP.call(\"__gmpz_clear\", a);\n}\n", | |
| "status": [ | |
| "CE" | |
| ], | |
| "details": [ | |
| "/tmp/tmp3lt5c6yh/52e1114c-f950-4f37-ae6e-dab23a8b6997.cpp:51:10: fatal error: gmp.h: No such file or directory\n 51 | #include <gmp.h>\n | ^~~~~~~\ncompilation terminated.\n" | |
| ], | |
| "tcb_id": "高精度进制转换", | |
| "query": "# 高精度进制转换\n## 题目描述\n\n\n请实现一个程序,将一个非常大的**非负整数**由一个进制转换为另一个进制。\n\n其中需要考虑的有 $62$ 个不同的数位 $\\{\\texttt{0}-\\texttt{9},\\texttt{A}-\\texttt{Z},\\texttt{a}-\\texttt{z}\\}$, 其中在十进制下,有 $\\texttt{A}=10,\\texttt{B}=11,\\dots,\\texttt{Z}=35,\\texttt{a}=36,\\texttt{b}=37,...,\\texttt{z}=61$。\n\n<!--需要注意的是,这里的数位分布和 `Go` 语言中 $62$ 进制的数位分布的大小写是完全相反的,即 `Go` 语言的数位在十进制下为 $\\texttt{a}=10,\\texttt{b}=11,...,\\texttt{z}=35,\\texttt{A}=36,\\texttt{B}=37,...,\\texttt{Z}=61$。如果你企图用 `Go` 语言通过此题,请务必注意这一点。-->\n## 输入格式\n第一行输入两个整数 $a, b$ ,表示输入数字的进制以及输出数字的进制。\n\n第二行输入一个 $a$ 进制非负整数 $X$。\n## 输出格式\n输出一个 $b$ 进制整数,为 $X$ 的 $b$ 进制表示。\n## 样例\n输入:\n36 10\n1AZ\n输出:\n1691\n\n$1\\times 36^2 + 10\\times 36^1 + 35 \\times 36^0=1\\times 10^3 + 6\\times 10^2 + 9\\times 10^1 + 1\\times 10^0$\n## 数据范围与提示\n对于 $100\\%$ 的数据,有:\n\n$2\\le a,b\\le 62$<!--,这意味着**直接使用** `Java\\Python\\PyPy\\Ruby` **现有的进制转换函数**无法通过本题-->。\n\n$1\\le$ $X$ 在 $a$ 进制表示下的长度 $\\le 10^5$。\n\n在 $b\\ge 4$ 时, $1\\le$ $X$ 在 $b$ 进制表示下的长度 $\\le 2\\times 10^5$。\n\n在 $b=3$ 时, $1\\le$ $X$ 在 $b$ 进制表示下的长度 $\\le 3.5\\times 10^5$。\n\n在 $b=2$ 时, $1\\le$ $X$ 在 $b$ 进制表示下的长度 $\\le 3\\times 10^5$。\n\n所有评测数据随机生成。<!--**但是时间和空间设置较紧,请务必在提交的时候直接开启`O2`优化(如果评测机处于波动状态,请开启`Ofast`优化)。**同时,你可能还需要**使用较快的读入输出方式,以及尽可能避免使用`C++`自带的`complex`类。**-->\n", | |
| "sample": { | |
| "input": "36 10\n1AZ", | |
| "output": "1691" | |
| } | |
| } | |
| ] |
Xet Storage Details
- Size:
- 245 kB
- Xet hash:
- 34c1af7ccfb249b2da09dac82488c7f51e182c7dd28849efbd1444ac7c022352
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.