11716 - Digital Fortress

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

noor_aub
New poster
Posts: 26
Joined: Sat Aug 22, 2009 12:16 pm

11716 - Digital Fortress

Post by noor_aub »

W/A why

Code: Select all


Removed
After A/C
Last edited by noor_aub on Fri Aug 13, 2010 12:17 pm, edited 1 time in total.
neilor
New poster
Posts: 10
Joined: Fri Oct 03, 2008 6:00 pm

Re: 11716 - Digital Fortress

Post by neilor »

Try:

Input:
8
WECGEWHYAAIORTNU
DAVINCICODE
DTFRIAOEGLRSI TS
ASDFASDFASDFASDF
AB ABCABC
ASDFGHASDFGHASDFGHASDFGAB
ASDFGHASDFGHASDFGHASDFGABAB
ASDFGHASDFGHASDFGHASDFGABASDFGHJKLOI

Output:
WEAREWATCHINGYOU
INVALID
DIGITAL FORTRESS
AAAASSSSDDDDFFFF
AAABBB CC
AHGFDSAHGFDSAHGFDSAAGFDSB
INVALID
AAAABHSSSSAJDDDDSKFFFFDLGGGGFOHHHAGI
neilor
New poster
Posts: 10
Joined: Fri Oct 03, 2008 6:00 pm

Re: 11716 - Digital Fortress

Post by neilor »

Also, You must use (for example):
char text[10001];
to read the line and a output that can store 100x100 chars data
example: char output[101][101];
sefakilic
New poster
Posts: 7
Joined: Wed Mar 11, 2009 8:12 pm

Re: 11716 - Digital Fortress

Post by sefakilic »

Hello,
I have tried all of test cases above, all of them seem correct. But I am still getting WA. Here is my code:

Code: Select all

code removed

Code: Select all

--- code removed
		if(sqrt(strLength)*sqrt(strLength) == strLength) {
--- code removed
Yes, I got AC. The problem is the line above. I think, following situation occurs:

let strLength be 4, so sqrt(4) can return 1.9999999999999999999.. and 1.99999.. * 1.99999.. = 3.99999.. so when it is compared with strLength which is 4, its type is converted to int, so it is converted to 3. Although they are equal in real, they are processed as they are not.

Thanks a lot.
Mizanur Rahman(IUK)
New poster
Posts: 12
Joined: Wed Aug 18, 2010 12:07 pm

Re: 11716 - Digital Fortress

Post by Mizanur Rahman(IUK) »

Why WA please help me ,i am tired

Code: Select all

#include<iostream.h>
#include<math.h>
#include<string.h>
#include<stdio.h>

int main()
{
	char a[11050];
	int i,n,j,Case,k,p;
	cin>>Case;
	for(k=0;k<Case;k++)
	{
		scanf("%[^\n]",a);i=getchar();
		n=strlen(a);
	p=sqrt(n);
	if(p*p==n)
	{
		for(j=0;j<p;j++)
		{
			i=j;
		for(;i<n;i=i+p)
			cout<<a[i];
		       }
	     //  cout<<endl;
	}
	else
		cout<<"INVALID";//<<endl;
		if(Case!=k)
		cout<<endl;
	}
	return 0;
}
Boie21
New poster
Posts: 1
Joined: Mon Feb 14, 2011 11:46 am

Re: 11716 - Digital Fortress

Post by Boie21 »

Thanks for taking time to help!!!
Pro.metal
New poster
Posts: 9
Joined: Fri Dec 17, 2010 8:13 pm

Re: 11716 - Digital Fortress

Post by Pro.metal »

getting WA too!! no idea where's the problem.

Code: Select all

removed after AC

:D
Last edited by Pro.metal on Fri Mar 25, 2011 10:01 am, edited 1 time in total.
naseef_07cuet
Learning poster
Posts: 62
Joined: Sat Nov 21, 2009 10:17 pm
Location: CUET,Chittagong,Bangladesh

Re: 11716 - Digital Fortress

Post by naseef_07cuet »

Dear Pro.metal,
you have a silly problem on your code.try to find it.best wishes to you....
If you have determination, you can do anything you want....:)
Halum
New poster
Posts: 2
Joined: Wed Jul 06, 2011 9:30 pm

Re: 11716 - Digital Fortress

Post by Halum »

There is a problem in discription.. Total number of character in the text will not be more 10,000... its wrong.. i tried with char x[10005] but got WA.. then i just changed it to x[100050] & got AC,..
shopnobaj_raju
New poster
Posts: 7
Joined: Wed Oct 19, 2011 5:07 pm

Re: 11716 - Digital Fortress

Post by shopnobaj_raju »

I'm getting WA. Please help :(

Code: Select all

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>

void main()
{
	int t,i,j;
	long int length,k;
	double root;
	char arr[10001],**p;
	scanf("%d",&t);
	fflush(stdin);
	while(t--)
	{
		gets(arr);
		length=strlen(arr);
		root=sqrt(length);
		if(floor(root)==ceil(root))
		{
			k=(int) root;
			p=(char **) malloc(k*sizeof(char *));
			for(i=0;i<root;i++) p[i]=(char *) malloc(k*sizeof(char));
			k=0;
			for(i=0;i<root;i++)
			{
				for(j=0;j<root;j++)
				{
					p[i][j]=arr[k];
					k++;
				}
			}
			for(i=0;i<root;i++)
			{
				for(j=0;j<root;j++)
				{
					putchar(p[j][i]);
				}
			}
			putchar('\n');
		}
		else printf("INVALID\n");
	}
}

			
Pro.metal
New poster
Posts: 9
Joined: Fri Dec 17, 2010 8:13 pm

Re: 11716 - Digital Fortress

Post by Pro.metal »

length=strlen(arr);
root=sqrt(length);
if(floor(root)==ceil(root))
if I am not wrong, i think your are checking if the length is a perfect square. its better if you do it like this

Code: Select all

if(root*root==length)
its better to use printf instead of putchar,also use int main() and return 0;
instead of saving those in a 2d char array, its better if you just print them. malloc is tricky and i hate them :wink:
cse.mehedi
New poster
Posts: 36
Joined: Sun Mar 18, 2012 8:18 am

11716 Why RE???????????

Post by cse.mehedi »

I can't understand why RE, I am so tired!!! Please any one tel me why my code RE. :( :oops: :oops:

Code: Select all

Removed after AC
Last edited by cse.mehedi on Tue Apr 17, 2012 8:49 am, edited 1 time in total.
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11716 Why RE???????????

Post by brianfry713 »

You're assuming there are only up to 1000 characters per line when the problem statement says up to 10000.
Check input and AC output for thousands of problems on uDebug!
cse.mehedi
New poster
Posts: 36
Joined: Sun Mar 18, 2012 8:18 am

Re: 11716 Why RE???????????

Post by cse.mehedi »

brianfry713 wrote:You're assuming there are only up to 1000 characters per line when the problem statement says up to 10000.
Thank You! :)
dante
New poster
Posts: 3
Joined: Fri Aug 10, 2012 4:30 pm

11716 why CE ??

Post by dante »

hi,

I'm getting CE for this code, I don't how to change it, can anyone help ?

Code: Select all

#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;

int main(){
	int n;
	cin>>n;
	getchar();
	for(int i=1; i<=n; i++){
		char ciph[10010], deciph[10010];
		int len, sq;
		gets(ciph);
		len = strlen(ciph);
		sq = sqrt( (float)len );
		if( sq*sq != len ) cout<<"INVALID"<<endl;
		else{
			int dex=0;
			for(int j=0; j<sq; j++ )
				for(int k=0; k<sq; k++, dex++)
					deciph[dex] = ciph[ sq*k + j ];
			deciph[dex]=NULL;
			cout<<deciph<<endl;
		}
	}
	return 0;
}
Post Reply

Return to “Volume 117 (11700-11799)”