| Показать все ветки     Спрятать все ветки     Показать все сообщения     Спрятать все сообщения | 
| WA #2. Still everything is right. \\// Ошибка в тесте №2. Хотя всё и так правильно | Batyr Nuryyev | 1197. Один в поле воин | 14 мар 2016 23:36 | 1 | 
| Here it is. \\ //  Вот код.
 #include <iostream>
 
 using namespace std;
 
 int main()
 {
 int n;
 cin >> n;
 int arrint[n];
 char arrchar[n];
 
 for (int i = 0; i < n; i++)
 {
 cin >> arrchar[i] >> arrint[i];
 if ((int(arrchar[i]>104)) || (int(arrchar[i]) < 97)) break;
 if ((arrint[i] < 1) || (arrint[i] > 8)) break;
 }
 
 for (int i = 0; i < n; i++)
 {
 if ((int(arrchar[i]) >= 99) && int(arrchar[i]) <= 102)
 {
 if ((arrint[i] >= 3) && (arrint[i] <= 6))
 {
 cout << "8" << endl;
 }
 else if ((arrint[i] == 2) || (arrint[i] == 7))
 {
 cout << "6" << endl;
 }
 else
 {
 cout << "4" << endl;
 }
 }
 else if ((int(arrchar[i] == 98)) || (int(arrchar[i] == 103)))
 {
 if (((arrint[i]) >= 3) && (arrint[i] <= 6))
 {
 cout << "6" << endl;
 }
 else if ((arrint[i] == 2) || (arrint[i] == 7))
 {
 cout << "4" << endl;
 }
 else
 {
 cout << "2" << endl;
 }
 }
 else
 {
 if (((arrint[i]) >= 3) && (arrint[i] <= 6))
 {
 cout << "4" << endl;
 }
 else if (((arrint[i]) == 2) || (arrint[i] == 7))
 {
 cout << "3" << endl;
 }
 else
 {
 cout << "2" << endl;
 }
 }
 }
 
 return 0;
 }
 | 
| ошибка: Runtime error (access violation), подскажите как исправить? С++ | Krychun Ivan | 1001. Обратный корень | 14 мар 2016 21:11 | 2 | 
| #include <stdio.h>#include <tchar.h>
 #include <math.h>
 int charToNumber(char charValue)
 {
 if (charValue >= '0' && charValue <= '9') {
 return charValue - '0';
 }
 }
 int main()
 {
 int CountOfAllNumbers = 1;
 int CountOfNumbers = 0;
 bool flag = 0;
 double *numbers = new double[4];
 numbers[CountOfAllNumbers] = 0;
 char *A = new char [100];
 scanf("%s", &A);
 for (int i = strlen(A)-1; i >= 0; i--)
 {
 if (((A[i] == ' ') || (A[i] == '\t'))|| (A[i] == '\n'))
 {
 CountOfNumbers = 0;
 if (flag)
 {
 CountOfAllNumbers++;
 numbers[CountOfAllNumbers] = 0;
 flag = 0;
 }
 }
 else
 {
 flag = 1;
 numbers[CountOfAllNumbers] = numbers[CountOfAllNumbers] + charToNumber(A[i])*pow(10.0, CountOfNumbers);
 CountOfNumbers++;
 }
 }
 for (int i = 1; i < CountOfAllNumbers; i++)
 {
 printf("%lf\n", sqrt(numbers[i]));
 }
 delete[] numbers;
 return 0;
 }
 
 Edited by author 14.03.2016 16:28
You are trying to read WHOLE input in one read, into 100 bytes buffer.But input is up to 256Kb; scanf "%s" reads non-white-space data and stops on the first white-space.
 
 You expect not more then 4 numbers. There are up to 256K/2 numbers.
 
 You should better use scanf "%lld" / scanf "%lf" in the cycle. You should allocate big enough "numbers" array (or use std::vector).
 
 You also should run locally at least test in the task sample and receive EXACTLY the sample output.
 | 
| whats wrong!!!!!   Everything is right | shubham | 1293. Эния | 14 мар 2016 05:42 | 4 | 
| #include<stdio.h>
 main()
 {
 
 int n, a, b;
 int weight;
 
 while (scanf("%d", n) != EOF || scanf("%d", a) != EOF || scanf("%d",b) != EOF)
 {
 weight = n*a*b * 2;
 printf("%d", weight);
 }
 
 return 0;
 }
1. You should specify the return type value for the main function: int main() {}2. Is not necessarry to read the input data until the end of stream. Just read it one time:
 
 int n, a, b, w;
 scanf("%d%d%d", &n, &a, &b);
 w = n*a*b*2;
 printf("%d\n", w);
Please read scanf documentation. It returns count of read variables.Also - task description means 3 and only 3 integers to read. Why did you use "while" here?
The main problem is in "||". You should use "&&" anyway. Otherwise, the shortpath magic happens. | 
| Runtime error in test 12 | Gorbatykh Michail | 1453. Ферзь | 14 мар 2016 02:14 | 1 | 
| I don't understand, where I made a mistake, but program crushes there everytime, although in my compilator it is works
 Edited by author 15.03.2016 01:56
 | 
| test case 3 | zahra | 1454. Прямоугольники 2 | 14 мар 2016 01:30 | 1 | 
| judje saied my solution does not work correctly on #3 and i do not know what is #3but i think my code works correctly
 | 
| here is a solvation | Costel::icerapper@k.ro | 1100. Таблица результатов | 13 мар 2016 23:30 | 9 | 
| program timus_1100;const
 maxn=150000;
 var
 ID:array[1..maxn]of longint;
 np:array[1..maxn]of byte;
 n:longint;
 i,j:longint;
 begin
 readln(n);
 for i:=1 to n do
 readln(ID[i],np[i]);
 for i:=100 downto 0 do
 for j:=1 to n do
 if np[j]=i then
 writeln(ID[j],' ',np[j]);
 end.
the difficulty is too high!> program timus_1100;> const
 >   maxn=150000;
 > var
 >   ID:array[1..maxn]of longint;
 >   np:array[1..maxn]of byte;
 >   n:longint;
 >   i,j:longint;
 > begin
 >   readln(n);
 >   for i:=1 to n do
 >     readln(ID[i],np[i]);
 >   for i:=100 downto 0 do
 >     for j:=1 to n do
 >       if np[j]=i then
 >         writeln(ID[j],' ',np[j]);
 > end.
 >
i used this way and i've got wrong answer it third test.  maxn=150000;
 why 15000???? you have only 100!!!! | 
| Java 1.8 Program Works fine in console and eclipse but gives wrong answer | Sohan Agate | 1001. Обратный корень | 13 мар 2016 00:34 | 1 | 
| Program is in Java 1.8 but gives wrong answer on the timus server. Any help will be appreciated. Thanks a lot.
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Scanner;
 
 
 public class ReverseRoot {
 
 public static void main(String[] args) throws IOException {
 Scanner in = new Scanner(System.in);
 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
 List<Long> list = new ArrayList<Long>();
 while ( in.hasNextLong() ) {
 long l = in.nextLong();
 list.add(l);
 }
 DecimalFormatSymbols s = new DecimalFormatSymbols();
 s.setDecimalSeparator('.');
 DecimalFormat df = new DecimalFormat("#,####0.0000",s);
 for (int i = list.size() - 1; i >= 0; --i) {
 out.println(df.format(Math.sqrt(list.get(i))));
 out.flush();
 }
 
 }
 }
 | 
| Why wrong?????????????? | IT | 1617. Ползуны | 12 мар 2016 20:21 | 1 | 
| varA:array[1..1000] of integer;
 i,s,n,b,r,m,j,k,d,q:integer;
 begin
 s:=0;
 r:=0;
 q:=0;
 read(n);
 for i:=1 to n do readln(A[i]);
 begin
 for i := 1 to n-1 do
 for j := 1 to n-i do
 if A[j] > A[j+1] then begin
 k := A[j];
 A[j] := A[j+1];
 A[j+1] := k
 end;
 end;
 
 for i:=1 to (n-1) do begin
 d:=i+q;
 if (A[d]=A[d+1]) then s:=s+1 else s:=0;
 if s=3 then begin r:=r+1; s:=0; q:=1+q; end;
 
 
 
 
 
 
 end;
 write(r);
 end.
 | 
| What is trickly test 2? | Strekalovsky Oleg [Vologda SPU #1] | 1876. Утро сороконожки | 12 мар 2016 19:32 | 11 | 
| no,need 39*2 + 40 + 60 * 2 + 1This problem don't need more than 3 tests, I think ;)
 Edited by author 22.10.2011 20:08
NO, I think this problem don't need more than 2 tests.
 there are 2 possible answers:
 
 2*a+39 and 2*b+40.
 
 you must choose biggest
Why 39 ????? What is 2*a+39 ?????Why 39 ????? What is 2*a+39 ????? 39 * 2 + 40 + (a - 40) * 2 + 1 = 2 * a + 39 | 
| I understand myself. Here is explaining | IlushaMax | 1225. Флаги | 12 мар 2016 16:59 | 1 | 
| Let W is WHITE, R is RED, B is BLUESo for n=1:
 f(n)=2
 W or R;
 for n=2:
 f(n)=2 too
 WR or RW;
 And now the most interesting:
 for n=3:
 f(n)=
 We add to combinations of n-1 W or R:  WRW or RWR;
 +
 We add to combinations of n-2 RB or WB: RBW or WBR;
 =f(n-1)+f(n-2);
 So you can check it for n=4 and n=5///It's really easy
 | 
| HELP! merge_sort gets WA#5 ,who can give me some test cases,please? | Fighting | 1090. Теперь ты в армии | 12 мар 2016 14:12 | 2 | 
|  | 
| text 9 Runtime error (access violation) | Emily Huo | 1001. Обратный корень | 9 мар 2016 17:14 | 2 | 
|     #include <stdio.h>#include <math.h>
 #define N 100000
 int main(){
 double n;
 double line[N];
 int i = 0 ;
 
 while(scanf("%lf",&n) != EOF)
 {
 line[i++] = n;
 }
 while(i-- > 1)
 {
 printf("%0.4lf\n",sqrt(line[i]));
 }
 printf("%0.4lf",sqrt(line[i]));
 return 0;
 }
> #define N 100000
 Why do you think 100,000 is enough?
 Why do you place so big arrays on stack? You should better use std::vector or dynamic allocation.
 Why do you have 2 equal "printf" lines? You should better change "while" condition.
 | 
| PLEASE HELP!!! WA #3 | kami_botanik | 1002. Телефонные номера | 9 мар 2016 15:29 | 1 | 
| I tried all tests given from kind people in forum and also I tried my own different tests. I have passed in all of it, but I got Wrong Anser 3. Can anybody help me with some tests or someting else?... Please be kind ((( | 
| Why on FPS There isn't any compilation errors but when i'm trying to send it then compilation error | IlushaMax | 2023. Дональд-почтальон | 9 мар 2016 02:33 | 1 | 
|  
 Edited by author 09.03.2016 02:44
 | 
| Test 6. What's wrong? pascal | Nick | 1787. Поворот на МЕГУ | 8 мар 2016 20:23 | 1 | 
| var minutes, carsAtMin, stay, i: byte;countOfCars: array[0..100] of integer;
 BEGIN
 readln(carsAtMin, minutes);
 stay := 0;
 for i:=1 to minutes do
 readln(countOfCars[i]);
 for i:=1 to minutes do
 begin
 countOfCars[i] := countOfCars[i] + stay;
 stay := 0;
 if (countOfCars[i] - carsAtMin > 0) then stay := countOfCars[i] - carsAtmin;
 end;
 if (stay > 0) then write(stay)
 else write('0');
 END.
 | 
| HINT | IlushaMax | 1924. Четыре чертёнка | 8 мар 2016 16:19 | 1 | 
| HINT IlushaMax 8 мар 2016 16:19 Use properties of arithmetic progression | 
| time limit exceeded | IT | 1880. Собственные числа Psych Up | 8 мар 2016 15:02 | 2 | 
| varA:array[1..4000] of integer;
 B:array[1..4000] of integer;
 C:array[1..4000] of integer;
 q,w,e,r,t,y,i,o,p,s:integer;
 begin
 read(q);
 for r:=1 to q do read(A[r]);
 read(w);
 for t:=1 to w do read(B[t]);
 read(e);
 for y:=1 to e do read(C[y]);
 for i:=1 to q do begin
 for o:=1 to w do
 for p:=1 to e do
 if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);
 end;
 write(s);
 end.
You should make variables like i1 ,i2, i3 but not q,w,e.r,t,y you know?So your program isn't clear.
 And about your timelimi.... :
 put here
 for o:=1 to w do
 >>>
 for p:=1 to e do
 if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);
 this: if A[i]=B[o] then begin
 for p:=1 to e do
 if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);end;
 and...think about what you can delete from this:  if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);end;
 | 
| Pascal and binary operations | Demenev Dmitriy | 1877. Велосипедные коды | 7 мар 2016 19:55 | 4 | 
| I used binary operations to solve the problem and I didn't manage make my algorithm faster. My algorithm is too slow (0.015 sec). Could you give me a little advice how I can optimise my algorithm? My facebook: https://www.facebook.com/dmitriy.demenev.7Time is rounded here, so you can only see results like 0.001, 0.015, 0.031, 0.046, 0.062 etc. 0.001 and 0.015 are pretty much equal, and 0.015 can mean pretty much anything between 0.002 and 0.015. Like 0.001, 0.015 is an ideal time, there's nothing to optimize here. Only starting from 0.031 the program might be considered "slightly slow".Thank you, Jane. It was really important for me. I got crazy of this runtime. It was like a bolt out of the blue xD Good luck!.
 Btw, sorry for my English :D
 | 
| Help me, please! Pascal... | KOTMAKRUS | 1293. Эния | 7 мар 2016 18:44 | 3 | 
| program en;var a,b,c:byte;
 BEGIN
 read(a,b,c);
 write(b*c*2*5);
 END.
 
 Where my mistake? Test 2 - Wrong Answer...
I am stupid.....))write(b*c*2*a); .....
for 0.001 sec write(a*b*c+a*b*c) | 
| 0.001 second How it's possible? My result: 0.015 | IlushaMax | 1785. Трудности локализации | 7 мар 2016 18:34 | 1 | 
|  |