10919 - Prerequisites?

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

Moderator: Board moderators

Post Reply
User avatar
Cho
A great helper
Posts: 274
Joined: Wed Oct 20, 2004 11:51 pm
Location: Hong Kong

10919 - Prerequisites?

Post by Cho » Mon Sep 26, 2005 4:21 pm

I used set<string> to solve this one during the contest, but couldn't get AC. I couldn't find any bug in my code so I submit it to online-judge without any modification. I get AC now with 2 secs running time. So I think I failed in contest because of TLE. Any one know what's the time limit of this problem in the contest?

By the way, in the recent two contests, I find no way to check the result of my submission. I can only know it's AC or not from the all team rank list. If it's not AC, how can I check if it WA, TLE, RTE, ...?

Monsoon
Learning poster
Posts: 66
Joined: Fri Jul 23, 2004 4:42 pm
Location: Poland

Post by Monsoon » Mon Sep 26, 2005 4:38 pm

you can see your submit status in "Judge status & Event Page" (second button below "All team ranklist"); i think there was 1 sec time limit

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Mon Oct 03, 2005 3:27 am

What is the output for the following input set...

Input:

Code: Select all

3 2
0123 9876 2222
2 1 8888 2222
3 1 3172 2222 7654 
3 2
0123 9876 2222
2 1 8888 2222
3 2 0123 9876 2222
0
Thanks.
Last edited by Jan on Mon Oct 03, 2005 2:59 pm, edited 1 time in total.
Ami ekhono shopno dekhi...
HomePage

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Mon Oct 03, 2005 3:22 pm

Got Accpeted. Thanks :D
Ami ekhono shopno dekhi...
HomePage

IRA
Learning poster
Posts: 82
Joined: Sat Jan 07, 2006 6:52 am

Post by IRA » Sat Jan 28, 2006 1:11 pm

Who can describe the meaning of the probelm.
I have think this so long but i can't figure it how to do.
Thanks in advanced!

mamun
A great helper
Posts: 286
Joined: Mon Oct 03, 2005 1:54 pm
Location: Bangladesh
Contact:

Post by mamun » Sat Jan 28, 2006 6:12 pm

To meet the degree requirements, he must take courses from each of several categories.
...
the minimum number of courses from the category that must be taken...
You can look at this too.

User avatar
smilitude
Experienced poster
Posts: 137
Joined: Fri Jul 01, 2005 12:21 am

Post by smilitude » Mon Jul 31, 2006 7:25 pm

you got to input some course name that freddie is going to take.
he got to take some minimum courses out of some catagories.
you got to check whether he is taking minimum numbers of courses from each catagory or not...

monsoon, why did you tried to use string? i used a simple boolean array and got AC in 0.248 seconds! :lol:
fahim
#include <smile.h>

abid_iut
Learning poster
Posts: 82
Joined: Wed Jul 16, 2008 7:34 am

Re: 10919 - Prerequisites? why RTE

Post by abid_iut » Sun Jun 07, 2009 3:32 pm

please help.. I am getting RTE
here is the code

Code: Select all

#include<stdio.h>

int main(){
	long n,m,array[150],n1,m1,ccount,i,k,test[150],itr,it,flag1=0;
	bool flag[150];
	while(1){
		k=0;
		scanf("%ld",&n);
		if(n==0)break;
		scanf("%ld",&m);
		for(i=0;i<n;i++)scanf("%ld",&array[i]);
		for(int tr=0;tr<m;tr++){
			ccount=0;
			scanf("%ld",&n1);
			scanf("%ld",&m1);
			for(itr=0;itr<n1;itr++)scanf("%ld",&test[itr]);
			for(itr=0;itr<n1;itr++){
				for(it=0;it<n;it++){
					if(test[itr]==array[it])ccount++;
				}
				if(ccount>=m1){flag[k]=true;k++;}
			}
			if(ccount<m1){flag[k]=false;k++;}
		}
		for(it=0;it<k;it++){
			if(flag[it]==false){
				printf("no\n");
				flag1=0;
				break;
			}
			else flag1=1;
		}
		if(flag1==1)printf("yes\n");
		for(it=0;it<k;it++)flag[it]=false;
		flag1=0;
	}
	return 0;
}
i love to wait... wait for better... and better will come...
http://akanoi.webs.com/

DD
Experienced poster
Posts: 145
Joined: Thu Aug 14, 2003 8:42 am
Location: Mountain View, California
Contact:

Re: 10919 - Prerequisites? why RTE

Post by DD » Tue Mar 15, 2011 8:34 pm

abid_iut wrote:please help.. I am getting RTE
here is the code

Code: Select all

#include<stdio.h>

int main(){
	long n,m,array[150],n1,m1,ccount,i,k,test[150],itr,it,flag1=0;
	bool flag[150];
	while(1){
		k=0;
		scanf("%ld",&n);
		if(n==0)break;
		scanf("%ld",&m);
		for(i=0;i<n;i++)scanf("%ld",&array[i]);
		for(int tr=0;tr<m;tr++){
			ccount=0;
			scanf("%ld",&n1);
			scanf("%ld",&m1);
			for(itr=0;itr<n1;itr++)scanf("%ld",&test[itr]);
			for(itr=0;itr<n1;itr++){
				for(it=0;it<n;it++){
					if(test[itr]==array[it])ccount++;
				}
				if(ccount>=m1){flag[k]=true;k++;}
			}
			if(ccount<m1){flag[k]=false;k++;}
		}
		for(it=0;it<k;it++){
			if(flag[it]==false){
				printf("no\n");
				flag1=0;
				break;
			}
			else flag1=1;
		}
		if(flag1==1)printf("yes\n");
		for(it=0;it<k;it++)flag[it]=false;
		flag1=0;
	}
	return 0;
}
I think there may be some problems on your use of flag[], which may out of boundary. You should re-design it such that its size is equal to the number of categories.
Have you ever...
  • Wanted to work at best companies?
  • Struggled with interview problems that could be solved in 15 minutes?
  • Wished you could study real-world problems?
If so, you need to read Elements of Programming Interviews.

tidusleonart
New poster
Posts: 10
Joined: Fri Nov 21, 2014 9:18 am

Re: 10919 - Prerequisites?

Post by tidusleonart » Sat Nov 22, 2014 6:14 pm

Code: Select all

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

typedef vector<int> vi;
bool indexB(vi& a, int f)
{
	int low = 0, high = a.size()-1, mid;
	while(low <= high)
	{
		mid = (low+high)/2;
		if(a[mid] == f)
			return true;
		if(a[mid] > f)
			high = mid-1;
		if(a[mid] < f)
			low = mid+1;
	}
	return false;
}
int main()
{
	freopen("input.txt", "r", stdin);
	vi taken, same;
	int k, m, c, r, num;
	while(scanf("%d", &k), k)
	{
		scanf("%d", &m);
		int ctaken;
		bool flag = true;
		for(int i = 0; i < k; i++)
		{
			scanf("%d", &ctaken);
			taken.push_back(ctaken);
		}
		sort(taken.begin(), taken.end());
		/*for(int i = 0; i < taken.size(); i++)
		{
			printf("%d ", taken[i]);
		}*/
		for(int i = 0; i < m; i++)
		{
			scanf("%d %d", &c, &r);
			//printf("%d %d\n", c, r);
			int check = 0;
			for(int j = 0; j < c; j++)
			{
				scanf("%d", &num);
				if(indexB(taken, num)){
					check++;}
			}
			if(check < r){
				flag = false;}
		}
		//cout << indexB(taken, 2222) << endl;
		printf((flag) ? "yes\n": "no\n");
	}
	return 0;
}
I keep getting WA. even though checked many test cases with input. I wonder what test cases that i did wrong. Please help. I'm bit frustrating. Thanks

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

Re: 10919 - Prerequisites?

Post by brianfry713 » Wed Nov 26, 2014 2:47 am

Don't read from a file.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 109 (10900-10999)”