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 1313. Some Words about Sport

Why My program don't work
Posted by AOTL_EKREM 3 Mar 2006 23:40
var
a:array[1..100,1..100] of byte;
counter,i,j,temp,min,n:integer;
b:array[1..10000] of integer;
 begin
  readln(n);
  for i:=1 to n do
   begin
    for j:=1 to n do
     read(a[i,j]);
     writeln;
   end;
   {*********************}
   for i:=1 to n do
    begin
     for j:=1 to n do
      begin
       counter:=counter+1;
       b[counter]:=a[i,j];
      end;
    end;
    for i:=1 to n*n do
     begin
      min:=i;
       for j:=i to n*n do
        if b[min]>b[j] then min:=j;
        temp:=b[i];
        b[i]:=b[min];
        b[min]:=temp;
     end;
     writeln;
     for i:=1 to n*n do
      write(b[i],' ');
     end.
Re: Why My program don't work
Posted by Burunduk1 5 Mar 2006 01:49
Test:
3
1 2 3
4 5 6
7 8 9

Right answer:
1 4 2 7 5 3 8 6 9
Re: Why My program don't work
Posted by Osipov Kirill 25 Apr 2006 19:12
#include "iostream.h"
void main()
{
int n;
cin>>n;

int a[100][100];
int str=0,st=0,i,j,qst=0,qstr=0;
      for(i=0;i<n;i++)
    for(j=0;j<n;j++)
    cin>>a[i][j];
for(i=0;i<((n*n)+n*2);i++)
        {
        if((str>=0)&&(st<n))
        {cout<<a[str][st]<<" ";str=str-1;st=st+1;}
        else
        {
                        if(st>=n)
                                {str=n-1;st=1+qst;qst++;}
                if ((str<=0)&&(st<=n))
                                {st=0;str=1+qstr;qstr++;}
                }
    }
}

Why "Wrong answer" ??? (on test 2)

Edited by author 27.04.2006 04:46