You are not logged in. Please login at to post your questions!


[closed] problem in understanding solution?

I've attended a contest on codeforces. Here is the question. solution::

#include <iostream>
#include <cstdio>
#define rep(a,b) for (int a=0;a<b;a++)
using namespace std;

int n,a[1000100],d[1<<22];

int main()
    cin >> n;
    rep(i,1<<22) d[i]=-1;
    rep(i,n) scanf("%d",&a[i]), d[a[i]]=a[i];
        if (d[i]<0)
                if (((i>>j)&1) && d[i^(1<<j)]>=0)
    rep(i,n) printf("%d ",d[(1<<22)-a[i]-1]);

But how it is working I'm not able to understand. Need help..!

asked 19 Mar '12, 11:11

tarun_007's gravatar image

accept rate: 80%

closed 28 Mar '12, 10:47

(16 Jan '13, 01:32) bondoc734★

The question has been closed for the following reason "Other" by tarun_007 28 Mar '12, 10:47

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 19 Mar '12, 11:11

question was seen: 1,580 times

last updated: 16 Jan '13, 01:32