ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1319. Hotel

What's in test #4? Please, help
Posted by Sapunovnik 10 Jun 2017 15:16
Hi. My solution works on my computer but there is not.

What's wrong with my code?

#include <iostream>

using namespace std;

int main()
{
    int n, c = 1;
    int pix[100][100];

    for ( int i = 0; i < n; ++i ) {
        for ( int j = 0; j < n; ++j ) {
            pix[i][j] = 0;
        }
    }

    cin >> n;

    for ( int i = 0; i < n; ++i ) {
        for ( int j = (n - 1); j >= 0; --j ) {
            if ( pix[i][j] > 0 )
                continue;

            int ii =  i, jj = j;

            while ( ii < n && jj < n ) {
                pix[ii][jj] = c;
                ii++;
                jj++;
                c++;
            }
        }
    }

    for ( int i = 0; i < n; ++i ) {
        for ( int j = 0; j < n; ++j ) {
            cout << pix[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

Edited by author 10.06.2017 15:16

Edited by author 10.06.2017 15:16

Edited by author 10.06.2017 15:17