All about problems in Volume 100. If there is a thread about your problem, please use it. If not, create one with its number in the subject.
Moderator: Board moderators
mf
Guru
Posts: 1244 Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:
Post
by mf » Mon Feb 26, 2007 6:16 am
helloneo wrote: Input doesn't have a blank line.. because..
The given lines will contain none of the first 32 or last 128 ASCII characters
Well, it doesn't (and that's strange, given who's the problemsetter
).
But I don't see how that is implied by the part of the problem statement that you quote. It just says there will be no whitespaces or any 'weird' characters in lines.
helloneo
Guru
Posts: 516 Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
Post
by helloneo » Mon Feb 26, 2007 6:28 am
Well.. I kind of misunderstood.. and my AC program totally takes care of the input contains blank line..
My output for stcheungj's input
lumier
New poster
Posts: 1 Joined: Sat Mar 10, 2007 2:20 pm
Post
by lumier » Sat Mar 10, 2007 2:24 pm
I can't find where my program is failing...
Help please! Thank you
Code: Select all
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
using namespace std;
bool comp(char a, char b){
return a > b;
}
typedef pair<int, int> P;
int main(){
string a;
int cont = 0;
while (cin >> a){
if (cont != 0) cout << endl;
erre = 1;
sort(a.begin(), a.end(), comp);
int n = a.size();
vector<P> v;
int c = 1;
char ch;
int max = 0;
for (int i = 0; i < n; ++i){
if (a[i] == a[i + 1]){
++c;
}
else {
P aux;
aux.first = a[i];
aux.second = c;
v.push_back(aux);
if (c > max) max = c;
c = 1;
}
}
n = v.size();
for(int j = 1; j != max + 1; ++j){
for (int i = 0; i < n; ++i){
if(v[i].second == j) cout << v[i].first << " " << v[i].second << endl;
}
}
}
}
Thanks a lot
Debashis Maitra
Learning poster
Posts: 62 Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
Post
by Debashis Maitra » Sat Mar 10, 2007 4:43 pm
You didnt tell what is your problem
I have compiled your code in G++ compiler
if gives me following message
Code: Select all
10062.cpp: In function int main():
10062.cpp:18: error: erre was not declared in this scope
I think your output format is also not correct
Sometimes you can get WA instead of PE in the case of string related problem
Akash chhoyar swopno
Dream to touch the sky
arakdev
New poster
Posts: 4 Joined: Sun Feb 11, 2007 6:38 pm
Location: Iran
Contact:
Post
by arakdev » Sat Mar 10, 2007 11:12 pm
I have tried any change in possition of "\n" in my program and I think 90 % percent who solved this problem first got PE . So one helper who got AC , please put the printing section of him/her program.Please Don't help by telling put \n here or here ? Copy Printing Section of Your program Plz.
here's my code
for(i=0;i<row;i++)
{
printf("%d %d",result[0],result[1]);
if(i!=row-1) printf("\n");
}
printf("\n");
Plz Help
Debashis Maitra
Learning poster
Posts: 62 Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
Post
by Debashis Maitra » Sun Mar 11, 2007 8:23 pm
Read output format
Code: Select all
A blank line should separate each set of output.
That means there is a blank line between 2 test case
And dont open a new thread if there is one already
Use previous posts to post your problem
Akash chhoyar swopno
Dream to touch the sky
arakdev
New poster
Posts: 4 Joined: Sun Feb 11, 2007 6:38 pm
Location: Iran
Contact:
Post
by arakdev » Sun Mar 11, 2007 9:32 pm
Thanks to Debashis Maitra for his useful help, that was a good help, short and useful , He mentioned to important point instead of confusing me.
Here is accepted code :
int time =0 ;
if(time) printf("\n");
else time=1;
....
for(i=0;i<row;i++)
printf("%d %d\n",result[0]
,result[1]);
hope to work for others too,
Debashis Maitra
Learning poster
Posts: 62 Joined: Sun Jul 09, 2006 8:31 am
Location: University of Dhaka
Contact:
Post
by Debashis Maitra » Sun Mar 11, 2007 10:05 pm
Thats good
Most of the time you can get PE for new line or printing spaces
So next time read the output format of your problem carefully and get AC
Keep posting and enjoy programming
Akash chhoyar swopno
Dream to touch the sky
Oronno
New poster
Posts: 21 Joined: Sun Jul 09, 2006 1:42 pm
Location: Dhaka
Contact:
Post
by Oronno » Sun Mar 18, 2007 11:09 am
I have done this problem; it show right answer for all testing input. But when i submit it, it show output limit exceed!
why?
Please help me or give me some test input&output
Last edited by
Oronno on Fri Feb 29, 2008 12:13 pm, edited 2 times in total.
I like programming but i am so lazy to do it...
helloneo
Guru
Posts: 516 Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea
Post
by helloneo » Sun Mar 18, 2007 11:42 am
Your program doesn't end..
change
to
ranacse05
New poster
Posts: 37 Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:
Post
by ranacse05 » Fri Apr 20, 2007 5:37 pm
Where is the bug?
#include<stdio.h>
#include<string.h>
int main()
{
char a[1000];
int i,j;
int c[160],v[160];
int ln,t;
while(gets(a))
{
ln=strlen(a);
for(i=0;i<160;i++)
{
v=i+33;
c=0;
}
for(j=33;j<194;j++)
for(i=0;i<ln;i++)
{
if(a==j)
c[j-33]++;
}
for(i=0;i<=159;i++)
for(j=i+1;j<=160;j++)
{
if(c>c[j])
{
t=c;
c=c[j];
c[j]=t;
t=v;
v=v[j];
v[j]=t;
}
}
for(i=0;i<160;i++)
if(c!=0)
printf("%d %d\n",v,c[i]);
}
return 0;
}
I like to solve problems.
Jan
Guru
Posts: 1334 Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:
Post
by Jan » Sat Apr 21, 2007 4:14 pm
ranacse05
New poster
Posts: 37 Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:
Post
by ranacse05 » Sun Apr 22, 2007 8:48 am
Please give me some samplz I/O for 10062
I like to solve problems.
abdullah<cse du>
New poster
Posts: 39 Joined: Mon Dec 04, 2006 2:18 pm
Location: Bangladesh(CSE DU)
Contact:
Post
by abdullah<cse du> » Sun Apr 22, 2007 10:36 am
ranacse05,
Try this input.
Input
Code: Select all
ihgvnkjhweriwujnmnvj54235443###^%--===
!@##$$%$#^&&++'~~~[][][{}{}QDXFGTYYVewqhvvxcfd))))6545209878??;;::
23102125456402154540324165410231654
jhjkhjhdfjfhdkjh
Output
Code: Select all
117 1
114 1
109 1
107 1
103 1
101 1
94 1
50 1
37 1
119 2
118 2
105 2
104 2
53 2
51 2
45 2
110 3
106 3
61 3
52 3
35 3
120 1
119 1
113 1
104 1
102 1
101 1
100 1
99 1
94 1
88 1
86 1
84 1
81 1
71 1
70 1
68 1
64 1
57 1
55 1
54 1
52 1
50 1
48 1
39 1
37 1
33 1
125 2
123 2
118 2
93 2
89 2
63 2
59 2
58 2
56 2
53 2
43 2
38 2
126 3
91 3
36 3
35 3
41 4
54 3
51 3
48 4
53 6
50 6
49 6
52 7
107 2
102 2
100 2
106 5
104 5
I think this will help you.
ABDULLAH.
Last edited by
abdullah<cse du> on Fri May 25, 2007 6:51 pm, edited 1 time in total.
ranacse05
New poster
Posts: 37 Joined: Wed Mar 28, 2007 5:08 pm
Location: Rajshahi
Contact:
Post
by ranacse05 » Tue Apr 24, 2007 6:13 pm
abdullah bhai my output is
Output
Code: Select all
107 1
117 1
37 1
109 1
94 1
101 1
50 1
114 1
103 1
51 2
53 2
45 2
104 2
105 2
118 2
119 2
61 3
35 3
52 3
110 3
106 3
58 1
39 1
48 1
99 1
100 1
101 1
102 1
33 1
104 1
64 1
50 1
37 1
81 1
52 1
68 1
84 1
54 1
113 1
86 1
70 1
88 1
71 1
119 1
120 1
55 1
94 1
57 1
59 2
38 2
93 2
118 2
56 2
53 2
63 2
43 2
123 2
89 2
125 2
35 3
91 3
36 3
41 3
126 3
51 3
54 3
48 4
49 6
53 6
50 6
52 7
102 2
107 2
100 2
104 5
106 5
Is it ok ? I'm still getting WA
I like to solve problems.