698 - Index

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

Moderator: Board moderators

698 - Index

Postby wyvmak » Thu Apr 11, 2002 10:00 am

:evil: I just hate it when I knew the sample output is wrong. If sample output is wrong, what is its purpose? or in the real ACM, wrong sample output is part of the test for competitors? Yet, I still cannot get AC.

would someone be kind enough to give me the output for the following input:

abc
def

abc abc def
abc abc def def
abc abc def def def
abc

would it be:
Case 1
ABC 1, 1-2, 2-3, 3-4
DEF 1-2, 2-3, 3, 3

Also, will there be a case that there's zero word to be indexed?
Or what other tricks in it?
wyvmak
Experienced poster
 
Posts: 110
Joined: Thu Dec 13, 2001 2:00 am

Postby Adrian Kuegel » Thu Apr 11, 2002 12:54 pm

I would say, the output is
Case 1
ABC 1-4
DEF 1-3
but I also get WA. What is the correct output for this input?
2fOr1
.*the+
bla

blab the+ h2for1
2for1z 2for1 *the bla
blabla the

My program prints:
Case 1
2FOR1 2
BLA 2
THE 1-3
Adrian Kuegel
Guru
 
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Postby Ivan Golubev » Thu Apr 11, 2002 2:51 pm

My accepted solution produces this output:

For wyvmak's input:
Case 1
ABC 4
DEF 1-3

For Adrian's input:
Case 1
2FOR1 2
BLA 2
Ivan Golubev
Experienced poster
 
Posts: 167
Joined: Fri Oct 19, 2001 2:00 am
Location: Saint Petersburg, Russia

Postby Adrian Kuegel » Thu Apr 11, 2002 3:10 pm

Ivan, thank you for your reply. But I don't understand, why the output for ywyvmak's input is "ABC 4" and not "ABC 1-4". And can you explain, why your program does not print the "the" for my input. Because it is said in the description: "Punctuation preceding or following an index term will be ignored." What does it mean?
Adrian Kuegel
Guru
 
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Postby Ivan Golubev » Thu Apr 11, 2002 5:05 pm

Oops, I've used a bit incorrect input file (there was a space after ABC). So real output is 'ABC 1-4', of course.

About 'the': I think (and it can be check with asserts, lazy to do it by my own ;-)) that terms doesn't contains anything else than digits and letters. My solution reads them as is. I've done searching via strstr. If before and after term there something else than letters and digits then it's match.
Ivan Golubev
Experienced poster
 
Posts: 167
Joined: Fri Oct 19, 2001 2:00 am
Location: Saint Petersburg, Russia

TLE

Postby sjn » Sat Jul 19, 2003 3:14 pm

oh, i got TLE :cry:

can anyone help me?
sjn
Learning poster
 
Posts: 73
Joined: Mon Apr 08, 2002 8:22 am

698

Postby titid_gede » Wed Jul 30, 2003 12:06 pm

can you tell me what is the trickies input for this problem? always got WA after almost 10 submissions :(

regards,
titid
Kalo mau kaya, buat apa sekolah?
titid_gede
Experienced poster
 
Posts: 187
Joined: Wed Dec 11, 2002 2:03 pm
Location: Mount Papandayan, Garut

Postby little joey » Mon Aug 11, 2003 11:47 am

All the obvious trickies are in the sample input. Everything more would be a spoiler.

One advise: Don't assume anything that's not explicitly written in the problem description. I did that and got 10+ WAs before finaly getting AC.
User avatar
little joey
Guru
 
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Postby bobi1978 » Mon Aug 18, 2003 3:20 pm

little joey wrote:
Code: Select all
One advise: Don't assume anything that's not explicitly written in the problem description.


What do you mean by this?

1) In the INDEX list, if there is a character that is not ALPHA_NUM what should I do with it?
ex:--- INDEX LIST ---

//foR*
ab*c<>
?a?b?

What are the Indexes in this list?

FOR AB A

or

FOR ABC AB
?
bobi1978
New poster
 
Posts: 13
Joined: Tue Jul 22, 2003 1:57 pm
Location: Kavadarci, Macedonia

Postby little joey » Mon Aug 18, 2003 4:09 pm

There are no such cases; that would violate the description.
As I said, I'm not gonna give a spoiler.
User avatar
little joey
Guru
 
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Postby Aleksandrs Saveljevs » Mon Jan 19, 2004 11:14 pm

Well, I managed to get it AC recently. :)

In the end, having only REs, beseeching God he would let me have WA, suddenly, to my astonishment, it was AC. :o

There are several found-out things I would like to share:

1) Words can be longer than 10 symbols, but shorter than 21 (maybe it results from 10 letters plus 10 digits; though it contradicts to what is said in the sample input). It may be not so if one can get SIGABRT because of something else than assert().

2) Either lines can be longer than 25000 symbols or there are less than 2 blank lines in the end.

If any of the above statements are wrong, please, make a post, so that people wouldn't have so much problems. :)
Aleksandrs Saveljevs
New poster
 
Posts: 39
Joined: Fri Nov 14, 2003 11:18 pm
Location: Riga, Latvia

Postby minskcity » Fri Aug 06, 2004 8:04 pm

I've already got 10 WA, can anybody tell me what I'm missing? Any special cases? HELP, PLEASE... :cry: [cpp]#include <iostream>
#include <string>
#include <fstream>
#include <ctype.h>
#include <vector>
#include <map>
using namespace std;

map < string, vector < long > > index;
vector < long > empty;
string s;
long t;

int main(){

// ifstream cin("in.txt");

t = 1;
while(getline(cin, s)){

index.clear();

while(s.size()){ // storing index words
for(unsigned i = 0; i < s.size(); i++) s[i] = toupper(s[i]);
index[s] = empty;
getline(cin, s);
}

long cnt = 0;
while(getline(cin, s) && s.size() && ++cnt){ // inserting to index lines of word that match
s += ' ';
string word = "";

for(unsigned i = 0; i < s.size(); i++){
s[i] = toupper(s[i]);
if(isalnum(s[i])) word += s[i];
else{
if(index.find(word) != index.end() && (!index[word].size() || index[word].back() != cnt))
index[word].push_back(cnt);
word = "";
}
}

}

cout << "Case " << t++ << endl; // starting to print answer

for(map < string, vector < long > > :: iterator it = index.begin(); it != index.end(); it++)
if(it->second.size()){
cout << it->first;
for(unsigned i = 0; i < it->second.size(); i++){
if(i + 1 == it->second.size() || it->second[i] + 1 != it->second[i + 1]){
cout << " " << it->second[i];
if(i + 1 != it->second.size()) cout << ",";
}else{
long st = i;
while(i + 1 < it->second.size() && it->second[i] + 1 == it->second[i + 1]) i++;
cout << " " << it->second[st] << "-" << it->second[i];
if(i + 1 != it->second.size()) cout << ",";
}
}
cout << endl;
}

cout << endl;

}

return 0;
}
[/cpp]
minskcity
Experienced poster
 
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Postby minskcity » Wed Aug 25, 2004 3:57 am

little joey wrote:All the obvious trickies are in the sample input. Everything more would be a spoiler.

One advise: Don't assume anything that's not explicitly written in the problem description. I did that and got 10+ WAs before finaly getting AC.
I've got more than 15 WAs. :-?
Why don't you post what were your mistakes before you get AC?
minskcity
Experienced poster
 
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Postby Emilio » Sat Apr 16, 2005 7:03 am

Hello,
I'm getting WAs, a lot of them and I can't encounter the reason of this,
Could anyone with an AC code say me what is the output for this?

Code: Select all
ab
abc
a1b
1ab
0ab
a0b
aaa
ab
abc
a11b
a12b
ab1
ab2
ab12
a1b1
a1b2
1
2
123
321
122
00A
0123
001234
004321
007

ab abc a1b a0b ab a12b
ab 0ab 1ab aaa
a11b a12b
ab abc ab2 ab12
abc ab1 a1b1 a1b2
1 2 123 007
321 122 00A
0123 001234 004321

ab
abc

ab abc
ab abc

asdfasdfasdfasdfasdfasdf

asdfasdfasdfasdfasdfasdf




And another thing, if you know some tricky input, please, say me it.
Are there blank texts or blank sets of keywords?

Thanks in advance!
Emilio
Experienced poster
 
Posts: 163
Joined: Sun Oct 17, 2004 8:31 pm
Location: Murcia, Spain

Postby minskcity » Sat Apr 16, 2005 5:43 pm

In order to get AC the output should be:
Code: Select all
Case 1
001234 8
004321 8
007 6
00A 7
0123 8
0AB 2
1 6
122 7
123 6
1AB 2
2 6
321 7
A0B 1
A11B 3
A12B 1, 3
A1B 1
A1B1 5
A1B2 5
AAA 2
AB 1-2, 4
AB 1-2, 4
AB1 5
AB12 4
AB2 4
ABC 1, 4-5
ABC 1, 4-5

Case 2
AB 1-2
ABC 1-2

Case 3
ASDFASDFASDFASDFASDFASDF 1

Ignore the spaces at the end of each line - those are added by bulletin board. I knew this problem was screwed :-?
minskcity
Experienced poster
 
Posts: 199
Joined: Tue May 14, 2002 10:23 am
Location: Vancouver

Next

Return to Volume VI

Who is online

Users browsing this forum: No registered users and 0 guests