Page 1 of 2

11917 - Do Your Own Homework

Posted: Thu Mar 10, 2011 6:36 am
by rahid
Please tell me whats wrong with my code??

Code: Select all

CODE HAS BEEN DELETED!!


Re: 11917 - Do Your Own Homework

Posted: Thu Mar 10, 2011 10:39 pm
by naseef_07cuet
Check this:
3
compiler 4
cplusplus 1
java 8
5
compiler
2
algorithm 3
math 9
4
math
2
java 8
ai 3
6
calculus

Your program shows for this input set:
Case 1: Yesss2
Case 2: Late2
Case 3: Do your own homework!


There is no new line after the last output.Give it.And delete the extra things that you are printing. Hope it will help you.

Re: 11917 - Do Your Own Homework

Posted: Fri Mar 11, 2011 4:58 am
by rahid
ThanX for your reply. Problem have been solved just after adding a single new line at the end.

Re: 11917 - Do Your Own Homework

Posted: Wed Mar 16, 2011 12:52 pm
by mintae71
Please Help me OTL.......

Code: Select all

#include <iostream>
#include <string>
using namespace std;
string bigeo1[101];
int Dbigeo1[101];
int main()
{
	int testcases, cntofbigeo1;
	int Dbigeo2;
	string bigeo2;
	int i, j;
	int Cases = 0;
	bool last;

	cin >> testcases;

	while (testcases--){
		Cases++;
		last = false;
		for (i = 0; i < 100; i++){
			Dbigeo1[i] = 0;
			bigeo1[i] = "";
		}
		cin >> cntofbigeo1;
		for (i = 0; i < cntofbigeo1; i++){
			cin >> bigeo1[i] >> Dbigeo1[i];
		}

		cin >> Dbigeo2 >> bigeo2;

		for (i = 0; i < cntofbigeo1; i++){
			if (bigeo2.length() == bigeo1[i].length()){
				bool chk = true;

				for (j = 0; j < bigeo1[i].length(); j++){
					if (bigeo1[i][j] != bigeo2[j]){
						chk = false;
						break;
					}
				}

				if (chk == true){
					last = true;
					if (Dbigeo2 >= Dbigeo1[i]) cout << "Case " << Cases << ": " << "Yesss" << endl;
					else if (Dbigeo2+5 >= Dbigeo1[i]) cout << "Case " << Cases << ": " << "Late" << endl;
				}
			}
			if (last) break;
		}
		if (!last) cout << "Case " << Cases << ": " << "Do your own homework!" << endl;
	}
	return 0;
}

11917 - Do Your Own Homework

Posted: Mon Feb 18, 2013 4:36 pm
by lukai

Code: Select all

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

vector<string>subjects;
vector<int>days;
int main()
{
    //freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
    long long int nunu=1,cases,comfortable,day,koydinlage,i;
    string subject,jeitalagbe;
    while(cin>>cases)
    {
        while(cases--)
        {

           cin>>comfortable;
           while(comfortable--)
           {
               cin>>subject>>day;
               subjects.push_back(subject);
               days.push_back(day);
           }
           cin>>koydinlage;
           cin>>jeitalagbe;
           cout<<"Case "<<nunu<<": ";
           nunu++;
           for(i=0;i<subjects.size();i++)
           {
               if(jeitalagbe==subjects[i])
               {
                   if(days[i]<=koydinlage)
                   {
                       cout<<"Yesss"<<endl;
                       break;
                   }
                   else if((koydinlage+5)<=days[i])
                   {
                       cout<<"Late"<<endl;
                       break;
                   }
                   else
                   {
                       cout<<"Do your own homework!"<<endl;
                       break;
                   }
               }

           }
           if(i==subjects.size())
           {
               cout<<"Do your own homework!"<<endl;
           }

            subjects.clear();
            days.clear();
        }
    }

    return 0;
}
Can you give me some critical I/O. I don't understand why I'm getting WA

Re: 11917 - Do Your Own Homework

Posted: Thu Feb 21, 2013 12:01 am
by brianfry713
Don't read the number of test cases more than once, some problems have junk after the real input.

Re: 11917 - Do Your Own Homework

Posted: Thu Feb 21, 2013 9:34 pm
by lukai

Code: Select all

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;

vector<string>subjects;
vector<long long int>days;
int main()
{
   //freopen("input.txt","r",stdin);
   //freopen("output.txt","w",stdout);
    long long int nunu=1,cases,comfortable,day,koydinlage,i;
    string subject,jeitalagbe;
    cin>>cases;

        while(cases--)
        {

           cin>>comfortable;
           while(comfortable--)
           {
               cin>>subject>>day;
               subjects.push_back(subject);
               days.push_back(day);
           }
           cin>>koydinlage;
           cin>>jeitalagbe;
           cout<<"Case "<<nunu<<": ";
           nunu++;
           for(i=0;i<subjects.size();i++)
           {
               if(jeitalagbe==subjects[i])
               {
                   if(days[i]<=koydinlage)
                   {
                       cout<<"Yesss"<<endl;
                       break;
                   }
                   else if((koydinlage+5)<=days[i])
                   {
                       cout<<"Late"<<endl;
                       break;
                   }
                   else
                   {
                       cout<<"Do your own homework!"<<endl;
                       break;
                   }
               }

           }
           if(i==subjects.size())
           {
               cout<<"Do your own homework!"<<endl;
           }

            subjects.clear();
            days.clear();
        }


    return 0;
}
still WA. I am worried :(

Re: 11917 - Do Your Own Homework

Posted: Thu Feb 21, 2013 11:20 pm
by brianfry713
Input:

Code: Select all

1
2
algorithm 3
math 9
8
math
AC output:

Code: Select all

Case 1: Late

Re: 11917 - Do Your Own Homework

Posted: Sun Feb 24, 2013 9:23 am
by lukai
can you guve me some more I/O. Getting WA again after fixing the bug.

Re: 11917 - Do Your Own Homework

Posted: Mon Feb 25, 2013 10:39 pm
by brianfry713
Post your updated code.

Re: 11917 - Do Your Own Homework

Posted: Sat Mar 23, 2013 4:55 am
by sirajul

Code: Select all

/* deleted after AC */

Re: 11917 - Do Your Own Homework

Posted: Sat Mar 23, 2013 4:57 am
by sirajul

Code: Select all

/*deleted after ac*/

Re: 11917 - Do Your Own Homework

Posted: Sun Mar 24, 2013 10:45 am
by brianfry713
Input:

Code: Select all

2
3
compiler 4
cplusplus 1
java 8
5
compiler
2
algorithm 3
math 9
4
java
AC output:

Code: Select all

Case 1: Yesss
Case 2: Do your own homework!

Re: 11917 - Do Your Own Homework

Posted: Sun Mar 24, 2013 9:06 pm
by sirajul
brianfry713 wrote:Input:

Code: Select all

2
3
compiler 4
cplusplus 1
java 8
5
compiler
2
algorithm 3
math 9
4
java
AC output:

Code: Select all

Case 1: Yesss
Case 2: Do your own homework!
just forgot to clear map

Re: 11917 - Do Your Own Homework

Posted: Sun Mar 24, 2013 9:30 pm
by sirajul

Code: Select all

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct MyStruct
{
    char sub[21];
	int days;
	struct MyStruct *next;
} link;

int main()
{
	link *head , *tptr , *nptr;
	int testCaseRunning=1,totalTestCase;
	scanf("%d",&totalTestCase);
	while (testCaseRunning++<=totalTestCase)
	{
		head = tptr = nptr = NULL;
		int subjects;
		scanf("%d",&subjects);
		char c[21];
		int i=0,n;
		for(i=1;i<=subjects;i++)
		{
			scanf("%s %d",c,&n);
			nptr = (link*) malloc(1*sizeof(link));
			strcpy(nptr->sub,c);
			nptr -> days = n;
			nptr -> next = NULL;
			if(head==NULL)
			{
				tptr = head = nptr;
				tptr = nptr ;
			}
			else
			{
				tptr ->next = nptr;
				tptr = nptr;
			}
		}
		scanf("%d",&n);
		scanf("%s",c);
		tptr = head;
		printf("Case %d: ",testCaseRunning-1);
		while (tptr!=NULL && strcmp(tptr->sub,c)!=0)
		{
			tptr = tptr->next;
		}
		if(tptr!=NULL)
		{
			if(strcmp(tptr->sub , c)==0)
			{
				if(tptr->days <= n)
					printf("Yesss\n");
				else if(n+5 <= tptr->days)
					printf("Late\n");
			}
		}
		else
		{
			printf("Do your own homework!\n");
		}
	}
	return 0;
}
Why WA NOW?? !