11360 - Have Fun with Matrices
Moderator: Board moderators
Re: 11360 - Have Fun with Matrices
brianfry713,
Thanks for the great test case.
How did you generate these? Did you write a program to do this?
Thanks for the great test case.
How did you generate these? Did you write a program to do this?
Last edited by uDebug on Thu Mar 27, 2014 9:14 am, edited 1 time in total.
Re: 11360 - Have Fun with Matrices
All I did was useplamplam wrote:You have to take the operations(for example inc, transpose, row a b etc) using scanf("%s");.When I tried with gets() the judge blessed me with a "Wrong Answer"
Code: Select all
getline(cin, aLine);
For the switch operations, I added the following lines
Code: Select all
istringstream ss(aLine);
ss >> aLine >> a >> b;
In other words, there's nothing fancy going on with the judge's input.
If your code passes brianfry713's exhaustive test case, you should be good.
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11360 - Have Fun with Matrices
I often write a program using rand() to generate test cases.
Check input and AC output for thousands of problems on uDebug!
Re: 11360 - Have Fun with Matrices
Great stuff! Thanks for sharing.brianfry713 wrote:I often write a program using rand() to generate test cases.
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11360 - Have Fun with Matrices
Getting TLE ! What should I do to get rid of it? Here is my code:
Code: Select all
#include<stdio.h>
struct matrix
{
int col[15];
int cl[15];
};
int main()
{
int t,n,c,comand,i,j,k,x,y,temp;
char oper[12];
struct matrix row[15];
struct matrix rw[15];
scanf("%d",&t);
for(c=1;c<=t;c++)
{
scanf("%d",&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
scanf("%d",&row[i].col[j]);
}
}
scanf("%d",&comand);
getchar();
while(comand--)
{
gets(oper);
if(oper[0]=='i')
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
row[i].col[j]++;
}
}
}
else if(oper[0]=='d')
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
row[i].col[j]--;
}
}
}
else if(oper[0]=='r')
{
x=oper[4]-'0';
y=oper[6]-'0';
for(i=1;i<=n;i++)
{
temp=row[x].col[i];
row[x].col[i]=row[y].col[i];
row[y].col[i]=temp;
}
}
else if(oper[0]=='c')
{
x=oper[4]-'0';
y=oper[6]-'0';
for(i=1;i<=n;i++)
{
temp=row[i].col[x];
row[i].col[x]=row[i].col[y];
row[i].col[y]=temp;
}
}
else if(oper[0]=='t')
{
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
rw[i].cl[j]=row[i].col[j];
}
}
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
row[i].col[j]=rw[j].cl[i];
}
}
}
}
printf("Case %d#\n",c);
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
if(j!=1)
printf(" ");
printf("%d",row[i].col[j]);
}
printf("\n");
}
printf("\n");
}
return 0;
}
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11360 - Have Fun with Matrices
Try running your code on the sample input.
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11360 - Have Fun with Matrices
Code: Select all
Accepted!!
Last edited by Shahidul.CSE on Thu Aug 28, 2014 5:09 am, edited 1 time in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11360 - Have Fun with Matrices
Try input:Output should be 0
Code: Select all
1
1
9
11
inc
inc
inc
inc
inc
inc
inc
inc
inc
inc
inc
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11360 - Have Fun with Matrices
Thanks, Got AC!!brianfry713 wrote:Try input:Output should be 0Code: Select all
1 1 9 11 inc inc inc inc inc inc inc inc inc inc inc
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com