11239 - Open Source

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

Moderator: Board moderators

User avatar
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 11239 - Open Source

Post by uDebug » Mon Jan 13, 2014 12:44 pm

Here's some input / output I found useful during testing / debugging. Thanks and credit goes to the original contributors for their test cases.

Input:

Code: Select all

ROBOTS
me
and
noone
LINUX
isthebest
isthebest
noone
ELECTRONIX PROJECT
hateit
burned
hateit
hateit
noone
C PROJECT
iscool
iamhere
hellworld
linux
gui
iscool
me
THIS IS THE LAST
helloworld
thisisme
hopeyougetaccepted
1
AB
AA
1
AA
x
c
BA
x
C
1
AA
BA
C
1
ROBOTS
me
and
noone
LINUX
isthebest
noone
noone
iamhere
ELECTRONIX PROJECT
isthebest
hateit
burned
hateit
hateit
noone
C PROJECT #2
iscool
iamhere
hellworld
linux
gui
iscool
me
THIS IS THE LAST
helloworld
thisisme
hopeyougetaccepted
gui
1
A
x
x
x
B
x
x
x
C
x
x
x
1
0
AC Output:

Code: Select all

C PROJECT 5
THIS IS THE LAST 3
ELECTRONIX PROJECT 2
LINUX 1
ROBOTS 1
AA 0
AB 0
AA 1
BA 0
C 0
AA 0
BA 0
C 0
C PROJECT #2 3
THIS IS THE LAST 3
ELECTRONIX PROJECT 2
ROBOTS 1
LINUX 0
A 0
B 0
C 0
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

shubho.cse
New poster
Posts: 1
Joined: Mon Jul 29, 2013 2:04 pm

11239

Post by shubho.cse » Tue May 27, 2014 4:56 pm

Why I'm Getting WA? :(

Code: Select all

#include<bits/stdc++.h>

#define vi vector<int>
#define pii pair<int, int>
#define vpii vector<pii>
#define msi map<string, int>
#define mem(arrayName,i) memset(arrayName,int (i),sizeof arrayName)
#define pb(number) push_back(number)
#define _VISIT true
#define _UNVISIT false

#define INF 2000000000
#define _INF 127
#define _HALF_INF 63

using namespace std;
bool compare (pair <string,int> p1,pair<string,int> p2){
    return p1.second>p2.second;
}
int main(){
    string str,project;
    msi mapForPro;
    map <string,string> mapForName;
    map <string,bool> statusForName;
    freopen("r.txt","r",stdin);
    while(getline(cin,str)){
        if(str=="0")
            break;
        if(str=="1"){
            vector<pair<string,int> > mapcopy(mapForPro.begin(),mapForPro.end());
            sort(mapcopy.begin(),mapcopy.end(),compare);
            for(vector < pair<string,int> > ::iterator it= mapcopy.begin(); it!=mapcopy.end(); it++){
                cout<<it->first<<" "<<it->second<<endl;
            }
            mapcopy.clear();
            mapForName.clear();
            mapForPro.clear();
            statusForName.clear();
            continue;
        }
        if(isupper(str[0])){
            project = str;
            mapForPro[project] = 0;
        }
        if(!isupper(str[0])){
            if(mapForName.find(str)==mapForName.end() and mapForName[str]!=project){
                ++mapForPro[project];
                mapForName[str]=project;
                statusForName[str]=true;
            }
            else if(mapForName.find(str)!=mapForName.end() and mapForName[str]!=project){
                if(statusForName[str]==true){
                    --mapForPro[mapForName[str]];
                    statusForName[str]=false;
                }
            }
        }

    }
}
Thanks in advance :D

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

Re: 11239

Post by brianfry713 » Wed Jun 11, 2014 11:40 pm

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

garbage
New poster
Posts: 19
Joined: Thu Feb 21, 2013 5:46 am

Re: 11239 - Open Source, Getting TLE, Help Pls...

Post by garbage » Fri Feb 13, 2015 8:15 pm

Code: Select all

#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
#include<set>
#define sz 100
using namespace std;

struct PrDes
{
    int cnt;
    string name;

    bool operator < (const PrDes& p)const
    {
        if(cnt > p.cnt)
            return true;
        
        else
            if(cnt == p.cnt && name < p.name)
                return true;
    }
}R;

int main()
{
    int i=-1, cnt = 0;
    string pName;
    vector<string>project;
    vector<set<string> >myVec;
    
    while(getline(cin, pName))
    {
        if(pName == "0")
            break;
        
        if(pName == "1")
        {
            int hold = 0;
            vector<PrDes>v;
            map<string, int>myMap;
            set<string>::iterator it;

            for(int j=0;j<=i;j++)
            {
                cnt = 0;
                for(it=myVec[j].begin(); it!=myVec[j].end(); it++)
                {
                    if(myMap[*it] == 0)
                    {
                        cnt++;
                        myMap[*it] = j+1;
                    }
                    
                    else
                        if(myMap[*it] != j+1)
						{
                            hold = myMap[*it];
							v[hold-1].cnt--;
						}
                }
                
                R.name = project[j];
                R.cnt = cnt;
                v.push_back(R);
            }
            
            sort(v.begin(), v.end());
            
            for(int j=0;j<v.size();j++)
                cout<<v[j].name<<" "<<v[j].cnt<<endl;
            
            v.clear();
			project.clear();
			i = -1;
        }
        
        if(pName[0]>='A' && pName[0]<='Z')
        {
            i++;
            project.push_back(pName);
            myVec.push_back(set<string>());
        }
        
        if(pName[0]>='a' && pName[0]<='z')
            myVec[i].insert(pName);
    }
    return 0;
}

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

Re: 11239 - Open Source

Post by brianfry713 » Sat Feb 14, 2015 12:09 am

Describe your algorithm.
Check input and AC output for thousands of problems on uDebug!

uradura
New poster
Posts: 11
Joined: Thu Jan 01, 2015 10:31 am

Re: 11239 - Open Source

Post by uradura » Tue Mar 24, 2015 1:56 pm


KhaledAshraf.
New poster
Posts: 3
Joined: Fri Jul 15, 2016 6:11 pm

Re: 11239 - Open Source

Post by KhaledAshraf. » Fri Jul 15, 2016 6:18 pm

why iam getting WA ? Please Help !
http://ideone.com/YhExZc

Post Reply

Return to “Volume 112 (11200-11299)”