Home
Problem
Status
Contest
Workbook
User
Group
Forum
Register
Login
{"managingGroups":{},"author":"16110501005","updateTime":1502326436000,"title":"debug","dislikeCnt":0,"content":"```\n#include\u003ccstdio\u003e\n#include\u003ccstring\u003e\n#include\u003ccmath\u003e\n#include\u003ccstdlib\u003e\n#include\u003cqueue\u003e\n#include\u003calgorithm\u003e\n#include\u003ciostream\u003e\nusing namespace std;\n#define lson root\u003c\u003c1\n#define rson root\u003c\u003c1|1\n#define MID int m \u003d (r+l)/2;\nconst int mmax \u003d 100100;\nconst int inf \u003d 0x3f3f3f3f;\nstruct node\n{\n int sum;\n node operator +(const node \u0026a)\n {\n node t;\n t.sum \u003d a.sum|sum;\n return t;\n }\n}tree[mmax\u003c\u003c2];\nstruct nodeq\n{\n int x,y;\n}num[mmax\u003c\u003c2];\nint n;\nvoid build(int root,int l,int r)\n{\n if(l\u003d\u003dr)\n {\n tree[root].sum \u003d 0;\n return;\n }\n MID\n build(lson,l,m);\n build(rson,m+1,r);\n tree[root] \u003d tree[lson]+tree[rson];\n}\n//void updata(int root,int l,int r,int ql,int qr,int val)\n//{\n// if(qr\u003cl||ql\u003er) return;\n// if(ql\u003c\u003dl\u0026\u0026r\u003c\u003dqr)\n// {\n// tree[root].sum \u003d 0;\n// }\n// MID\n//}\nint updata_tree(int root,int l,int r,int ql,int qr)\n{\n\n if(qr\u003cl||ql\u003er) return 0;\n\n if(ql\u003c\u003dl\u0026\u0026r\u003c\u003dqr)\n {\n if(!tree[root].sum)\n {\n tree[root].sum \u003d 1;\n return 1;\n }\n return 0;\n }\n else\n {\n int flag\u003d0;\n MID\n flag +\u003d updata_tree(lson,l,m,ql,qr);\n flag +\u003dupdata_tree(rson,m+1,r,ql,qr);\n tree[root] \u003d tree[lson]+tree[rson];\n // if(tree[lson].sum\u0026\u0026tree[rson].sum) tree[root].sum \u003d 1;\n if(flag\u003e0)\n return 1;\n }\n\n // return 0;\n}\nint main()\n{\n int t;\n cin\u003e\u003et;\n int hash1[mmax];\n while(t--)\n {\n int top \u003d 0;\n scanf(\"%d\",\u0026n);\n int ans \u003d0;\n for(int i\u003d1;i\u003c\u003dn;i++)\n {\n scanf(\"%d%d\",\u0026num[i].x,\u0026num[i].y);\n hash1[++top] \u003d num[i].x;\n hash1[++top] \u003d num[i].y;\n }\n sort(hash1+1,hash1+1+top);\n top \u003d unique(hash1+1,hash1+1+top)-(hash1+1);\n for(int i\u003dn;i\u003e\u003d1;i--)\n {\n int l \u003d lower_bound(hash1+1,hash1+1+top,num[i].x)-hash1;\n int r \u003d lower_bound(hash1+1,hash1+1+top,num[i].y)-hash1;\n ans+\u003dupdata_tree(1,1,n,l,r);\n }\n printf(\"%d\\n\",ans);\n }\n return 0;\n}\n\n```","likeCnt":2,"createTime":1502326356000,"isWorkbook":false,"viewCnt":1433,"openness":1,"fav":false,"id":191,"trustable":false}