Page 3 of 3

hmm

Posted: Thu Feb 17, 2005 3:16 pm
by shahriar_manzoor
Sorry! I never used or heard of seekeof(), so I cannot comment. You don't need to use eof() to check whether file has ended so ...

Posted: Fri Feb 18, 2005 3:56 am
by NightFir
" You don't need to use eof() to check whether file has ended so ..."
If I don't use "eof",what else can I do to check whether file has ended?

Posted: Fri Feb 18, 2005 3:57 am
by NightFir
" You don't need to use eof() to check whether file has ended so ..."
If I don't use "eof",what else can I do to check whether file has ended?

jmm

Posted: Fri Feb 18, 2005 4:40 am
by shahriar_manzoor
a) tell me the problem u r solving
b) Do you use C language or anything else?

Posted: Fri Feb 18, 2005 9:54 am
by little joey
seekeof is a Pascal function, as is eof, so the language NightFir is referring to is Pascal (you should have written that in your posting!).

It's funny that the judge forbids this function, because it's a perfectly legal (though a bit unusual) function to scan an input stream (not only files but also the standard input stream).

I would be practical about it and only use eof in your programs and forget about seekeof when solving UVA problems.

Re: jmm

Posted: Fri Feb 18, 2005 10:26 am
by shahriar_manzoor
shahriar_manzoor wrote:a) tell me the problem u r solving
b) Do you use C language or anything else?
I was going in completely wrong direction because never realized that your language is PASCAL. Can't blame myself for not remembering about seekeof because I used to program in Pascal 8 years ago.

Re: 10745 - Dominant Strings

Posted: Mon May 31, 2010 4:19 pm
by mak(cse_DU)
I was stuck in this problem several hours.
After generating some random inputs, I got the error.
Here it is:
Input:

Code: Select all

a
ab
AC output:

Code: Select all

ab
Also try :

Code: Select all

ab
a

10745 - Dominant Strings RE

Posted: Thu Apr 26, 2012 3:02 am
by nlisi2012

Code: Select all

 #include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <time.h>
using namespace std;
int intersec(string pal1, string pal2);
int main(int argc, char *argv[]) {
	//clock_t tin, tf;
	string line;
	vector<string> palabras;
	vector<string> palDominantes;
	//tin= clock ();
	while(cin>>line) {
		palDominantes.push_back(line);
		sort(line.begin(), line.end());
		palabras.push_back(line);
	}
	int tamPal = palabras.size();
	for( int i = 0; i < tamPal; i++) {
		for(int j = i+1; j < tamPal; j++) {
			if(palabras[j] != palabras[i]) {
				
				if(palabras[i].size() < palabras[j].size()) {
					if(intersec(palabras[j],palabras[i])){
						palabras.erase(palabras.begin() + i);
						//palDominantes.erase(palDominantes.begin() + i);
						i--;
						tamPal--;
					}
				}
				else if(palabras[i].size() > palabras[j].size())
					if(intersec(palabras[i], palabras[j])){
						palabras.erase(palabras.begin() + j);
						//palDominantes.erase(palDominantes.begin() + j);
						j--;
						tamPal--;
					}
			}
		}
	}
	sort(palDominantes.begin(),palDominantes.end());
	for(unsigned int i = 0; i < palDominantes.size(); i++)
		cout<<palDominantes[i]<<endl;
	//tf = clock();
	//cout<<(double)(tf - tin)/CLOCKS_PER_SEC*1000.0<<endl;
	getchar();
	return 0;
}
int intersec(string pal1, string pal2) {
	int c1=0, c2=0;
	int tam1 = pal1.size(), tam2=pal2.size();
	//pal1 seria la palabra de mayor tamaƱo
	while(((tam2 - c2) <= (tam1 - c1)) && (c2 < tam2)) {
		if(pal1[c1] == pal2[c2])
			c2++;
		c1++;
	}
	if(c2 == tam2)
		return 1;
	return 0;
}
i have runtime error and i don't know why? i'm going crazy! i made everithing kind of changes but i cant receive AC

Re: 10745 - Dominant Strings

Posted: Fri Apr 27, 2012 3:56 am
by brianfry713
Doesn't match the sample I/O.

http://ideone.com/NtAjx