755 - 487--3279

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

Moderator: Board moderators

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

Re: 755 - (487--3279) - WA ?

You're printing a null character at the end of a phone number.
Check input and AC output for thousands of problems on uDebug!

c0debreak
New poster
Posts: 10
Joined: Mon Aug 13, 2012 5:32 am

Re: 755 - (487--3279) - WA ?

Thanks, got AC.

crazycholon1
New poster
Posts: 1
Joined: Tue Oct 09, 2012 11:47 am

Re: 755 - (487--3279) - WA ?

I've tested many times and many kind of test, but it's still WA. I used map stl to collect no-dupplicate, and a vector to sort them ascending. And I think my program handle well multiple test. No unneccesary blank line. Please take a look and help me =.=

Code: Select all

``````#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int n;
map <string, int> Q;
map <string, int> ::iterator it;
map <char, char> R;
string s;

struct kieu{
string s;
int n;
};

bool myCompare(kieu x, kieu y) {
return (x.s < y.s);
}

void init() {
R.clear();
R['0'] = '0';
R['1'] = '1';
R['A'] = '2';   R['B'] = '2';    R['C'] = '2';    R['2'] = '2';
R['D'] = '3';   R['E'] = '3';    R['F'] = '3';    R['3'] = '3';
R['G'] = '4';   R['H'] = '4';    R['I'] = '4';    R['4'] = '4';
R['J'] = '5';   R['K'] = '5';    R['L'] = '5';    R['5'] = '5';
R['M'] = '6';   R['N'] = '6';    R['O'] = '6';    R['6'] = '6';
R['P'] = '7';   R['R'] = '7';    R['S'] = '7';    R['7'] = '7';
R['T'] = '8';   R['U'] = '8';    R['V'] = '8';    R['8'] = '8';
R['W'] = '9';   R['X'] = '9';    R['Y'] = '9';    R['9'] = '9';
}

void make(string s) {
string temp = "";
int sLength = s.length();
for (int i = 0; i < sLength; ++i) {
if (s[i] != '-') {
temp += R[s[i]];
if (temp.length() == 3) temp += '-';
}
}
if (Q.find(temp) != Q.end()) ++Q[temp];
else Q[temp] = 1;
}

int main() {
int test;
bool check;
vector <kieu> a;
vector <kieu> ::iterator it2;
kieu t;
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "wt", stdout);
scanf("%d", &test);
init();
while (test--) {
scanf("%d", &n);
Q.clear();
for (int i = 0; i < n; ++i) {
cin >> s;
make(s);
}
a.clear();
check = false;
for (it = Q.begin(); it != Q.end(); ++it)
if (it->second > 1) {
t.s = it->first;
t.n = it->second;
a.push_back(t);
check = true;
}
if (check) {
sort(a.begin(), a.end(), myCompare);
for (it2 = a.begin(); it2 != a.end(); ++it2) {
cout << it2->s << " " << it2->n;
if (it2 + 1 != a.end()) cout << endl;
}
if (test > 0) cout << endl;
}
else {
cout << "No duplicates.";
if (test > 0) cout << endl;
}
if (test > 0) cout << endl;
}
return 0;
}
``````

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

Re: 755 - (487--3279) - WA ?

Print a newline at the end of the last line of output.
Check input and AC output for thousands of problems on uDebug!

heavenllymoon
New poster
Posts: 1
Joined: Sun Feb 24, 2013 4:02 pm

755 - 487--3279

I got a TLE on this problem,here is my code:

Code: Select all

``````#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <cstdio>
#include <algorithm>
using namespace std;

vector<string> tel,out,cmp;
vector<int> vis;
int times;

int main()
{
int cases;
cin >> cases;
cin.ignore();
cin.ignore();

while(cases--)
{
int num;
cin >> num;
while(getchar() != '\n');

string line;
for(int i = 0 ; i < num ; i++)
{
getline(cin,line);

for(int j = line.size()-1 ; j >= 0 ; j--)
{
if(!isdigit(line[j]))
{
if(isalpha(line[j]))
switch(line[j])
{
case 'A': case 'B': case 'C':
line[j] = '2';
break;
case 'D': case 'E': case 'F':
line[j] = '3';
break;
case 'G': case 'H': case 'I':
line[j] = '4';
break;
case 'J': case 'K': case 'L':
line[j] = '5';
break;
case 'M': case 'N': case 'O':
line[j] = '6';
break;
case 'P': case 'R': case 'S':
line[j] = '7';
break;
case 'T': case 'U': case 'V':
line[j] = '8';
break;
case 'W': case 'X': case 'Y':
line[j] = '9';
break;
}
else
line.erase(line.begin() + j);
}
}

cmp.push_back(line);
int ii;
for(ii = 0 ; ii < tel.size() ; ii++)
if(tel[ii] == line)
{
vis[ii]++;
break;
}

if(ii == tel.size())
{
tel.push_back(line);
vis.push_back(1);
}
}

for(int i = 0 ; i < vis.size() ; i++)
{
if(vis[i] > 1)
out.push_back(tel[i]);
}

if(out.empty())
cout << "No duplicates." << endl;
else
{
sort(out.begin(),out.end());
for(int i = 0 ; i < out.size() ; i++)
{
times = 0;
for(int k = 0 ; k < cmp.size() ; k++)
if(out[i] == cmp[k])
times++;

for(int j = 0 ; j < out[i].size() ; j++)
{
if(j != 3)
cout << out[i][j];
else
cout << '-' << out[i][j];
}
cout << " " << times << endl;
}
}

if(cases)
cout << endl;

tel.clear();
vis.clear();
out.clear();
cmp.clear();
}

return 0;
}
``````
but I had tried many test cases and passed,so I don't know why I got TLE,please give me a favour , thanks very much !!!!

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

Re: 755 - 487--3279

Try using a map.
Check input and AC output for thousands of problems on uDebug!

hpjhc
New poster
Posts: 17
Joined: Wed Jun 26, 2013 10:35 am

755 always SubmmisionErr

Anyone knows why ? I am crazy! Thanks!

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

Re: 755 always SubmmisionErr

Try a different problem.
Check input and AC output for thousands of problems on uDebug!

Munkhbayar
New poster
Posts: 1
Joined: Tue Jul 09, 2013 8:37 pm

Re: 755 - 487-3279

I got Submission Error twice. Is there anyone who knows what is this error? If then help me..

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

Re: 755 - 487-3279

Try a different problem.
Check input and AC output for thousands of problems on uDebug!

20717TZ
New poster
Posts: 33
Joined: Tue Apr 27, 2004 7:41 pm
Location: Santa Clara / Mountain View, CA, USA
Contact:

Re: 755 always SubmmisionErr

I am having the same problem. It's always submission error.

I also tried to submit a different problem and then came back to submit 755, but I still got the same problem.

Please take a look at it.
I Believe I Can - leestime.com

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

Re: 755 always SubmmisionErr

Check input and AC output for thousands of problems on uDebug!

Naveed123
New poster
Posts: 1
Joined: Sat Oct 19, 2013 12:05 pm

Re: 755 always SubmmisionErr

any1 plz help

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

Re: 755 - 487-3279

This problem already has quite a few threads scattered all over the forums, so, I decided to try to gather test input / output data that I found elsewhere (or in earlier parts fo this thread) and add them in here - since it seems like this is the biggest and most comprehensive thread. All credit for the input / output data goes to OPs.

Note that there is a newline only between cases. So, just to be clear, there's no newline after the last case.

Input:

Code: Select all

``````8

12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279

3
3--------------------------------------3----3-----W---1-1-----1
-----F-----D---E---Y111
ABC-DEFG

12
0-0-0-0-0-0-0
00-0-0-0-0-0
000-0-0-0-0
0000-0-0-0
00000-0-0
000000-0
001-----------------------------------0000
001-------------------------------------------------0000
0---------00000--------1
0000--------------------------------001
---------------------------------1000000
1000--------000----------------------------------------

40
0U--4N712
---X2-KN-U-75
VR-J37G--3
85W-0Y6-V
85W-0Y6-V
85W-0Y6-V
--N-6AV4-NK
--XL----F-PO--B-0
-P-10167P
7--R8YME-N
P-U-1O6W-----1
X-KFK87--L
YFX63K-N
-3-73G---ELH
--2RD-6-IJ-Y
P2--SJ9G9
P2--SJ9G9
O-1----2287-2
-DC-C1L-3V
7963V68
U-66X52M
U-66X52M
-8-16F5TG
---YN-32E5-K
---YN-32E5-K
4--KDJ-PV2
4--KDJ-PV2
P27-42L2
P27-42L2
-MIWO-W5D
44M7675
F---6-7R80M
T5S6U1-P
T5S6U1-P
T5S6U1-P
BUM85L--3
BUM85L--3
DB1E---046
36O--7-1W2
-R--52-P-Y7H

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
``````
AC Output:

Code: Select all

``````310-1010 2
487-3279 4
888-4567 3

333-9111 2

000-0000 6
000-0001 2
001-0000 2
100-0000 2

286-8553 2
453-5782 2
727-4252 2
727-5949 2
857-6817 3
859-0968 3
866-9526 2
963-2355 2

No duplicates.

No duplicates.

No duplicates.

No duplicates.``````
Check input and AC output for over 7,500 problems on uDebug!