fork(1) download
  1. program cow;
  2. {$o-}
  3. {$APPTYPE CONSOLE}
  4. uses
  5. Math, StrUtils, SysUtils;
  6. type
  7. ex=extended;
  8. int=longint;
  9. bool=boolean;
  10. var
  11. a,b,c: array [1..10] of int;
  12. f: bool;
  13. i,j,n,y,z: int;
  14. s: string;
  15.  
  16. function check(s,t: string; a,b: int): bool;
  17. var
  18. i,c,d: int;
  19. begin
  20. c:= 0;
  21. d:= 0;
  22. for i:= 1 to 4 do
  23. if pos(s[i],t)=i
  24. then
  25. inc(c)
  26. else
  27. if pos(s[i],t)>0
  28. then
  29. inc(d);
  30. result:= (a=c)and(b=d);
  31. end;
  32.  
  33. function conv(n: int): string;
  34. begin
  35. result:= inttostr(n);
  36. if n<1000
  37. then
  38. result:= '0'+result;
  39. end;
  40.  
  41. function ok(n: int): bool;
  42. var
  43. a,b,c,d: int;
  44. begin
  45. a:= n mod 10;
  46. n:= n div 10;
  47. b:= n mod 10;
  48. n:= n div 10;
  49. c:= n mod 10;
  50. d:= n div 10;
  51. result:= not((a=b)or(a=c)or(a=d)or(b=c)or(b=d)or(c=d));
  52. end;
  53.  
  54. begin
  55. readln(n);
  56. y:= 0;
  57. z:= 0;
  58. for i:= 1 to n do
  59. readln(a[i],b[i],c[i]);
  60. for i:= 123 to 9876 do
  61. begin
  62. if not ok(i)
  63. then
  64. continue;
  65. s:= conv(i);
  66. f:= true;
  67. for j:= 1 to n do
  68. f:= f and check(s,conv(a[j]),b[j],c[j]);
  69. if f
  70. then
  71. begin
  72. inc(z);
  73. y:= i;
  74. end;
  75. end;
  76. if z=1
  77. then
  78. writeln(y)
  79. else
  80. if z=0
  81. then
  82. writeln('Incorrect data')
  83. else
  84. writeln('Need more data');
  85. //readln;
  86. end.
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
2
1263 1 2
8103 2 1
compilation info
Free Pascal Compiler version 2.2.0 [2009/11/16] for i386
Copyright (c) 1993-2007 by Florian Klaempfl
Target OS: Linux for i386
Compiling prog.pas
prog.pas(3,2) Warning: APPTYPE is not supported by the target OS
prog.pas(30,7) Error: Identifier not found "result"
prog.pas(35,7) Error: Identifier not found "result"
prog.pas(38,9) Error: Identifier not found "result"
prog.pas(38,22) Error: Identifier not found "result"
prog.pas(51,7) Error: Identifier not found "result"
prog.pas(59,2) Warning: Variable "a" does not seem to be initialized
prog.pas(59,2) Warning: Variable "b" does not seem to be initialized
prog.pas(59,2) Warning: Variable "c" does not seem to be initialized
prog.pas(86,4) Fatal: There were 5 errors compiling module, stopping
Fatal: Compilation aborted
Error: /usr/bin/ppc386 returned an error exitcode (normal if you did not specify a source file to be compiled)
stdout
Standard output is empty