10919 - Prerequisites?
Moderator: Board moderators
10919 - Prerequisites?
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, ...?
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, ...?
What is the output for the following input set...
Input:
Thanks.
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
Last edited by Jan on Mon Oct 03, 2005 2:59 pm, edited 1 time in total.
Ami ekhono shopno dekhi...
HomePage
HomePage
You can look at this too.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 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!
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!
fahim
#include <smile.h>
#include <smile.h>
Re: 10919 - Prerequisites? why RTE
please help.. I am getting RTE
here is the code
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/
http://akanoi.webs.com/
-
- Experienced poster
- Posts: 145
- Joined: Thu Aug 14, 2003 8:42 am
- Location: Mountain View, California
- Contact:
Re: 10919 - Prerequisites? why RTE
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.abid_iut wrote:please help.. I am getting RTE
here is the codeCode: 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; }
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?
-
- New poster
- Posts: 10
- Joined: Fri Nov 21, 2014 9:18 am
Re: 10919 - Prerequisites?
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;
}
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 10919 - Prerequisites?
Don't read from a file.
Check input and AC output for thousands of problems on uDebug!