Page 1 of 1

10919 - Prerequisites?

Posted: Mon Sep 26, 2005 4:21 pm
by Cho
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, ...?

Posted: Mon Sep 26, 2005 4:38 pm
by Monsoon
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

Posted: Mon Oct 03, 2005 3:27 am
by Jan
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.

Posted: Mon Oct 03, 2005 3:22 pm
by Jan
Got Accpeted. Thanks :D

Posted: Sat Jan 28, 2006 1:11 pm
by IRA
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!

Posted: Sat Jan 28, 2006 6:12 pm
by mamun
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.

Posted: Mon Jul 31, 2006 7:25 pm
by smilitude
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:

Re: 10919 - Prerequisites? why RTE

Posted: Sun Jun 07, 2009 3:32 pm
by abid_iut
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;
}

Re: 10919 - Prerequisites? why RTE

Posted: Tue Mar 15, 2011 8:34 pm
by DD
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.

Re: 10919 - Prerequisites?

Posted: Sat Nov 22, 2014 6:14 pm
by tidusleonart

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

Re: 10919 - Prerequisites?

Posted: Wed Nov 26, 2014 2:47 am
by brianfry713
Don't read from a file.