11917 - Do Your Own Homework
Posted: Thu Mar 10, 2011 6:36 am
Please tell me whats wrong with my code??
Code: Select all
CODE HAS BEEN DELETED!!
Code: Select all
CODE HAS BEEN DELETED!!
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;
}
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;
}
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;
}
Code: Select all
1
2
algorithm 3
math 9
8
math
Code: Select all
Case 1: Late
Code: Select all
/* deleted after AC */
Code: Select all
/*deleted after ac*/
Code: Select all
2
3
compiler 4
cplusplus 1
java 8
5
compiler
2
algorithm 3
math 9
4
java
Code: Select all
Case 1: Yesss
Case 2: Do your own homework!
brianfry713 wrote:Input:AC output:Code: Select all
2 3 compiler 4 cplusplus 1 java 8 5 compiler 2 algorithm 3 math 9 4 java
just forgot to clear mapCode: Select all
Case 1: Yesss Case 2: Do your own homework!
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;
}