755 - 487-3279

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

Moderator: Board moderators

This is My First Replay

Postby hiloshi » Fri Aug 27, 2004 8:34 am

hi tetuya!
I think you had take mistake in func method.

[cpp]
if(counter>0)
printf("%03d-%04d %d\n",tmp/10000,tmp%10000,++counter);

}
skip:;
if(duple) cout << "No duplicates." << endl;
}
[/cpp]

Label skip and follow code is executed any case.
You should type "return" before label skip:

Check this input

1

2
1111111
1111111
--------------
correct output is
111-1111 2

but your program will output
111-1111 2
No duplicates.
hiloshi
New poster
 
Posts: 20
Joined: Fri Aug 27, 2004 8:15 am
Location: Kanagawa, Japan

Postby tetuya » Fri Aug 27, 2004 9:25 am

No soon had I followed your Advice and submitted,than I got Accepted ! :D

Thank you for your Accurate Advice ! :wink:

My heart was saved (^-')b
sorry for my poor English.
User avatar
tetuya
New poster
 
Posts: 14
Joined: Thu May 27, 2004 2:31 pm

Postby tetuya » Sat Aug 28, 2004 3:53 am

Hello emka.
It's a bug. :wink:
Code: Select all
else if ( s[i] == 'O' || s[i] == 'N' || s[i] == 'O' || s[i] == '6' )

good luck :D
sorry for my poor English.
User avatar
tetuya
New poster
 
Posts: 14
Joined: Thu May 27, 2004 2:31 pm

Postby tetuya » Sun Aug 29, 2004 9:03 pm

Hi 20717TZ.

string is slow in case of this problem.
you could handle it with primitive measure. :)
sorry for my poor English.
User avatar
tetuya
New poster
 
Posts: 14
Joined: Thu May 27, 2004 2:31 pm

755 -> how is this possible??

Postby Ivo Sluganovic » Sun Oct 31, 2004 3:57 pm

How is it possible that for the following code,
OJ says it uses only 64 KB when it should use at least 0.3 MB?

It also says WA in 0.00 seconds.

[c]
[/c]

I don't understand this.
Ivo Sluganovic
New poster
 
Posts: 12
Joined: Tue Sep 21, 2004 10:08 pm

Postby Ivo Sluganovic » Sun Oct 31, 2004 9:48 pm

I found the error.
Ivo Sluganovic
New poster
 
Posts: 12
Joined: Tue Sep 21, 2004 10:08 pm

755 [487-3279] Why WA ! :-(

Postby Ali Arman Tamal » Tue Feb 15, 2005 6:41 pm

Why OJ gives WA :-? Please help me ...

Code: Select all
CUT AFTER AC


Please Help !
Last edited by Ali Arman Tamal on Fri Mar 18, 2005 5:18 pm, edited 1 time in total.
User avatar
Ali Arman Tamal
Learning poster
 
Posts: 76
Joined: Sat Jan 15, 2005 5:04 pm
Location: Dhaka

755

Postby kenneth » Wed Mar 02, 2005 12:34 am

Would anyone be able to provide some input and output with lots of data in there as i think my program is correct, but keep getting WA =p

Thanks alot
kenneth
New poster
 
Posts: 24
Joined: Wed Mar 02, 2005 12:29 am

Postby Raj Ariyan » Fri Mar 04, 2005 12:00 pm

Hi,
You can check this input. Hope it helps. Good luck

Input :-
4

5
-0-0-0-0-1-0-1
IYSDS-1-1-
MMDPS-22
0000A--AA
-----AMSAM--AA

6
3-10-10-1A
6464642
ASACCS5
-1111115
F101010
888-1200

5
-5-5-9-7-4-9-2
2947955
GO-HOME-1
HOME-123
12344-AA

9
-123-5657
12----12121
ABBCSS1
12112-A--B
ABBC-123
-1-2----3AABC
KKSDS-AA
ALNKNDS
----KKJ1234


Output:-
No duplicates.
No duplicates.
No duplicates.
No duplicates.
Last edited by Raj Ariyan on Tue Mar 08, 2005 2:52 pm, edited 1 time in total.
Some Love Stories Live Forever ....
Raj Ariyan
Learning poster
 
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul

Postby kenneth » Fri Mar 04, 2005 2:12 pm

I think the 3rd test case is wrong since the number of phone numbers is wrong.

Furthermore, for the last input, how come the output is as such?
kenneth
New poster
 
Posts: 24
Joined: Wed Mar 02, 2005 12:29 am

Sorry

Postby Raj Ariyan » Tue Mar 08, 2005 2:55 pm

Hi Kenneth.
I'm extreamly sorry. Actually when i copy my input file at that time something was missing. Now i edited my input and output. Sorry again.
Some Love Stories Live Forever ....
Raj Ariyan
Learning poster
 
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul

755

Postby Raj Ariyan » Tue Mar 08, 2005 3:25 pm

Hi Tamal,

There are two mistake.

1. You print your output like this
printf("%3d-%4d",temp/10000,temp%10000);
printf(" %ld\n",count);


But what abt this case --->
** when temp/10000 returns 1 digit then u print only 1 not 001
output will be 001-0002 2, but ur output will be 1- 2 2
so use this :-
printf("%03ld-%04ld",temp/10000,temp%10000);
printf(" %ld\n",count);


2. You always print extra new line cause you a P.E.

I think u still get P.E after modify this. That is upto you. Good Luck.
Some Love Stories Live Forever ....
Raj Ariyan
Learning poster
 
Posts: 70
Joined: Sat Feb 05, 2005 9:38 am
Location: Gurukul

Postby Ali Arman Tamal » Fri Mar 18, 2005 5:17 pm

Thank you Raj Ariyan :D
I got AC :P

I really appreciated your help, I didn't thought of that problem.

Thanks :D
User avatar
Ali Arman Tamal
Learning poster
 
Posts: 76
Joined: Sat Jan 15, 2005 5:04 pm
Location: Dhaka

755 need a fast algrithem

Postby sunnycare » Mon Apr 04, 2005 4:20 am

i solved the problem 755 ,but used 9.928 seconds ...

i see others use only 0.0xx seconds......

i have generated 1,000,000 random telephone number,and my prog solved it in 118.xxx seconds......so long......

my code here
Code: Select all
#include <iostream>
#include <string>
#include <map>

using namespace std;

long t[26]={2,2,2,
            3,3,3,
            4,4,4,
            5,5,5,
            6,6,6,
            7,7,7,7,
            8,8,8,
            9,9,9,9};
long table[128];

long convert(string &s)
{
   
   long n=s.length();
   long ret=0;
   long i;
   for(i=0;i<n;i++)
   {
      if(s[i]!='-')
         ret=ret*10+table[s[i]];
   }
   
   return ret;
}
void InitTable()
{
   unsigned char i;
   for(i=0;i<128;i++)
   {
      if(i>='0'&&i<='9')
         table[i]=i-'0';
      else
         if(i>='A'&&i<='Z')
            table[i]=t[i-'A'];
   }
}
void main()
{
   
   InitTable();
   
   long ncase;
   string s;
   long tel;
   long occu;
   long n;
   cin>>ncase;
   map<long,long> telmap;
   map<long,long>::iterator ptr,end;
   cout.fill('0');
   while(ncase-->=1)
   {
      cin>>n;
      telmap.clear();
      while(n-->=1)
      {
         cin>>s;
         telmap[convert(s)]++;
      }
      ptr=telmap.begin();
      end=telmap.end();
      bool dup=false;
      
      while(ptr!=end)
      {
         if(ptr->second!=1)
         {
            dup=true;
            cout.width(3);
            tel=ptr->first;
            cout<<tel/10000<<'-';
            cout.width(4);
            cout<<tel%10000<<' ';
            cout<<ptr->second<<endl;
         }
         ptr++;
      }
      if(!dup)
         cout<<"No duplicates."<<endl;
      if(ncase!=1)
         cout<<endl;
      
   }

}

my code looks ugly..... need help...[/code]
sunnycare
Learning poster
 
Posts: 74
Joined: Tue Mar 08, 2005 2:35 am
Location: China , Shanghai

Postby mf » Mon Apr 04, 2005 7:52 am

I used my own tuned implementation of quicksort and read() function to take input, and ran less than 1 second.

Try to get rid of STL, cin/cout. This will speed up your program significantly.
mf
Guru
 
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland

PreviousNext

Return to Volume VII

Who is online

Users browsing this forum: No registered users and 1 guest