621 - Secret Research

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

Moderator: Board moderators

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 621

Post by Obaida » Wed May 21, 2008 8:54 am

I got so many WA.. But I couldn't find my mistake...
Can some body explain it.

Code: Select all

Accepted Now.
Last edited by Obaida on Wed May 21, 2008 11:54 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 621

Post by Obaida » Wed May 21, 2008 11:50 am

Very Easy problem. :)
I found my mistake. Now it's Accepted in 0.000sec.
I was taking the numbers in long long int but it will be in string. Now it works well. :P
try_try_try_try_&&&_try@try.com
This may be the address of success.

zyxw
New poster
Posts: 24
Joined: Sat Mar 22, 2008 5:49 am
Location: Chennai
Contact:

For those who are getting WA...

Post by zyxw » Fri Jun 20, 2008 12:47 pm

I take input as string.

My AC code:
1. Ignores invalid cases like "12345". (No blank line)
2. Prints "\n" for all test case including last one.

Hope this helps someone 8)
I am not totally useless, because I can still be used as a bad example :P

convyusboy
New poster
Posts: 1
Joined: Thu Dec 01, 2011 9:36 am

Re: 621 - Secret Research

Post by convyusboy » Sun Sep 30, 2012 3:51 pm

Code: Select all

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

using namespace std;

int TC;
string s;

int main () {
	scanf ("%s", &TC);
	while (TC --) {
		getline (cin, s);
		if (s == "1" || s == "4" || s == "78")
			printf ("+");
		else {
			int le = s.length ();
			if (le > 1 && s[le - 1] == '5' && s[le - 2] == '3')
				printf ("-");
			else if (le > 1 && s[0] == '9' && s[le - 1] == '4')
				printf ("*");
			else if (le > 2 && s[0] == '1' && s[1] == '9' && s[2] == '0')
				printf ("?");
		}		
		if (TC > 1)
			printf ("\n");
	}
	
	return 0;
}
that is my code, why do I keep getting WA?
somebody helps me please

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 621 - Secret Research

Post by brianfry713 » Mon Oct 01, 2012 9:34 pm

int TC;
scanf ("%s", &TC);
Check input and AC output for thousands of problems on uDebug!

triplemzim
New poster
Posts: 48
Joined: Sat Apr 06, 2013 6:02 pm

Re: ACM 621

Post by triplemzim » Wed Jul 31, 2013 5:57 pm

jjtse wrote:
Ming Han wrote:What if you have something like "12345".

Thank You
based on the other posts I've read, you should print a newLine for that case, since it doesn't fit into any of the description.

There's no need to print a newline if the test case doesn't match the conditions... (My AC code just ignores them...)

abbir.ku
New poster
Posts: 3
Joined: Sat Nov 09, 2013 10:04 am

Re: 621 - Secret Research

Post by abbir.ku » Thu Nov 28, 2013 2:06 pm

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

using namespace std;

int main()
{
string str;
int T,i,len;
char *arr;

while(cin>>T){
cin.ignore();
for(i=1;i<=T;i++){
getline(cin,str);
len = str.length();

arr = new char[len];
strcpy(arr,str.c_str());

if( ( ( arr[0] == '1' ) && ( len==1 ) ) || ( ( arr[0] == '4' ) && ( len == 1 ) ) || ( ( (arr[0] == '7') && (arr[1] == '8') && (arr[2]!='3') ) && ( len == 2 ) ) ){
cout<<"+"<<endl;
delete arr;
continue;
}else if( ( (arr[len-2] == '3') && (arr[len-1] == '5') ) ){
cout<<"-"<<endl;
delete arr;
continue;
}else if( ( (arr[0] == '9') && (arr[len-1] == '4') ) ){
cout<<"*"<<endl;
delete arr;
continue;
}else if( ( (arr[0] == '1') && (arr[1] == '9') && (arr[2] == '0') ) ){
cout<<"?"<<endl;
delete arr;
continue;
}
cout<<endl;
delete arr;
}
}

return 0;
}

why i keep getting wrong answer . please help . :(

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 621 - Secret Research

Post by brianfry713 » Tue Dec 03, 2013 2:02 am

That is AC code.
Check input and AC output for thousands of problems on uDebug!

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 621 - Secret Research

Post by uDebug » Fri Dec 13, 2013 12:45 pm

Here's some sample input / output.

Input:

Code: Select all

12
19035
1902342432
92342424
111
444
7777777778
78787878
1123131
1
4
78
94949435
AC Output:

Code: Select all

-
?
*
+
+
+
-
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 621 - Secret Research

Post by uDebug » Fri Dec 13, 2013 1:56 pm

why i keep getting wrong answer . please help .
Looks like you're printing useless blank lines. When I run your code with the input I gave above, I see

Code: Select all

-
?
*





+
+
+
-
However, after commenting out the "cout" like so

Code: Select all

       ...
       //cout<<endl;
       delete arr;
        }
    }
    return 0;
}
I got the same AC output as I posted above.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

Blief.S
New poster
Posts: 16
Joined: Wed Jun 18, 2014 9:03 pm

621-Secret Research

Post by Blief.S » Thu Jun 19, 2014 8:59 pm

I am getting RE though i passed every test cases...........plz.....help....

Code: Select all

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main()
{
    int n,m,i;
    char str[100];
    scanf("%d",&n);
    while(n--){
        scanf("%s",&str);
        m=strlen(str);
        char s[100];
        for(i=0;i<m;i++){
            s[i]=str[i];
        }
        if((s[0]=='1' && m==1 )|| (s[0]=='4'&& m==1 )|| (s[0]=='7' && s[1]=='8' && m==2 )) printf("+\n");
        else if(s[m-2]=='3' && s[m-1]=='5') printf("-\n");
        else if(s[0]=='9' && s[m-1]=='4') printf("*\n");
        else if(s[0]=='1' && s[1]=='9' && s[2]=='0') printf("?\n");
        else continue;


    }
    return 0;

}


Blief.S
New poster
Posts: 16
Joined: Wed Jun 18, 2014 9:03 pm

Re: 621 - Secret Research

Post by Blief.S » Thu Jun 19, 2014 9:29 pm

6 times got RE........ plz....help...i am totally helpless to solve this...passed all cases above...

Code: Select all

Removed After AC Thanks for the help
Last edited by Blief.S on Fri Jun 20, 2014 12:07 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 621-Secret Research

Post by brianfry713 » Thu Jun 19, 2014 10:07 pm

Don't double post.
Check input and AC output for thousands of problems on uDebug!

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 621 - Secret Research

Post by brianfry713 » Thu Jun 19, 2014 10:25 pm

Try increasing the size of s to at least 200.
Check input and AC output for thousands of problems on uDebug!

Blief.S
New poster
Posts: 16
Joined: Wed Jun 18, 2014 9:03 pm

Re: 621 - Secret Research

Post by Blief.S » Fri Jun 20, 2014 10:47 am

Thanks. I got AC

Post Reply

Return to “Volume 6 (600-699)”