Author |
Message |
saltpro15
|
Posted: Sat Apr 11, 2009 7:35 pm Post subject: not understanding this problem |
|
|
hey guys,
I'm getting back into the SPOJ questions, can't seem to understand what this one is asking, it can be found here
a palace of size N when N = 3 should be like
[ ] [ ] [ ]
[ ] [ ] [ ]
[ ] [ ] [ ]
with a total of 9 rooms right? so why is the output 16? |
|
|
|
|
|
Sponsor Sponsor
|
|
|
DanielG
|
Posted: Sat Apr 11, 2009 7:57 pm Post subject: RE:not understanding this problem |
|
|
maybe the N=3 is referring to the number of walls on each side?? so the number of rooms is (n+1)^2??? |
|
|
|
|
|
saltpro15
|
Posted: Sat Apr 11, 2009 7:58 pm Post subject: RE:not understanding this problem |
|
|
oh maybe, thanks Daniel |
|
|
|
|
|
saltpro15
|
Posted: Sat Apr 11, 2009 8:08 pm Post subject: RE:not understanding this problem |
|
|
hmm, attempted, returned a wrong answer, there must still be a problem somewhere |
|
|
|
|
|
Tony
|
Posted: Sat Apr 11, 2009 8:16 pm Post subject: RE:not understanding this problem |
|
|
The wording is ambiguous. 16 refers to the number of different ways people can be arranged inside a palace (combinatorics problem), not the number of rooms (output = n^2 makes it too simple). But I don't see where the number of people would be specified. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
saltpro15
|
Posted: Sat Apr 11, 2009 8:18 pm Post subject: RE:not understanding this problem |
|
|
problem abandoned for now, I'll just try some other problems, these are good ECOO practice |
|
|
|
|
|
Analysis Mode
|
Posted: Sat Apr 11, 2009 8:22 pm Post subject: Re: not understanding this problem |
|
|
If you're stuck on a problem, the SPOJ Forums are your best friend. |
|
|
|
|
|
saltpro15
|
Posted: Sat Apr 11, 2009 8:27 pm Post subject: Re: not understanding this problem |
|
|
c++: |
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream fin ("in.txt");
ofstream fout ("debug.txt");
int tc;
int walls;
fin >> tc;
for (int a = 0; a < tc; a++);
{
fin >> walls;
fout << (walls + 1) * (walls + 1) << endl;
}
return 0;
}
|
I knew it wouldn't be that easy haha, worth a shot lol |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Analysis Mode
|
Posted: Sat Apr 11, 2009 8:46 pm Post subject: Re: not understanding this problem |
|
|
why are you inputting from files? All input is done from screen. |
|
|
|
|
|
saltpro15
|
Posted: Sat Apr 11, 2009 8:49 pm Post subject: RE:not understanding this problem |
|
|
files help me think, i just ran it and it produced some number like -399764534, so I think C++ is doing it's thing again
edit : input numbers are 1 and 3 |
|
|
|
|
|
DanielG
|
Posted: Sat Apr 11, 2009 8:58 pm Post subject: RE:not understanding this problem |
|
|
can you put up a link to the question, it will help us figure out what it's asking. just a little. |
|
|
|
|
|
saltpro15
|
Posted: Sat Apr 11, 2009 9:00 pm Post subject: RE:not understanding this problem |
|
|
already have, it's in my first post
here it is again, just in case the link doesn't show for some
http://www.spoj.pl/problems/PALACE/ |
|
|
|
|
|
Analysis Mode
|
Posted: Sat Apr 11, 2009 9:08 pm Post subject: Re: not understanding this problem |
|
|
long longs and bignums are your friends, too. |
|
|
|
|
|
bbi5291
|
Posted: Sat Apr 11, 2009 10:02 pm Post subject: Re: not understanding this problem |
|
|
Put in a more mathematical style, the question asks: how many distinct NxN grids are there, such that each cell is either empty or filled, and every row and column contains an odd number of filled cells?
And no, you don't need long longs / bignums, because the answer is to be outputted modulo 98777. |
|
|
|
|
|
CodeMonkey2000
|
Posted: Sat Apr 11, 2009 10:57 pm Post subject: Re: not understanding this problem |
|
|
For N=3 these are all the possible arrangements (a block with a * means an occupied room). I'm pretty sure this is a DP problem, look at the number of ways you can place people in an (n-1) matrix. I'm pretty sure you can brute force it to find patterns.
1
[*][*][*]
[*][*][*]
[*][*][*]
2
[ ][*][ ]
[ ][*][ ]
[*][*][*]
3
[*][*][*]
[ ][*][ ]
[ ][*][ ]
4
[ ][*][ ]
[*][*][*]
[ ][*][ ]
5
[*][ ][ ]
[ ][*][ ]
[ ][ ][*]
6
[ ][ ][*]
[ ][*][ ]
[*][ ][ ]
7
[*][ ][ ]
[ ][ ][*]
[ ][*][ ]
8
[ ][ ][*]
[*][ ][ ]
[ ][*][ ]
9
[ ][*][ ]
[ ][ ][*]
[*][ ][ ]
10
[*][ ][ ]
[*][*][*]
[*][ ][ ]
11
[ ][*][ ]
[*][*][*]
[ ][*][ ]
12
[ ][ ][*]
[*][*][*]
[ ][ ][*]
13
[ ][*][ ]
[*][ ][ ]
[ ][ ][*]
14
[*][ ][ ]
[* ][ ][ ]
[*][*][*]
15
[ ][ ][*]
[ ][ ][*]
[*][*][*]
16
[*][*][*]
[*][ ][ ]
[*][ ][ ] |
|
|
|
|
|
|