Page 2 of 2
Re: 11239 - Open Source
Posted: Mon Jan 13, 2014 12:44 pm
by uDebug
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
11239
Posted: Tue May 27, 2014 4:56 pm
by shubho.cse
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

Re: 11239
Posted: Wed Jun 11, 2014 11:40 pm
by brianfry713
Don't read from a file.
Re: 11239 - Open Source, Getting TLE, Help Pls...
Posted: Fri Feb 13, 2015 8:15 pm
by garbage
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;
}
Re: 11239 - Open Source
Posted: Sat Feb 14, 2015 12:09 am
by brianfry713
Describe your algorithm.
Re: 11239 - Open Source
Posted: Tue Mar 24, 2015 1:56 pm
by uradura
Re: 11239 - Open Source
Posted: Fri Jul 15, 2016 6:18 pm
by KhaledAshraf.
why iam getting WA ? Please Help !
http://ideone.com/YhExZc