11736 - Debugging RAM

All about problems in Volume 117. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
durjay
New poster
Posts: 13
Joined: Tue Oct 06, 2009 5:09 pm
Location: ctg

11736 - Debugging RAM

Post by durjay » Sat Dec 19, 2009 9:10 pm

thank u asu
Last edited by durjay on Mon Jan 11, 2010 7:41 pm, edited 1 time in total.

robot
New poster
Posts: 29
Joined: Sun May 24, 2009 8:39 pm

Re: debugging ram

Post by robot » Fri Dec 25, 2009 7:19 pm

HI,
its a easy base conversion problem.
look the input carefully ....
4 4
ab 2
Cd 2
ef 3
gh 1
0101
1111
1111
0101
1010
1010
1010
1000
4
Ab
Cd
ef
gh
b=4 is the number of bits in a byte and v =4 is the total number of variables in the RAM where robot is used.
now ab=2, its means it contains 2 bytes in memory(0101,1111);
Cd=2, its means it contains next 2 bytes in memory(1111,0101);
ef=3, its means it contains next 3 bytes in memory(1010,1010,1010);
gh=1,its means it contains next 1bytes in memory(1000);
now i have 4 quary..
Ab->not found in variable.so,ans ab=
Cd->found this variable in the list so, ans is ->11110101->245(Decimal Conversion).
........
MSB is not important , its only make confusion..
i hope now u r understand....
if u get wa you use unsigned long.
"Teme jabo bole to shopno deki ni"
ASU(sust).

arifcsecu
Learning poster
Posts: 64
Joined: Fri Sep 25, 2009 11:29 am
Location: Chittagong,University of chittagong
Contact:

Re: debugging ram

Post by arifcsecu » Mon Feb 22, 2010 1:16 pm

Code Removed
After accepted.

Critical Input:
8 1
ab 8
11111111
11111111
11111111
11111111
11111111
11111111
11111111
11111111
4
ab
ab
cd
ef

Output:
ab=18446744073709551615
ab=18446744073709551615
cd=
ef=
Try to catch fish rather than asking for some fishes.

tanmoy
New poster
Posts: 18
Joined: Wed Jun 25, 2008 2:25 pm

Re: debugging ram

Post by tanmoy » Sun May 02, 2010 2:54 pm

can anyone plz help me ?? i'm getting wrong ans :(

Code: Select all

#pragma warning ( disable : 4786 )
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<iostream>
#include<map>
#include<vector>
#include<string>
using namespace std;
#define _pf printf
#define _sc scanf

int main(){
	char array[40],temp[20];
	gets(array);
	int a,b,i,j;
	int k;
    vector<string> A;
	vector<int> B;
	map<string,string> M;
	map<string,string>::iterator it;
	sscanf(array,"%d %d",&a,&b);
	for(i = 0; i<b; i++){
		gets(array);
		sscanf(array,"%s %d",temp,&k);
		A.push_back(temp);
		B.push_back(k);
	}
	for(j = 0; j<B.size(); j++){
		int d = B[j];
		string S;
		for(i = 0; i<d; i++){
			gets(temp);
			S += temp;
		}
		M[A[j]] = S;
	}
	gets(temp);
	a = atoi(temp);
	for(j = 0; j<a; j++){
		gets(temp);
		it = M.find(temp);
		if(it!=M.end()){
			string S = (*it).second;
			unsigned long long decimal = 0,bit;
			for(i = 0; i<S.size(); i++){
				bit = S.at(i) - '0';
				decimal = (decimal<<1) + bit;
			}
			printf("%s=%llu\n",temp,decimal);
		}
		else printf("%s=\n",temp);
	}
	return 0;
}

Taman
New poster
Posts: 32
Joined: Sun Oct 11, 2009 8:59 pm
Location: Southeast University

Re: debugging ram

Post by Taman » Mon May 03, 2010 6:34 am

@Tanmoy:
I am afraid you have forgotten that there are multiple test cases(At least your code agrees with me). Make sure that you are taking all the inputs :wink:
Hope it helps. . .

tanmoy
New poster
Posts: 18
Joined: Wed Jun 25, 2008 2:25 pm

Re: debugging ram

Post by tanmoy » Mon May 03, 2010 10:02 am

heeeeeeeyyyyyy taman thanks man i really forgot that.thanks a lot :)

Post Reply

Return to “Volume 117 (11700-11799)”