441 - Lotto
Moderator: Board moderators
441 - Lotto
Any trick in getting AC instead of PE on this problem 441 (Lotto)? I tried couple newline variations but still no luck.
441
Between every output set you should put a new line.
Remember
See the sample ouput for input
Output
If same you owe an AC. 
Remember
Also exactly one space between integers sholud be followed.The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.
See the sample ouput for input
Code: Select all
7 1 2 3 4 5 6 7
7 1 2 3 4 5 6 7
0
Code: Select all
1 2 3 4 5 6\n
1 2 3 4 5 7\n
1 2 3 4 6 7\n
1 2 3 5 6 7\n
1 2 4 5 6 7\n
1 3 4 5 6 7\n
2 3 4 5 6 7\n\n
1 2 3 4 5 6\n
1 2 3 4 5 7\n
1 2 3 4 6 7\n
1 2 3 5 6 7\n
1 2 4 5 6 7\n
1 3 4 5 6 7\n
2 3 4 5 6 7\n

Solving for fun..
Re: 441 - Lotto PE
I got WA again and again.
Some one please help me.


Code: Select all
Yes!!!
I got Accepted i was taking the input in wrong way
Again thank you very much linux



try_try_try_try_&&&_try@try.com
This may be the address of success.
This may be the address of success.
Re: 441 - Lotto PE
Hi,
Sorry for reviving an old thread,but I am not sure why am i getting WA:
THX.
Sorry for reviving an old thread,but I am not sure why am i getting WA:
Code: Select all
#include<stdio.h>
int main()
{
int i,j,size,a[49],b[6],l,k,m,n;
while(1)
{
scanf("%d",&size);
if(size==0)
break;
for(i=0;i<size;i++)
{
scanf("%d",&a[i]);
if(i<6)
b[i]=a[i];
}
j=4;
l=5;
n=l+1;
m=size;
for(i=0;i<6;i++)
printf("%d ",b[i]);
while(j>=(-1))
{
if(l>j)
{
if(n<m)
{
b[l]=a[n];
printf("\n");
for(i=0;i<6;i++)
printf("%d ",b[i]);
n++;
}
else
{
n=l+1;
l--;
m--;
}
}
else
{
k=0;
for(i=0;i<7;i++)
{
if(i==j)
continue;
b[k]=a[i];
k++;
}
n=i;
if(j>=0)
{
printf("\n");
for(i=0;i<6;i++)
printf("%d ",b[i]);
}
j--;
m=size;
l=5;
}
}
printf("\n");
}
return 0;
}
-
- Experienced poster
- Posts: 136
- Joined: Sat Nov 29, 2008 8:01 am
- Location: narayangong,bangladesh.
- Contact:
Re: 441 - Lotto PE
Two things i can say:
1.you code does not follow this-
1.you code does not follow this-
2. This print a space after the last number,which should no be.The test cases have to be separated from each other by exactly one blank line. Do not put a blank line after the last test case.
Code: Select all
printf("%d ",b[i]);
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com
Re: 441 - Lotto PE
I have modified the code as what u have said,still no luck:
Code: Select all
#include<stdio.h>
int main()
{
int i,j,size,a[49],b[6],l,k,m,n,c=0;
while(1)
{
if(c==1)
printf("\n");
scanf("%d",&size);
if(size==0)
break;
for(i=0;i<size;i++)
{
scanf("%d",&a[i]);
if(i<6)
b[i]=a[i];
}
c=1;
j=4;
l=5;
n=l+1;
m=size;
for(i=0;i<6;i++)
{
printf("%d",b[i]);
if(i<5)
printf(" ");
else
printf("\n");
}
while(j>=(-1))
{
if(l>j)
{
if(n<m)
{
b[l]=a[n];
for(i=0;i<6;i++)
{
printf("%d",b[i]);
if(i<5)
printf(" ");
else
printf("\n");
}
n++;
}
else
{
n=l+1;
l--;
m--;
}
}
else
{
k=0;
for(i=0;i<7;i++)
{
if(i==j)
continue;
b[k]=a[i];
k++;
}
n=i;
if(j>=0)
{
for(i=0;i<6;i++)
{
printf("%d",b[i]);
if(i<5)
printf(" ");
else
printf("\n");
}
}
j--;
m=size;
l=5;
}
}
}
return 0;
}
Re: 441 - Plz help me.....
I tried 10 more test data and it was all right. But Bad OJ(Sorry
) says it's WA
I don't no why it is
Please help me.....
Please give some critical inputs......
Or hint from code.
Sorry, But I'm using C++.







I don't no why it is








Please help me.....
Please give some critical inputs......
Or hint from code.
Sorry, But I'm using C++.
Code: Select all
#include <iostream>
using namespace std;
int s[13];
int Base2[13];
int main()
{
int k;
int i, j;
int ktimes2;
int cnt = 0;
int imsi;
int cntzero = 0;
int first = false;
while (cin >> k){
if (k == 0) break;
if (first) cout << endl;
first = true;
for (i = 0; i < k; i++){
cin >> s[i];
}
ktimes2 = 1;
for (i = 0; i < k; i++){
ktimes2 *= 2;
}
for (i = 0; i < ktimes2; i++){
imsi = i;
for (j = 0; j < 13; j++){
Base2[j] = 0;
}
cnt = 0;
while (imsi > 0){
Base2[cnt++] = imsi%2;
imsi /= 2;
}
cntzero = 0;
for (j = 0; j < k; j++){
if (Base2[j] == 1) cntzero++;
}
if (cntzero == 6){
for (j = 0; j < k; j++){
if (Base2[j] == 1){
if (j != k-1){
cout << s[j] << " ";
}
else cout << s[j];
}
}
cout << endl;
}
}
}
return 0;
}
-
- New poster
- Posts: 31
- Joined: Thu Nov 24, 2011 12:08 am
Re: 441 - Lotto PE
it's a very easy problem if your approach is iterative backtracking.
since you need to take a fixed(6) numbers at a time, you can iterate 6 loops. and the limit of k is 6<k<13, so no possibility of getting tle!!
since you need to take a fixed(6) numbers at a time, you can iterate 6 loops. and the limit of k is 6<k<13, so no possibility of getting tle!!
Re: 441 - Lotto PE
I have tried this problem more times than I can count. But every time I get the damn "Submission Error".
I don't know why OJ showing this. Has anyone got any idea?
I am using C++ stl funtion "next_permutation" and a vector to store data.




I don't know why OJ showing this. Has anyone got any idea?
I am using C++ stl funtion "next_permutation" and a vector to store data.
Check out UVA Arena - a software build for UVA solvers @ http://dipu-bd.github.io/UVA-Arena/
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 441 - Lotto PE
See "Information on Submission Errors" at http://uva.onlinejudge.org/
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 122
- Joined: Tue Apr 16, 2002 10:07 am
Re: 441 - Lotto
Instead of using recursion, you can solve this problem using 6 nested loops 
For me, it ran in 0.015 seconds.

For me, it ran in 0.015 seconds.
441 - Lotto
Hello , I'm relatively new in that and i tried solve this problem i used linux diff comand to compare my output with required output and is the same but when I submitted was WA someone can look to my code please.
Code: Select all
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<string,string> ss;
typedef vector<ss> vss;
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb push_back
int main(int argc, char const *argv[]) {
int n;
vi v;
cin>>n;
while(n!=0){
while(cin.peek()!='\n'){
v.pb(n);
cin>>n;
}
v.pb(n);
sort(all(v));
auto it = unique(all(v));
v.resize(distance(v.begin(),it));
for (int i = 0; i < v.size(); i++) {
for (int j = i+1; j < v.size() && v[i]!=v[j]; j++) {
for (int k = j+1; k < v.size() && v[j]!=v[k]; k++) {
for (int l = k+1; l < v.size() && v[k]!=v[l]; l++) {
for (int z = l+1;z < v.size() && v[l]!=v[z];z++) {
for (int x = z+1; x < v.size() && v[z]!=v[x]; x++) {
cout<<v[i]<<" "<<v[j]<<" "<<v[k]<<" "<<v[l]<<" "<<v[z]<<" "<<v[x]<<endl;
}
}
}
}
}
}
cin>>n;
if(n!=0)
cout<<endl;
v.clear();
}
return 0;
}
-
- Experienced poster
- Posts: 122
- Joined: Tue Apr 16, 2002 10:07 am
Re: 441 - Lotto
Try taking the input in a simpler way as below..
Code: Select all
while (cin >> n) {
if (n == 0) break;
v.clear();
// Read set
// No need to sort as the input is already sorted.
// We also assume that there is no duplicate in the set
if (testcase > 1)
printf("\n");
// Process and output here..
}