339 - SameGame Simulation
Moderator: Board moderators
-
- New poster
- Posts: 6
- Joined: Mon May 05, 2003 1:48 pm
339 - SameGame Simulation
i've got the program working but the only problem is
do they require the output after they input all the grids and enter the final 0, 0 or they want the final grid to be displayed after each and every grid's 0,0 is encounter ????
do they require the output after they input all the grids and enter the final 0, 0 or they want the final grid to be displayed after each and every grid's 0,0 is encounter ????
-
- Experienced poster
- Posts: 192
- Joined: Sat Nov 30, 2002 5:14 am
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 pm
Well ashutoshkorde, that doesn't realy matter, because the judge first lets you complete the program, collecting all output in one big text file, and then checks this file to determine the verdict. So it's realy up to you how and in which order you read input, process data and write output, as long as the resulting output file is correct.
(The actual situation is a little more complicated, because the running program can be interrupted by errors, but that is the general idea).
(The actual situation is a little more complicated, because the running program can be interrupted by errors, but that is the general idea).
-
- New poster
- Posts: 6
- Joined: Mon May 05, 2003 1:48 pm
339 Wrong Anwer
I wrote an implementation for 339 problem. I tried to submit it but the Onlid Jutge answers me Wrong Answer. For this reason, I want a sample output from a program that the online Judge accepts. Thanks.[/cpp]
-
- Guru
- Posts: 834
- Joined: Wed May 29, 2002 4:11 pm
- Location: Wroclaw, Poland
- Contact:
Why did you not search this forum before posting this ? This problem has our thread - look at it ...
DM
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)
Born from ashes - restarting counter of problems (800+ solved problems)
Can anybody give me some critical inputs/outputs or find a bug in my code? I've already got more than 10 WA
Code: Select all
#include <iostream>
#include <vector>
using namespace std;
vector < vector < int > > data;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
bool good(int x, int y, int num){
return x > -1 && y > -1 && x < (int)data.size() && y < (int)data[x].size() && data[x][y] == num;
}
void dfs(int x, int y, int num){
if(!good(x, y, num)) return;
data[x][y] = -1;
for(int d = 0; d < 4; d++) dfs(x + dx[d], y + dy[d], num);
}
int m, n;
int main(){
int test = 1;
while(cin >> m >> n && m && n){
data.clear();
data.resize(n, vector < int > (m));
for(int i = 0; i < m; i++)
for(int j = 0; j < n; j++) cin >> data[j][i];
while(cin >> m >> n && (m || n)){
m--, n--;
if(m < 0 || n < 0 || n >= (int)data.size() || m >= (int)data[n].size()) continue;
bool f = false;
for(int d = 0; d < 4; d++) f |= good(n + dx[d], m + dy[d], data[n][m]);
if(!f) continue;
dfs(n, m, data[n][m]);
for(unsigned i = 0; i < data.size(); i++)
for(int j = data[i].size() - 1; j >= 0; j--)
if(j < (int)data[i].size() && data[i][j] == -1) data[i].erase(data[i].begin() + j);
for(int i = data.size() - 1; i >= 0; i--)
if(i < (int)data.size() && data[i].empty()) data.erase(data.begin() + i);
}
cout << "Grid " << test++ << "." << endl;
if(data.empty()) cout << " Game Won" << endl;
else{
cout << endl;
int mx = 0;
for(unsigned i = 0; i < data.size(); i++) mx >?= (int)data[i].size();
for(int j = mx - 1; j >= 0; j--){
cout << " ";
for(unsigned i = 0; i < data.size(); i++)
if(j < (int)data[i].size()) cout << " " << data[i][j];
else cout << " ";
cout << endl;
}
}
cout << endl;
}
return 0;
}
can't understand sample i/o
I can't understand the sample i/o for this problem.
According to me the output for the 1st sample input is :
What's wrong in my understanding of the problem ?
According to me the output for the 1st sample input is :
Code: Select all
3
3 1
3 5 2 2
What's wrong in my understanding of the problem ?
-
- Guru
- Posts: 647
- Joined: Wed Jun 26, 2002 10:12 pm
- Location: Hong Kong and New York City
- Contact:
The input is given upside down.. when I was reading this problem, it took me a while to realize too..
Check out http://www.algorithmist.com !
I still don't understand. Can u help me about this?? I want to know about the output pattern. Anybody can help??minskcity wrote:I've figured out that I actually had a presentation error - they want spaces printed so that the size of the game state is always the same, even if most of the numbers are gone...
Thanks.
Ami ekhono shopno dekhi...
HomePage
HomePage
for the input:
output (after clicking on 3) should be:where '*' stays for blank space. If you don't print those blanks, you will get WA.
Code: Select all
3*3*3
2*3*3
Code: Select all
*********
****2****
Thankx minskcity, but I m still getting WA.
Can u tell me what is the output for the following input set...
( If u don't mind please use * instead of space)
Input:
And my code gives the following output
Output:
I use * instead of space. Any tricky cases?
Can u tell me what is the output for the following input set...
( If u don't mind please use * instead of space)
Input:
Code: Select all
4 4
1 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
1 2
1 1
0 0
1 1
0
1 1
0 0
2 3
0 0 0
0 2 2
2 3
2 2
0 0
2 3
0 0 0
0 2 2
2 3
1 1
0 0
0 0
Output:
Code: Select all
Grid 1.
***********
***********
***********
****1******
Grid 2.
****0
Grid 3.
****0****
****0*0*0
Grid 4.
Game Won
Ami ekhono shopno dekhi...
HomePage
HomePage
My AC program outputs
for your inputs.
Code: Select all
Grid 1.
***********
***********
***********
****1******
Grid 2.
****0
Grid 3.
****0****
****0*0*0
Grid 4.
****Game Won