ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1320. Разбиение графа

qwe Something wrong on testcase 6. [22] // Задача 1320. Разбиение графа 10 май 2004 19:24
please check it. AC'ers try to submit your solution one more time. If its OK, then sorry(i'm stupid).
Vladimir Yakovlev (USU) Why do you think so? [21] // Задача 1320. Разбиение графа 11 май 2004 02:59
qwe Re: Why do you think so? [20] // Задача 1320. Разбиение графа 11 май 2004 14:45
First i got WA #6

I have counted the number of edges. in program is that code:

If count=6 then while true do;
TL#6
I changed to :
If count=6 then begin writeln(1); halt; end;
WA#6
Than:
If count=6 then begib writeln(0); halt; end;
WA#6...

It's something strange, because output maybe only 1 or 0...
Vladimir Yakovlev (USU) All is ok with test #6, the answer belongs to set {0,1}. [19] // Задача 1320. Разбиение графа 11 май 2004 20:07
No. I'm sure. Please submit your solution ad you'll see.
Vladimir Yakovlev (USU) I saw the output for test #6. You try to submit once again. [17] // Задача 1320. Разбиение графа 11 май 2004 22:29
WA#6...
Ярославцев Григорий Re: I saw the output for test #6. You try to submit once again. [1] // Задача 1320. Разбиение графа 11 май 2004 23:25
I also get WA on test #6. Please tell me if you get AC.
Ярославцев Григорий писал(a) 11 мая 2004 23:25
I also get WA on test #6.  
me too =(

Edited by author 11.05.2004 23:50
Vladimir Yakovlev (USU) The answer for test #6 is 0, you may check this. [13] // Задача 1320. Разбиение графа 12 май 2004 00:10
WA#6...
Vladimir Yakovlev (USU) It means that your program is wrong. [11] // Задача 1320. Разбиение графа 12 май 2004 23:13
NO! Just submit your solution and you'll see i'm right!
Vladimir Yakovlev (USU) OK, see this... [9] // Задача 1320. Разбиение графа 13 май 2004 00:52
My program gets AC (see link http://acm.timus.ru/status.aspx?space=1&pos=598572 )
It may output only 0 or 1.

So, it's your mistake.

Edited by author 13.05.2004 00:53
qwe Re: OK, see this... [8] // Задача 1320. Разбиение графа 13 май 2004 01:12
OK, but how...
if count=6 then
begin
  while true do;
  halt;
end;

TL;

if count=6 then
begin
  writeln(0);
  halt;
end;

WA

if count=6 then
begin
  writeln(1);
  halt;
end;

WA

Is it possible?
qwe Re: OK, see this... [7] // Задача 1320. Разбиение графа 13 май 2004 12:43
hm... accept... i just changed eof to seekoef. But why? Who can explain me?
Ярославцев Григорий What's the difference?! [6] // Задача 1320. Разбиение графа 13 май 2004 19:35
Thank you very much!
I also got accepted just changing eof on seekeof.
But what is the difference?

Edited by author 13.05.2004 19:36

Edited by author 13.05.2004 19:37
Vladimir Yakovlev (USU) There is a diffirence... [5] // Задача 1320. Разбиение графа 13 май 2004 20:32
There may be a following situation. A line break (eoln) ends the last line of input and your program read last number with "read" function, so only a number is removed from the input stream, but the eoln symbol is still in stream. At this moment "eof" function returns false (it sees eoln symbol, so it is not end of file), but "seekeof" returns true (it skips all whitespace in a stream including eoln symbol).
Ярославцев Григорий Re: There is a diffirence... [4] // Задача 1320. Разбиение графа 14 май 2004 21:08
Thank you very much!
Denis Can someone help me? I have WA 6... [3] // Задача 1320. Разбиение графа 9 дек 2007 04:07
#include <fstream>
#include <stdio.h>
using namespace std;

int n, nm = 0;
int arr[1010][1010] = {0};
int mark[1010] = {0};
int col[1010] = {0};

void dfs (int v)
{
    mark[v] = nm;
    int i;
    for (i = 1; i <= n; ++i)
    {
        if (mark[i] == 0 && arr[v][i] == 1)
        {
            dfs (i);
        }
    }
}

int main ()
{
    //freopen ("a.in", "r", stdin);
    //freopen ("a.out", "w", stdout);
    int i, a, b;
    n = 0;
    while (scanf("%d%d", &a, &b) == 2)
    {
        arr[a][b] = 1;
        arr[b][a] = 1;
        if (a < b)
        {
            swap (a, b);
        }
        if (n < a)
        {
            n = a;
        }
    }
    for (i = 1; i <= n; ++i)
    {
        if (mark[i] == 0)
        {
            ++nm;
            dfs (i);
        }
    }
    for (i = 1; i <= n; ++i)
    {
        ++col[mark[i]];
    }
    for (i = 1; i <= nm; ++i)
    {
        if (col[i] == 2)
        {
            printf ("0\n");
            return 0;
        }
    }
    printf ("1\n");
    return 0;
}
Rustam WA#6 too((( [1] // Задача 1320. Разбиение графа 8 сен 2008 22:32
{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J-,K-,L+,M-,N+,O-,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
program z1320;

{$APPTYPE CONSOLE}

uses
  SysUtils;
type
  pnode = ^tnode;
  tnode = record
    b:longint;
    next:pnode;
  end;
var a:array [1..1000] of pnode;
    c:array [1..1000] of longint;
    b:array [1..1000] of boolean;
    n,m,i,j,k,t:longint;
    x:pnode;
procedure init;
begin
  reset(input,'input.txt');
  rewrite(output,'output.txt');
end;
procedure print;
begin
  close(input);
  close(Output);
  halt(0);
end;
procedure swap(var a,b:longint);
var t:longint;
begin
 t:=a;
 a:=b;
 b:=t;
end;
procedure dfs(k:longint);
begin
  b[k]:=true;
  inc(c[m]);
  while a[k]<>nil do
    begin
     if b[a[k]^.b]=false then
      dfs(a[k]^.b);
     a[k]:= a[k]^.next;
    end;
end;
begin
  init;
  n:=0;
  while not seekeof(input) do
   begin
     read(i,j);
     new(x);
     x^.b:=j;
     x^.next:=a[i];
     a[i]:=x;
     new(x);
     x^.b:=i;
     x^.next:=a[j];
     a[j]:=x;
     if i<j then swap(i,j);
     if i>n then n:=i;
   end;
  m:=0;
  for i:=1 to n do
    if b[i]=false then
      begin
       inc(m);
       dfs(i);
      end;
  for i:=1 to m do
   if c[i]=2 then
    begin
     write(0);
     halt(0);
    end;
  write(1);
  print;
end.
Artem Ladik Re: WA#6 too((( // Задача 1320. Разбиение графа 13 сен 2008 01:26
type int=integer;

var n,i,j,col:int;
    g:array[1..1000,1..1000] of byte;
    vid:array[1..1000] of boolean;
    v:array[1..1000] of int;

    procedure dsd(curr,p:int);
    var j:int;
    begin
     for j:=1 to n do
      if (g[curr,v[j]]=1) and (not vid[v[j]]) and (j<>p) then
       begin
        inc(col);
        vid[v[j]]:=true;
        dsd(v[j],curr);
       end;
    end;

begin
n:=0;
 while not EOF do
  begin
   readln(i,j);
   g[i,j]:=1;
   g[j,i]:=1;
    if not vid[i] then begin inc(n);v[n]:=i;vid[i]:=true;end;
    if not vid[j] then begin inc(n);v[n]:=j;vid[j]:=true;end;
  end;

fillchar(vid,sizeof(vid),false);

  for i:=1 to n do
   if not vid[v[i]] then
    begin
     col:=0;
      vid[v[i]]:=true;
       dsd(v[i],0);
     if col<2 then begin write(0);halt;end;
    end;
 write(1);
end.