Graph theory/bit operations codeforces Round #285 (Div. 2) C. Misha and Forest

Source: Internet
Author: User

Topic Portal

1 /*2 Test instructions: gives a non-circular graph, the degree of each point and the xor of the adjacent points (a^b^c^ ...)3 graph theory/bit operations: In fact, the problem is very simple. Similar topological sort, first in the degree of 1 first-in pairs, each one less than one degree4 the key is to update the XOR, the essence: a ^ b = c, a ^ c = b, b ^ c = A;5 */6#include <cstdio>7#include <cstring>8#include <cmath>9#include <algorithm>Ten#include <queue> One using namespacestd; A  - Const intMAXN = 7e4 +Ten; - Const intINF =0x3f3f3f3f; the intans[maxn][2]; - intD[MAXN], S[MAXN]; -  - intMainvoid)//codeforces Round #285 (Div. 2) C. Misha and Forest + { -     //freopen ("c.in", "R", stdin); +  A     intN; at      while(SCANF ("%d", &n) = =1) -     { -queue<int>Q; -          for(intI=0; i<n; ++i) -         { -scanf ("%d%d", &d[i], &s[i]); in             if(D[i] = =1) Q.push (i); -         } to  +         intCNT =0; -          while(!q.empty ()) the         { *             intU =Q.front (); Q.pop (); $             if(D[u] = =0)Continue;Panax Notoginseng             intv =S[u]; -ans[++cnt][0] = u; ans[cnt][1] =v; the             if((--d[v]) = =1) Q.push (v); +S[V] = S[v] ^u; A         } the  +printf ("%d\n", CNT); -          for(intI=1; i<=cnt; ++i) $         { $printf ("%d%d\n", ans[i][0], ans[i][1]); -         } -     } the  -     return 0;Wuyi}

Graph theory/bit operations codeforces Round #285 (Div. 2) C. Misha and Forest

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.